blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
201
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 7
100
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 260
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 11.4k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 80
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 8
9.86M
| extension
stringclasses 52
values | content
stringlengths 8
9.86M
| authors
sequencelengths 1
1
| author
stringlengths 0
119
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fc8c7494e190ba68706c9203ff226dda86d50b40 | b8591378dd82ca72eb0985c925c3201ea034e502 | /l4/init.cc | c94b41703a0716ead8264969a763e2fa32a4ed59 | [] | no_license | ryougi1/internet | bdd914ab177d953ccd2137ed842a0ef8a8a16412 | bbe32648f30a266a0ddce8eb754c7a22528fd331 | refs/heads/master | 2021-05-10T21:53:34.125982 | 2018-03-14T19:29:45 | 2018-03-14T19:29:45 | 118,243,319 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,244 | cc | /*!**************************************************************************
*! FILE NAME : init.cc
*!
*! DESCRIPTION: The implementation of initialisation for the
*! CD server
*!
*!**************************************************************************/
#include <stddef.h>
extern "C" {
#include "compiler.h"
#include "system.h"
#include "osys.h"
#include "msg.h"
#include "reschedule.h"
}
#include "iostream.hh"
#include "threads.hh"
#include "job.hh"
#include "timer.hh"
#include "frontpanel.hh"
#include "ethernet.hh"
#include "llc.hh"
#define D_INIT
#ifdef D_INIT
#define trace cout
#else
#define trace if(false) cout
#endif
//*#**************************************************************************
//*#
void* operator new(size_t mem_size)
{
return ::ax_malloc(mem_size);
}
//*#**************************************************************************
//*#
void operator delete(void* ptr)
{
::ax_free(ptr);
}
//*#**************************************************************************
//*#
enum { numberOfServers = 20,
serverStackSize = 4500,
jobQueueSoftLimit = 100 };
void
initJob()
{
// The enums are casted to ints, 'cos some compilers thinks that's cool.
cout << "Create "
<< static_cast<int>(numberOfServers) << " Job Servers, stack "
<< static_cast<int>(serverStackSize) << " bytes" << endl;
Job::createServers(numberOfServers, serverStackSize, jobQueueSoftLimit);
}
//*#**************************************************************************
//*#
extern "C" void
thread_main(void)
{
initJob();
FrontPanel::instance();
Ethernet::instance();
while (1)
{
mail_struct msg;
if (os_get(WAIT_FOREVER, &msg))
{
switch (msg.action_id)
{
case THREAD_TIMER_EXPIRED:
{
Timed* timerObj = (Timed*)msg.param_ptr;
timerObj->timerExpired();
}
break;
case THREAD_RESCHEDULE:
{
reschedule();
}
break;
case THREAD_PACKET_RECEIVED:
{
Ethernet::instance().decodeReceivedPacket();
}
break;
default:
break;
}
}
}
}
| [
"[email protected]"
] | |
121f185af1eee632968ca4c308cc109dc203a51a | d4a2c50a90792600c4d864fffe9c1a9d1ebd6acc | /dssf3/RTA/FftFreqDlg.h | 189da786c2a4675b7c7d1ab658dd66db91d4ef41 | [] | no_license | iwasen/MyProg | 3080316c3444e98d013587e92c066e278e796041 | a0755a21d77647261df271ce301404a4e0294a7b | refs/heads/master | 2022-12-30T00:28:07.539183 | 2020-10-25T06:36:27 | 2020-10-25T06:36:27 | 307,039,466 | 0 | 4 | null | null | null | null | SHIFT_JIS | C++ | false | false | 881 | h | #pragma once
#include "FftDlg.h"
// CFfrFreqDlg ダイアログ
class CFftFreqDlg : public CDialog
{
public:
CFftFreqDlg(CWnd* pParent = NULL); // 標準コンストラクタ
virtual ~CFftFreqDlg();
CFftDlg *m_pFftDlg;
int m_nMaxRange;
int m_nMinRange;
int m_nMaxFreq;
int m_nMinFreq;
// ダイアログ データ
enum { IDD = IDD_FFT_FREQ };
protected:
int CalcSliderPos(double fFreq);
int CalcFreq(int pos);
void SetFreqScale(CSliderCtrl &oSliderCtrl);
CSliderCtrl m_cFftMaxFreq;
CSliderCtrl m_cFftMinFreq;
DECLARE_MESSAGE_MAP()
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV サポート
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnDestroy();
afx_msg void OnNcDestroy();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
| [
"[email protected]"
] | |
1945ca553096a48d1b2bd52207003e1f3885c69b | 711e5c8b643dd2a93fbcbada982d7ad489fb0169 | /XPSP1/NT/printscan/wia/test/wiatest/wiatestview.cpp | 237d042a4d5cf05aa277a8103da25476aaed30b0 | [] | no_license | aurantst/windows-XP-SP1 | 629a7763c082fd04d3b881e0d32a1cfbd523b5ce | d521b6360fcff4294ae6c5651c539f1b9a6cbb49 | refs/heads/master | 2023-03-21T01:08:39.870106 | 2020-09-28T08:10:11 | 2020-09-28T08:10:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 66,493 | cpp | // WIATestView.cpp : implementation of the CWIATestView class
//
#include "stdafx.h"
#include "WIATest.h"
#include "WIATestDoc.h"
#include "WIATestView.h"
#include "Mainfrm.h"
#include "PropEdit.h"
#include "datacallback.h"
#include "devicecmddlg.h"
#include "iteminfodlg.h"
#include "mmsystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWIATestView
IMPLEMENT_DYNCREATE(CWIATestView, CFormView)
BEGIN_MESSAGE_MAP(CWIATestView, CFormView)
//{{AFX_MSG_MAP(CWIATestView)
ON_NOTIFY(TVN_SELCHANGED, IDC_DEVICE_ITEM_TREE, OnSelchangedDeviceItemTree)
ON_CBN_SELCHANGE(IDC_DEVICELIST_COMBO, OnSelchangeDevicelistCombo)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_ITEMPROP, OnDblclkListItemprop)
ON_COMMAND(ID_GETIMAGEDLG, OnGetimagedlg)
ON_COMMAND(ID_IDTGETBANDED, OnIdtgetbanded)
ON_COMMAND(ID_WIADATA, OnWiadata)
ON_COMMAND(ID_ADDDEVICE, OnAdddevice)
ON_COMMAND(ID_REFRESH, OnRefresh)
ON_COMMAND(ID_VIEW_TRANSFER_TOOLBAR, OnViewTransferToolbar)
ON_COMMAND(ID_EXECUTECOMMAND, OnExecutecommand)
ON_COMMAND(ID_DUMPDRVITEM_INFO, OnDumpdrvitemInfo)
ON_COMMAND(ID_DUMPAPPITEM_INFO, OnDumpappitemInfo)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_PAINTMODE_CHECKBOX, OnPaintmodeCheckbox)
ON_COMMAND(ID_RESETSTI, OnResetsti)
ON_COMMAND(ID_FULLPREVIEW, OnFullpreview)
ON_BN_CLICKED(IDC_THUMBNAILMODE, OnThumbnailmode)
ON_COMMAND(ID_DELETEITEM, OnDeleteitem)
ON_CBN_SELCHANGE(IDC_TYMED_COMBOBOX, OnSelchangeTymedCombobox)
ON_CBN_SELCHANGE(IDC_CLIPBOARDFORMAT_COMBOBOX, OnSelchangeClipboardFormatCombobox)
ON_UPDATE_COMMAND_UI(ID_VIEW_TRANSFER_TOOLBAR, OnUpdateViewTransferToolbar)
ON_BN_CLICKED(IDC_PLAYAUDIO_BUTTON, OnPlayaudioButton)
ON_COMMAND(ID_GETROOTITEMTEST, OnGetrootitemtest)
ON_COMMAND(ID_REENUMITEMS, OnReenumitems)
ON_COMMAND(ID_SAVEPROPSTREAM, OnSavepropstream)
ON_COMMAND(ID_LOADPROPSTREAM, OnLoadpropstream)
ON_COMMAND(ID_GET_SET_PROPSTREAM_TEST, OnGetSetPropstreamTest)
ON_COMMAND(ID_ANALYZE, OnAnalyzeItem)
ON_COMMAND(ID_CREATE_CHILD_ITEM, OnCreateChildItem)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWIATestView construction/destruction
CWIATestView::CWIATestView()
: CFormView(CWIATestView::IDD)
{
//{{AFX_DATA_INIT(CWIATestView)
m_FileName = _T("");
m_GUIDDisplay = _T("");
//}}AFX_DATA_INIT
m_pIWiaDevMgr = NULL;
m_pDIB = NULL;
m_pPreviewWindow = NULL;
m_pFullPreviewWindow = NULL;
m_PaintMode = PAINT_TOFIT;
m_bThumbnailMode = FALSE;
m_pThumbNail = NULL;
m_hBitmap = NULL;
}
/**************************************************************************\
* CWIATestView::~CWIATestView()
*
* Destructor for WIA object:
* Deletes WIA preview window
* Deletes FULL preview window
* unregisters for Events
*
*
* Arguments:
*
* none
*
*
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
CWIATestView::~CWIATestView()
{
//
// delete preview window pointer, if exists
//
if (m_pPreviewWindow != NULL)
delete m_pPreviewWindow;
//
// delete FULL preview window pointer, if exists
//
if (m_pFullPreviewWindow != NULL) {
m_pFullPreviewWindow->DestroyWindow();
delete m_pFullPreviewWindow;
}
//
// unregister from events
//
UnRegisterForAllEventsByInterface();
}
/**************************************************************************\
* CWIATestView::DoDataExchange()
*
* Maps messages from controls to member variables
*
*
* Arguments:
*
* pDX - CDataExchange object
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWIATestView)
DDX_Control(pDX, IDC_PLAYAUDIO_BUTTON, m_PlayAudioButton);
DDX_Control(pDX, IDC_TYMED_COMBOBOX, m_TymedComboBox);
DDX_Control(pDX, IDC_THUMBNAIL, m_ThumbnailImage);
DDX_Control(pDX, IDC_PREVIEW, m_PreviewFrame);
DDX_Control(pDX, IDC_LIST_ITEMPROP, m_ItemPropertyListControl);
DDX_Control(pDX, IDC_DEVICELIST_COMBO, m_DeviceListComboBox);
DDX_Control(pDX, IDC_DEVICE_ITEM_TREE, m_ItemTree);
DDX_Control(pDX, IDC_CLIPBOARDFORMAT_COMBOBOX, m_ClipboardFormatComboBox);
DDX_Text(pDX, IDC_FILENAME_EDITBOX, m_FileName);
//}}AFX_DATA_MAP
}
/**************************************************************************\
* CWIATestView::PreCreateWindow()
*
* Sets window creation parameters.
*
*
* Arguments:
*
* cs - CREATESTRUCT, window construction params
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
BOOL CWIATestView::PreCreateWindow(CREATESTRUCT& cs)
{
return CFormView::PreCreateWindow(cs);
}
/**************************************************************************\
* CWIATestView::OnInitialUpdate()
*
* Initialization routine for FORM
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
//
// Set default file name
//
m_AudioFileName = "test.wav";
m_FileName = "c:\\test";
UpdateData(FALSE);
//
// hide audio play button
//
m_PlayAudioButton.ShowWindow(SW_HIDE);
//
// resize mainframe to fit resource template
//
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE);
//
// set transfer type radio button
//
CButton* pRadioButton = (CButton*)GetDlgItem(IDC_TOMEMORY);
if (pRadioButton != NULL)
pRadioButton->SetCheck(1);
//
// initialize clipboard type combo box
//
m_ClipboardFormatComboBox.InitClipboardFormats(NULL,NULL);
//
// initialize tymed combo box
//
m_TymedComboBox.InitTymedComboBox();
//
// initialize headers for Property list control
//
m_ItemPropertyListControl.InitHeaders();
//
// initialize headers for Item tree control
//
m_ItemTree.InitHeaders();
if(FAILED(m_WIA.Initialize())){
AfxMessageBox("WIA did not initialize correctly..");
exit(0);
}
HRESULT hResult = S_OK;
hResult = EnumerateWIADevices();
if (SUCCEEDED(hResult))
StressStatus("Device Enumeration Successful");
else
StressStatus("* EnumerateWIADevices() Failed",hResult);
if (((CWIATestApp*)AfxGetApp())->GetDeviceIDCommandLine() == "") {
if (m_WIA.GetWIADeviceCount() > 0) {
if (!DoDefaultUIInit()) {
StressStatus("* WIATest UI Failed attempting to do DEFAULT UI setup");
exit(0);
}
} else {
AfxMessageBox("There are no WIA devices on this system..WIATEST will now exit");
exit(0);
}
} else
if (!DoCmdLineUIInit(((CWIATestApp*)AfxGetApp())->GetDeviceIDCommandLine()))
StressStatus("* WIATest UI Failed attempting to do CommandLine UI setup");
if (m_pPreviewWindow == NULL) {
m_pPreviewWindow = new CWIAPreview;
if (m_pPreviewWindow != NULL) {
RECT PreviewFrameRect;
m_PreviewFrame.GetWindowRect(&PreviewFrameRect);
ScreenToClient(&PreviewFrameRect);
if (!m_pPreviewWindow->Create(NULL,"WIA Preview Window",WS_CHILD|WS_BORDER|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,this,NULL)) {
StressStatus("Preview Window Failed to create..",0);
} else {
//
// hide the place holder frame
//
m_PreviewFrame.ShowWindow(SW_HIDE);
//
// hide both scroll bars
//
m_pPreviewWindow->ShowScrollBar(SB_BOTH,FALSE);
//
// paint NULL image (white background)
//
DisplayImage();
}
}
}
//
// Register for Connect / Disconnect Events
//
RegisterForAllEventsByInterface();
GetDocument()->SetTitle(m_DeviceListComboBox.GetCurrentDeviceName());
((CMainFrame*)GetParent())->ActivateSizing(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// CWIATestView diagnostics
#ifdef _DEBUG
void CWIATestView::AssertValid() const
{
CFormView::AssertValid();
}
void CWIATestView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CWIATestDoc* CWIATestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWIATestDoc)));
return(CWIATestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWIATestView message handlers
/**************************************************************************\
* CWIATestView::EnumerateWIADevices()
*
* Enumerates all WIA devices on the system
*
*
* Arguments:
*
* none
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
HRESULT CWIATestView::EnumerateWIADevices()
{
HRESULT hResult = S_OK;
LONG cItemRoot = 0;
BOOL bRet = FALSE;
int DeviceIndex = 0;
m_DeviceListComboBox.ResetContent();
//
// attempt to enumerate WIA devices
//
m_WIA.Auto_ResetDeviceEnumerator();
WIADEVICENODE* pDeviceNode = NULL;
do {
pDeviceNode = m_WIA.Auto_GetNextDevice();
if (pDeviceNode != NULL) {
BSTR bstrDeviceID = ::SysAllocString(pDeviceNode->bstrDeviceID);
BSTR bstrDeviceName = ::SysAllocString(pDeviceNode->bstrDeviceName);
BSTR bstrServerName = ::SysAllocString(pDeviceNode->bstrServerName);
m_DeviceListComboBox.AddDeviceID(DeviceIndex, bstrDeviceName, bstrServerName, bstrDeviceID);
StressStatus((CString)bstrDeviceName + " Found..");
//
// Free BSTRs allocated
//
::SysFreeString(bstrDeviceName);
::SysFreeString(bstrServerName);
DeviceIndex++;
}
} while (pDeviceNode != NULL);
//
// No devices found during enumeration?
//
if (DeviceIndex == 0) {
m_DeviceListComboBox.AddDeviceID(-1, NULL, NULL, NULL);
StressStatus("* No WIA Devices Found");
}
//
// set the default combo box settings
//
m_DeviceListComboBox.SetCurSel(0);
return hResult;
}
/**************************************************************************\
* CWIATestView::DoDefaultUIInit()
*
* Handles default launch initialization of parameters
*
*
* Arguments:
*
* none
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
BOOL CWIATestView::DoDefaultUIInit()
{
int nDeviceNum = 0;
HRESULT hResult = S_OK;
if (SUCCEEDED(m_WIA.CreateWIADevice(m_DeviceListComboBox.GetCurrentDeviceID()))){
if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
StressStatus("* BuildItemTree Failed");
else{
OnSelchangeTymedCombobox();
m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
}
}else{
if(IsWindow(m_ItemPropertyListControl.m_hWnd))
m_ItemPropertyListControl.DeleteAllItems();
if(IsWindow(m_ItemTree.m_hWnd))
m_ItemTree.DeleteAllItems();
return FALSE;
}
return TRUE;
}
/**************************************************************************\
* CWIATestView::DoCmdLineUIInit()
*
* Handles command line launch initialization
*
*
* Arguments:
*
* CmdLine - Device ID used to set the default device
*
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
BOOL CWIATestView::DoCmdLineUIInit(CString CmdLine)
{
int nDeviceNum = 0;
HRESULT hResult = S_OK;
m_DeviceListComboBox.SetCurrentSelFromID(CmdLine);
if (SUCCEEDED(m_WIA.CreateWIADevice(m_DeviceListComboBox.GetCurrentDeviceID()))) {
if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
StressStatus("* BuildItemTree Failed");
else {
OnSelchangeTymedCombobox();
m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
}
}else{
m_ItemPropertyListControl.DeleteAllItems();
m_ItemTree.DeleteAllItems();
}
return TRUE;
}
/**************************************************************************\
* CWIATestView::OnSelchangedDeviceItemTree()
*
* Handles the message for changing item selection in the device Item tree
*
*
* Arguments:
*
* pNMHDR - Notification handler
* pResult - result after notification is handled
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnSelchangedDeviceItemTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
IWiaItem* pIWiaItem = NULL;
WIAITEMTREENODE* pWiaItemTreeNode = NULL;
if (m_ItemTree.GetCount() > 1) {
POSITION Position = (POSITION)pNMTreeView->itemNew.lParam;
if (Position) {
#ifdef _SMARTUI
if (m_WIA.IsRoot(Position)) {
//
// enable GetImageDlg button
//
CMainFrame* pMainFrm = (CMainFrame*)GetParent();
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_GETIMAGEDLG,FALSE))
StressStatus("* GetImageDlg Button failed to be unhidden..");
} else {
//
// disable GetImageDlg button
//
CMainFrame* pMainFrm = (CMainFrame*)GetParent();
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_GETIMAGEDLG,TRUE))
StressStatus("* GetImageDlg Button failed to be hidden..");
}
#endif
pWiaItemTreeNode = m_WIA.GetAt(Position);
if (pWiaItemTreeNode!= NULL) {
pIWiaItem = pWiaItemTreeNode->pIWiaItem;
if (pIWiaItem != NULL) {
//
// display Item information
//
m_ItemPropertyListControl.DisplayItemPropData(pIWiaItem,TRUE);
if (m_bThumbnailMode) {
//
// display item's thumbnail only if it's a child item, and
// only if it's a camera child item
//
if ( (m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
(m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo) ) {
if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position))
DisplayItemThumbnail(pIWiaItem);
}
}
if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
(m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position)) {
if (ItemHasAudio(pIWiaItem))
m_PlayAudioButton.ShowWindow(SW_SHOW);
else
m_PlayAudioButton.ShowWindow(SW_HIDE);
}
else
m_PlayAudioButton.ShowWindow(SW_HIDE);
}
OnSelchangeTymedCombobox();
}
}
}
}
*pResult = 0;
}
/**************************************************************************\
* CWIATestView::OnSelchangeDevicelistCombo()
*
* Handles the message for changing current devices in the device combo box
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnSelchangeDevicelistCombo()
{
DoDefaultUIInit();
GetDocument()->SetTitle(m_DeviceListComboBox.GetCurrentDeviceName());
}
/**************************************************************************\
* CWIATestView::OnDblclkListItemprop()
*
* Handles the message for double-clicking on an item in the list control
*
* Arguments:
*
* pNMHDR - Notification handler
* pResult - result after notification is handled
*
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnDblclkListItemprop(NMHDR* pNMHDR, LRESULT* pResult)
{
CPropEdit Edit;
CPropEditRange EditRange;
CPropEditList EditList;
CPropEditFlags EditFlags;
int EditType = EDIT_NONE;
ULONG AccessFlags = 0;
PROPVARIANT AttrPropVar;
PROPSPEC PropSpec;
HRESULT hResult = S_OK;
IWiaPropertyStorage *pIWiaPropStg;
int nResponse = 0;
//
// find out what property is selected
//
HD_NOTIFY* phdn = (HD_NOTIFY *) pNMHDR;
LV_ITEM lvitem;
LONG iProp = 0;
int item = phdn->iItem;
//
// is it a valid item?
//
if (item < 0)
return;
//
// set property values to null ("")
//
CString strProp = "";
CString strValue = "";
//
// Get selected values
//
strProp = m_ItemPropertyListControl.GetItemText(item,0);
strValue = m_ItemPropertyListControl.GetItemText(item,1);
lvitem.mask = LVIF_PARAM;
lvitem.iItem = item;
lvitem.iSubItem = 0;
m_ItemPropertyListControl.GetItem(&lvitem);
//
// Assign Prop ID
//
iProp = (LONG)lvitem.lParam;
//
// setup dialogs with selected values (any one could be the selected type)
//
Edit.SetPropertyValue(strValue);
Edit.SetPropertyName(strProp);
EditRange.SetPropertyValue(strValue);
EditRange.SetPropertyName(strProp);
EditList.SetPropertyValue(strValue);
EditList.SetPropertyName(strProp);
EditFlags.SetPropertyValue(strValue);
EditFlags.SetPropertyName(strProp);
//
// get access flags and var type
//
PropSpec.ulKind = PRSPEC_PROPID;
PropSpec.propid = iProp;
IWiaItem* pCurrentItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pCurrentItem != NULL && m_WIA.IsValidItem(pCurrentItem)) {
hResult = pCurrentItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
if (FAILED(hResult)) {
StressStatus("* pCurrentItem->QueryInterface() Failed",hResult);
return;
} else {
//
// read property value for type only
//
PROPVARIANT PropVar;
hResult = pIWiaPropStg->ReadMultiple(1,&PropSpec,&PropVar);
if (hResult == S_OK) {
//
// write TYPE to Dialogs
//
Edit.SetPropertyType(PropVar.vt);
EditRange.SetPropertyType(PropVar.vt);
EditList.SetPropertyType(PropVar.vt);
EditFlags.SetPropertyType(PropVar.vt);
EditFlags.SetPropID((USHORT)iProp);
} else
StressStatus("* pIWiaPropStg->ReadMultiple() Failed",hResult);
}
hResult = pIWiaPropStg->GetPropertyAttributes(1, &PropSpec,&AccessFlags,&AttrPropVar);
if (FAILED(hResult)) {
StressStatus("* pCurrentItem->GetPropertyAttributes() Failed",hResult);
hResult = S_OK; // do this to continue property traversal
} else {
//
// check access flags
//
if ((AccessFlags & WIA_PROP_NONE)) {
EditType = EDIT_NONE;
}
else if ((AccessFlags & WIA_PROP_RANGE)) {
EditType = EDIT_RANGE;
if (AttrPropVar.caul.cElems == 4) {
if (EditRange.m_VT == VT_R4) {
EditRange.SetRangeValues(
(float)AttrPropVar.caflt.pElems[WIA_RANGE_MIN],
(float)AttrPropVar.caflt.pElems[WIA_RANGE_MAX],
(float)AttrPropVar.caflt.pElems[WIA_RANGE_NOM],
(float)AttrPropVar.caflt.pElems[WIA_RANGE_STEP]);
} else {
EditRange.SetRangeValues(
(int)AttrPropVar.caul.pElems[WIA_RANGE_MIN],
(int)AttrPropVar.caul.pElems[WIA_RANGE_MAX],
(int)AttrPropVar.caul.pElems[WIA_RANGE_NOM],
(int)AttrPropVar.caul.pElems[WIA_RANGE_STEP]);
}
} else {
//
// elements does not equal 4
//
StressStatus("Range does not contain 4 elements");
}
}
else if ((AccessFlags & WIA_PROP_LIST)) {
UINT nElem = 0;
EditType = EDIT_LIST;
if(EditList.m_VT == VT_CLSID)
EditList.SetArray((BYTE*)AttrPropVar.cauuid.pElems, WIA_PROP_LIST_COUNT(&AttrPropVar));
else
EditList.SetArray((BYTE*)AttrPropVar.caul.pElems, WIA_PROP_LIST_COUNT(&AttrPropVar));
} else if ((AccessFlags & WIA_PROP_FLAG) == WIA_PROP_FLAG) {
//
// do flag dialog initialization here...
//
EditType = EDIT_FLAGS;
}
}
//
// determine which dialog to display
//
switch (EditType) {
case EDIT_LIST:
nResponse = (int) (INT_PTR)EditList.DoModal();
break;
case EDIT_RANGE:
nResponse = (int) (INT_PTR)EditRange.DoModal();
break;
case EDIT_FLAGS:
nResponse = (int) (INT_PTR)EditFlags.DoModal();
break;
default:
nResponse = (int) (INT_PTR)Edit.DoModal();
break;
}
if ((nResponse == IDOK) && (pCurrentItem != NULL)) {
LONG lVal = 0;
int iret = 0;
if (EditType == EDIT_FLAGS) {
hResult = WriteProp(EditFlags.m_VT, iProp, pIWiaPropStg, EditFlags.m_EditString.GetBuffer(20));
if (hResult != S_OK)
StressStatus("* WriteProp Failed Writing FLAG values",hResult);
} else if (EditType == EDIT_LIST) {
hResult = WriteProp(EditList.m_VT, iProp, pIWiaPropStg, EditList.m_EditString.GetBuffer(20));
if (hResult != S_OK)
StressStatus("* WriteProp Failed Writing LIST values",hResult);
} else if (EditType == EDIT_RANGE) {
hResult = WriteProp(EditRange.m_VT, iProp, pIWiaPropStg, EditRange.m_EditString.GetBuffer(20));
if (hResult != S_OK)
StressStatus("* WriteProp Failed Writing RANGE values",hResult);
} else {
hResult = WriteProp(Edit.m_VT, iProp, pIWiaPropStg, Edit.m_EditString.GetBuffer(20));
if (hResult != S_OK)
StressStatus("* WriteProp Failed Writing values",hResult);
}
//
// release IPropStg and IWiaItem
//
pIWiaPropStg->Release();
OnRefresh();
}
}
*pResult = 0;
}
/**************************************************************************\
* CWIATestView::OnGetimagedlg()
*
* Executes the GetImageDlg() call setting the intent
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnGetimagedlg()
{
UpdateData(TRUE);
m_WIA.SetFileName(m_FileName);
HRESULT hResult = S_OK;
hResult = m_WIA.DoGetImageDlg(m_hWnd, 0,0,WIA_INTENT_IMAGE_TYPE_GRAYSCALE|WIA_INTENT_MINIMIZE_SIZE,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
DisplayImage();
}
/**************************************************************************\
* CWIATestView::OnIdtgetbanded
*
* Initiates a banded transfer using the currently selected item
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnIdtgetbanded()
{
UpdateData(TRUE);
m_WIA.SetFileName(m_FileName);
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL){
m_WIA.SetPreviewWindow(m_pPreviewWindow->m_hWnd);
hResult = m_WIA.DoIWiaDataBandedTransfer(pIWiaItem,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
DisplayImage();
}
}
/**************************************************************************\
* CWIATestView::
*
* Initiates a IWiaDataTransfer, using the currently selected item
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnWiadata()
{
UpdateData(TRUE);
m_WIA.SetFileName(m_FileName);
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.DoIWiaDataGetDataTransfer(pIWiaItem,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
DisplayImage();
}
}
/**************************************************************************\
* CWIATestView::OnAdddevice()
*
* Creates a thread to add a device to the Device list combo box
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnAdddevice()
{
static HANDLE hAddDeviceThread;
static DWORD dwAddDeviceThreadId;
hAddDeviceThread = CreateThread(NULL,0, &AddDeviceThread,0,0,&dwAddDeviceThreadId);
if (!hAddDeviceThread)
StressStatus("* CreateThread failed");
}
/**************************************************************************\
* CWIATestView::OnRefresh()
*
* Forces a refresh of the selected items property data
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnRefresh()
{
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem))
m_ItemPropertyListControl.DisplayItemPropData(pIWiaItem);
}
/**************************************************************************\
* AddDeviceThread
*
* This is a thread that controls adding a device to the device combo box
*
*
* Arguments:
*
* pParam - not used at this time (extra information)
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
ULONG _stdcall AddDeviceThread(LPVOID pParam)
{
HRESULT hResult = S_OK;
CWIATestApp* pApp = (CWIATestApp*)AfxGetApp();
CMainFrame* pFrame = (CMainFrame*)pApp->GetMainWnd();
CWIATestView* pView = (CWIATestView*)pFrame->GetActiveView();
IWiaItem* pIWiaItem = NULL;
IWiaDevMgr* pIWiaDevMgr = NULL;
//
// initlialize OLE libs
//
hResult = ::OleInitialize(NULL);
if (hResult != S_OK)
StressStatus("* OleInitialize failed!");
//
// if OleInitialize is successful call CoCreateInstance for IWiaDevMgr
//
if (hResult == S_OK) {
//
// initialize IWiaDevMgr
//
hResult = CoCreateInstance(CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER,
IID_IWiaDevMgr,(void**)&pIWiaDevMgr);
if (hResult != S_OK)
StressStatus("* CoCreateInstance failed - pIWiaDevMgr not created");
else {
StressStatus("CoCreateInstance Successful - pIWiaDevMgr created");
hResult = pIWiaDevMgr->AddDeviceDlg(pFrame->m_hWnd,0);
if (SUCCEEDED(hResult)){
//
// refresh device list
//
pView->RefreshDeviceList();
pView->EnumerateWIADevices();
//
// set the default combo box settings
//
pView->m_DeviceListComboBox.SetCurSel(0);
}
else
StressStatus("* No Device added ");
pIWiaDevMgr->Release();
}
}
::OleUninitialize();
return 0;
}
/**************************************************************************\
* CWIATestView::OnViewTransferToolbar()
*
* Enables/Disables the Transfer toolbar
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnViewTransferToolbar()
{
CMainFrame* pMainFrame = (CMainFrame*)GetParent();
if (pMainFrame != NULL) {
if (pMainFrame->IsToolBarVisible(IDR_TRANSFER_TOOLBAR)) {
//
// hide toolbar
//
pMainFrame->ShowToolBar(IDR_TRANSFER_TOOLBAR,FALSE);
} else {
//
// show toolbar
//
pMainFrame->ShowToolBar(IDR_TRANSFER_TOOLBAR,TRUE);
}
}
}
/**************************************************************************\
* CWIATestView::DisplayImage
*
* paints the current DIB to the preview area
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::DisplayImage()
{
m_pDIB = m_WIA.GetDIB();
m_pPreviewWindow->SetPaintMode(m_PaintMode);
m_pPreviewWindow->SetDIB(m_pDIB);
m_pPreviewWindow->Invalidate();
if (m_pFullPreviewWindow != NULL) {
if (m_pFullPreviewWindow->m_hWnd != NULL) {
m_pFullPreviewWindow->SetPaintMode(PAINT_ACTUAL);
m_pFullPreviewWindow->SetDIB(m_pDIB);
m_pFullPreviewWindow->CleanBackground();
m_pFullPreviewWindow->Invalidate();
}
}
}
/**************************************************************************\
* CWIATestView::OnExecutecommand()
*
* Calls the DeviceCommand dialog, to execute device commands
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnExecutecommand()
{
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
CDeviceCmdDlg DeviceCommandDlg;
DeviceCommandDlg.Initialize(pIWiaItem);
DeviceCommandDlg.DoModal();
OnSelchangeDevicelistCombo();
}
}
/**************************************************************************\
* CWIATestView::RegisterForAllEventsByInterface()
*
* Register this application for CONNECT/DISCONNECT events
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::RegisterForAllEventsByInterface()
{
//
// register connected event
//
m_pConnectEventCB = new CEventCallback;
m_pDisConnectEventCB = new CEventCallback;
m_WIA.RegisterForConnectEvents(m_pConnectEventCB);
m_WIA.RegisterForDisConnectEvents(m_pDisConnectEventCB);
}
/**************************************************************************\
* CWIATestView::UnRegisterForAllEventsByInterface()
*
* Unregister this application from CONNECT/DISCONNECT events
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::UnRegisterForAllEventsByInterface()
{
m_WIA.UnRegisterForConnectEvents(m_pConnectEventCB);
m_WIA.UnRegisterForDisConnectEvents(m_pDisConnectEventCB);
}
/**************************************************************************\
* CWIATestView::UpdateUI()
*
* Updates the UI by posting a selection change message on the Device list
* combo box.
* note: this is called externally, after a CONNECT/DISCONNECT event is trapped
*
*
* Arguments:
*
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::UpdateUI()
{
OnSelchangeDevicelistCombo();
}
/**************************************************************************\
* CWIATestView::OnDumpdrvitemInfo()
*
* Dump Driver item information for DEBUGGING ONLY
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnDumpdrvitemInfo()
{
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
CItemInfoDlg ItemInfoDlg;
ItemInfoDlg.Initialize(pIWiaItem,FALSE);
ItemInfoDlg.DoModal();
}
}
/**************************************************************************\
* CWIATestView::OnDumpappitemInfo()
*
* Dump Application item information for DEBUGGING ONLY
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnDumpappitemInfo()
{
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
CItemInfoDlg ItemInfoDlg;
ItemInfoDlg.Initialize(pIWiaItem,TRUE);
ItemInfoDlg.DoModal();
}
}
/**************************************************************************\
* CWIATestView::OnPaint()
*
* Handles the painting of the application window
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
/**************************************************************************\
* CWIATestView::OnPaintmodeCheckbox()
*
* Enables/Disables 1 to 1 painting setting for the preview window
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnPaintmodeCheckbox()
{
if (m_PaintMode == PAINT_TOFIT)
m_PaintMode = PAINT_ACTUAL;
else
m_PaintMode = PAINT_TOFIT;
DisplayImage();
}
/**************************************************************************\
* CWIATestView::OnResetsti()
*
* Force STI to reset the current selected device.
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnResetsti()
{
//
// UnRegister from Connect / Disconnect Events
//
UnRegisterForAllEventsByInterface();
//
// cleanup all WIA devices
//
m_WIA.Shutdown();
PSTI pSti;
IStiDevice *pIStiDevice;
HRESULT hResult = S_OK;
hResult = StiCreateInstance(GetModuleHandle(NULL), STI_VERSION, &pSti, NULL);
if (hResult != S_OK)
StressStatus("* StiCreateInstance() Failed",hResult);
else {
hResult = pSti->CreateDevice(m_DeviceListComboBox.GetCurrentDeviceID(), STI_DEVICE_CREATE_STATUS, &pIStiDevice, NULL);
if (hResult != S_OK)
StressStatus("* pSti->CreateDevice() Failed",hResult);
else {
hResult = pIStiDevice->LockDevice(2000);
if (hResult != S_OK)
StressStatus("* pIStiDevice->LockDevice(2000) Failed",hResult);
else {
StressStatus("STI device is locked");
pIStiDevice->DeviceReset();
StressStatus("STI device is reset");
pIStiDevice->UnLockDevice();
StressStatus("STI device is unlocked");
pIStiDevice->Release();
pSti->Release();
}
}
}
m_WIA.Restart();
//
// Reform UI
//
DoDefaultUIInit();
//
// Register for Connect / Disconnect Events
//
RegisterForAllEventsByInterface();
}
/**************************************************************************\
* CWIATestView::OnFullpreview()
*
* Initiate a full preview window (scrolling enabled for larger pictures)
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnFullpreview()
{
if (m_pFullPreviewWindow == NULL) {
m_pFullPreviewWindow = new CWIAPreview;
if (m_pFullPreviewWindow != NULL) {
RECT PreviewFrameRect;
PreviewFrameRect.left = 0;
PreviewFrameRect.top = 0;
PreviewFrameRect.right = 400;
PreviewFrameRect.bottom = 400;
if (!m_pFullPreviewWindow->CreateEx(NULL,AfxRegisterWndClass(NULL),"WIA Preview Window",WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,NULL,NULL,NULL)) {
StressStatus("FULL Preview Window Failed to create..",0);
} else {
//
// paint NULL image (white background)
//
DisplayImage();
}
}
} else {
if (m_pFullPreviewWindow->m_hWnd == NULL) {
RECT PreviewFrameRect;
PreviewFrameRect.left = 0;
PreviewFrameRect.top = 0;
PreviewFrameRect.right = 400;
PreviewFrameRect.bottom = 400;
if (!m_pFullPreviewWindow->CreateEx(NULL,AfxRegisterWndClass(NULL),"WIA Preview Window",WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,NULL,NULL,NULL)) {
StressStatus("FULL Preview Window Failed to create..",0);
} else {
//
// paint NULL image (white background)
//
DisplayImage();
}
}
m_pFullPreviewWindow->ShowWindow(SW_SHOW);
}
}
/**************************************************************************\
* CWIATestView::ResizeControls()
*
* Resize the controls along with the main frame window
*
*
* Arguments:
*
* dx - change in width of main window
* dy - change in height on main window
*
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::ResizeControls(int dx, int dy)
{
m_ItemPropertyListControl.Resize(dx,dy);
}
/**************************************************************************\
* CWIATestView::OnThumbnailmode()
*
* Enables/Disables thumbnailing for picture items on digitial cameras
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnThumbnailmode()
{
POSITION Position = NULL;
HTREEITEM hTreeItem = NULL;
if (m_bThumbnailMode)
m_bThumbnailMode = FALSE;
else {
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
(m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
hTreeItem = m_ItemTree.GetSelectedItem();
if (hTreeItem != NULL) {
Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position))
DisplayItemThumbnail(pIWiaItem);
}
}
}
m_bThumbnailMode = TRUE;
}
}
/**************************************************************************\
* CWIATestView::DisplayItemThumbnail()
*
* Display thumbnail for the target item
*
*
* Arguments:
*
* pIWiaItem - Target item to thumbnail
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::DisplayItemThumbnail(IWiaItem *pIWiaItem)
{
long ThumbNailHeight = 0;
long ThumbNailWidth = 0;
long ThumbNailSize = 0;
if (m_pThumbNail != NULL) {
LocalFree(m_pThumbNail);
m_pThumbNail = NULL;
}
if (m_hBitmap != NULL) {
DeleteObject(m_hBitmap);
m_hBitmap = NULL;
}
m_pThumbNail = NULL;
IWiaPropertyStorage *pIWiaPropStg;
HRESULT hResult = S_OK;
HBITMAP hBitmap = NULL;
// get item's thumbnail height & width and create thumbnail
hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
if (hResult == S_OK) {
//
// read height
//
hResult = ReadPropLong(WIA_IPC_THUMB_HEIGHT, pIWiaPropStg, &ThumbNailHeight);
if (hResult != S_OK) {
StressStatus("* ReadPropLong(WIA_IPC_THUMB_HEIGHT) Failed",hResult);
ThumbNailHeight = 0;
}
//
// read width
//
hResult = ReadPropLong(WIA_IPC_THUMB_WIDTH, pIWiaPropStg, &ThumbNailWidth);
if (hResult != S_OK) {
StressStatus("* ReadPropLong(WIA_IPC_THUMB_WIDTH) Failed",hResult);
ThumbNailWidth = 0;
}
//
// read thumbnail data
//
PROPVARIANT PropVar[1];
PROPSPEC PropSpec[1];
memset(PropVar, 0, sizeof(PropVar));
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = WIA_IPC_THUMBNAIL;
hResult = pIWiaPropStg->ReadMultiple(1, PropSpec, PropVar);
if (hResult != S_OK) {
StressStatus("* ReadMultiple() asking for WIA_IPC_THUMBNAIL Failed",hResult);
m_pThumbNail = NULL;
} else {
ThumbNailSize = ThumbNailWidth * ThumbNailHeight * 3;
if (ThumbNailSize != (LONG)PropVar[0].caub.cElems) {
//
// force size to thumbnail's suggested size
//
ThumbNailSize = PropVar[0].caub.cElems;
}
m_pThumbNail = (PBYTE)LocalAlloc(LPTR,ThumbNailSize);
if (m_pThumbNail != NULL) {
memcpy(m_pThumbNail,PropVar[0].caub.pElems,ThumbNailSize);
HDC hdc = ::GetDC(NULL);
HDC hdcm = CreateCompatibleDC(hdc);
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = ThumbNailWidth;
bmi.bmiHeader.biHeight = ThumbNailHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
PBYTE pDib = NULL;
m_hBitmap = CreateDIBSection(hdc,&bmi,DIB_RGB_COLORS,(void **)&pDib,NULL,0);
memcpy(pDib,m_pThumbNail,ThumbNailSize);
m_ThumbnailImage.SetBitmap(m_hBitmap);
m_ThumbnailImage.Invalidate();
}
}
//
// release propstg
//
pIWiaPropStg->Release();
}
}
/**************************************************************************\
* CWIATestView::OnDeleteitem()
*
* Deletes the selected item
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnDeleteitem()
{
HRESULT hResult = S_OK;
POSITION TestPosition = NULL;
POSITION Position = NULL;
HTREEITEM hTreeItem = NULL;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem == NULL) {
StressStatus("* Item selected for deletion is NULL!!!");
return;
}
if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
(m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
//
// Get selected item (to be deleted)
//
hTreeItem = m_ItemTree.GetSelectedItem();
if (hTreeItem != NULL) {
//
// What's the selected item's position in the
// m_ActiveTreeList??
//
Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
}
//
// test to make sure it's not a root item
//
if (!m_WIA.IsRoot(Position)) {
if (pIWiaItem != NULL) {
hResult = pIWiaItem->DeleteItem(0);
if (hResult == S_OK) {
//
// release selected item
//
pIWiaItem->Release();
//
// kill item from m_ActiveTreeList
//
m_WIA.RemoveAt(Position);
//
// kill item from tree control (visual delete)
//
m_ItemTree.DeleteItem(hTreeItem);
}
}
} else
AfxMessageBox("You can not delete the Root Item");
} else {
//
// Get selected item (to be deleted)
//
hTreeItem = m_ItemTree.GetSelectedItem();
if (hTreeItem != NULL) {
//
// What's the selected item's position in the
// m_ActiveTreeList??
//
Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
}
//
// test to make sure it's not a root item
//
if (!m_WIA.IsRoot(Position)) {
if (pIWiaItem != NULL) {
if (MessageBox("You just attempted to delete a scanner item..\nDo you really want to execute a DeleteItem()\ncall on this scanner item to see what happens?","WIATest Testing Question",MB_YESNO|MB_ICONQUESTION) == IDYES) {
hResult = pIWiaItem->DeleteItem(0);
if (hResult == S_OK) {
OnReenumitems();
} else
StressStatus("* pIWiaItem->DeleteItem() called on a scanner item Failed",hResult);
}
}
} else
AfxMessageBox("You can not delete the Root Item");
}
}
/**************************************************************************\
* CWIATestView::OnSelchangeTymedCombobox()
*
* Handles the message for a selection change in the TYMED combo box
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnSelchangeTymedCombobox()
{
if (m_TymedComboBox.GetCurrentTymed() != TYMED_FILE) {
//
// disable File Edit box
//
CWnd* pWnd = GetDlgItem(IDC_FILENAME_EDITBOX);
if (pWnd != NULL)
pWnd->EnableWindow(FALSE);
} else {
//
// enable File Edit box
//
CWnd* pWnd = GetDlgItem(IDC_FILENAME_EDITBOX);
if (pWnd != NULL)
pWnd->EnableWindow(TRUE);
}
#ifdef _SMARTUI
if (m_TymedComboBox.GetCurrentTymed() == TYMED_CALLBACK) {
//
// hide IWiaData Toolbar button and
// unhide idtGetBanded Toolbar button
//
CMainFrame* pMainFrm = (CMainFrame*)GetParent();
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_IDTGETBANDED,FALSE))
StressStatus("* idtGetBanded Button failed to be unhidden..");
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_WIADATA,TRUE))
StressStatus("* IWiaData Button failed to be hidden..");
} else {
//
// hide idtGetBanded Toolbar button and
// unhide IWiaData Toolbar button
//
CMainFrame* pMainFrm = (CMainFrame*)GetParent();
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_IDTGETBANDED,TRUE))
StressStatus("* idtGetBanded Button failed to be hidden..");
if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_WIADATA,FALSE))
StressStatus("* IWiaData Button failed to be unhidden..");
}
#endif
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem != NULL) {
m_WIA.EnumerateSupportedFormats(pIWiaItem);
m_ClipboardFormatComboBox.InitClipboardFormats(m_WIA.GetSupportedFormatList(),m_TymedComboBox.GetCurrentTymed());
}
//
// Force update and change..
//
OnSelchangeClipboardFormatCombobox();
}
/**************************************************************************\
* CWIATestView::OnSelchangeClipboardFormatCombobox()
*
* Handles the message for a selection change in the clipboard format combo box
*
*
* Arguments:
*
* -
* -
* -
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnSelchangeClipboardFormatCombobox()
{
HRESULT hResult = S_OK;
POSITION Position = NULL;
HTREEITEM hTreeItem = NULL;
IWiaPropertyStorage *pIWiaPropStg;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if (pIWiaItem == NULL) {
StressStatus("* Item selected for setting is NULL!!!");
return;
}
//
// Get selected item
//
hTreeItem = m_ItemTree.GetSelectedItem();
if (hTreeItem != NULL) {
//
// What's the selected item's position in the
// m_ActiveTreeList??
//
Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
}
//
// test to make sure it's not a root item
//
if (!m_WIA.IsRoot(Position)) {
hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
if (hResult != S_OK) {
StressStatus("* pCurrentItem->QueryInterface() Failed",hResult);
return;
} else {
//
// Write property value for TYMED
//
hResult = WritePropLong(WIA_IPA_TYMED,pIWiaPropStg,m_TymedComboBox.GetCurrentTymed());
if (hResult == S_OK)
StressStatus("tymed Successfully written");
else
StressStatus("* WritePropLong(WIA_IPA_TYMED) Failed",hResult);
//
// Write property value for SUPPORTED WIA FORMAT
//
hResult = WritePropGUID(WIA_IPA_FORMAT,pIWiaPropStg,m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
if (hResult == S_OK)
StressStatus("Format Successfully written");
else
StressStatus("* WritePropLong(WIA_IPA_FORMAT) Failed",hResult);
OnRefresh();
}
}
}
/**************************************************************************\
* CWIATestView::OnUpdateViewTransferToolbar()
*
* Updates the Check/uncheck display on the menu for toolbar display status
*
*
* Arguments:
*
* pCmdUI - CommandUI handler
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnUpdateViewTransferToolbar(CCmdUI* pCmdUI)
{
CMainFrame* pMainFrm = (CMainFrame*)GetParent();
if(pMainFrm != NULL)
pCmdUI->SetCheck(pMainFrm->IsToolBarVisible(IDR_TRANSFER_TOOLBAR));
}
/**************************************************************************\
* CWIATestView::OnPlayaudioButton()
*
* Plays .WAV data from an item that supports audio
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnPlayaudioButton()
{
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL){
IWiaPropertyStorage *pIWiaPropStg;
PROPSPEC PropSpec[1];
PROPVARIANT PropVar[1];
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = WIA_IPC_AUDIO_DATA;
memset(PropVar, 0, sizeof(PropVar));
HRESULT hResult = S_OK;
hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
if (hResult == S_OK) {
hResult = pIWiaPropStg->ReadMultiple(1, PropSpec, PropVar);
if(hResult == S_OK){
DWORD dwAudioSize = PropVar->caub.cElems;
BYTE* pAudioData = PropVar->caub.pElems;
if(pAudioData != NULL){
CFile AudioFile;
//
// open & write audio file
//
AudioFile.Open(m_AudioFileName,CFile::modeCreate|CFile::modeWrite,NULL);
AudioFile.Write(pAudioData,dwAudioSize);
AudioFile.Close();
PlaySound(m_AudioFileName,NULL,SND_FILENAME);
DeleteFile(m_AudioFileName);
}
}
else
StressStatus("* ReadMultiple(WIA_IPC_AUDIO_DATA) Failed",hResult);
}
}
}
/**************************************************************************\
* CWIATestView::ItemHasAudio()
*
* Determines if an item supports audio data, or contains data to be accessed.
*
*
* Arguments:
*
* pIWiaData - Target item to check for audio data
*
* Return Value:
*
* status
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
BOOL CWIATestView::ItemHasAudio(IWiaItem* pIWiaItem)
{
long lVal = 0;
if (pIWiaItem != NULL) {
IWiaPropertyStorage *pIWiaPropStg;
HRESULT hResult = S_OK;
hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
if (hResult == S_OK) {
//
// read Item's Audio flag
//
hResult = ReadPropLong(WIA_IPC_AUDIO_AVAILABLE, pIWiaPropStg, &lVal);
if (hResult != S_OK){
if(hResult != S_FALSE){
StressStatus("* ReadPropLong(WIA_IPC_AUDIO_AVAILABLE) Failed",hResult);
}
pIWiaPropStg->Release();
}
else
pIWiaPropStg->Release();
if(lVal)
return TRUE;
else
return FALSE;
}
}
return FALSE;
}
/**************************************************************************\
* CWIATestView::RefreshDeviceList()
*
* Called externally to force a reenumeration of WIA devices on the system
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::RefreshDeviceList()
{
m_WIA.EnumerateAllWIADevices();
}
/**************************************************************************\
* CWIATestView::OnGetrootitemtest()
*
* Gets the selected item, and gets the root item from it.
* Driver and application item information are dumped.
* DEBUGGING ONLY
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnGetrootitemtest()
{
HRESULT hr = S_OK;
IWiaItem* pIWiaItem = NULL;
IWiaItem* pNewRootItem = NULL;
pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hr = pIWiaItem->GetRootItem(&pNewRootItem);
if(hr == S_OK){
CItemInfoDlg ItemInfoDlg;
ItemInfoDlg.Initialize(pNewRootItem,TRUE);
ItemInfoDlg.DoModal();
CItemInfoDlg ItemInfoDlg2;
ItemInfoDlg2.Initialize(pNewRootItem,FALSE);
ItemInfoDlg2.DoModal();
pNewRootItem->Release();
}
}
}
/**************************************************************************\
* CWIATestView::OnReenumitems()
*
* Force a rennumeration of all child items, preserving the ROOT item
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnReenumitems()
{
HRESULT hResult = S_OK;
if (SUCCEEDED(m_WIA.ReEnumerateItems())){
if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
StressStatus("* BuildItemTree Failed");
else{
OnSelchangeTymedCombobox();
m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
}
}else{
m_ItemPropertyListControl.DeleteAllItems();
m_ItemTree.DeleteAllItems();
}
}
/**************************************************************************\
* CWIATestView::OnSavepropstream()
*
* Writes the currently selected item's property stream to a data file
* "propstrm.wia"
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnSavepropstream()
{
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.SavePropStreamToFile("propstrm.wia", pIWiaItem);
if (SUCCEEDED(hResult))
StressStatus("Stream was saved successfully...");
else
StressStatus("* Stream Failed to be saved...",hResult);
}
else
StressStatus("* Target Item is NULL");
}
/**************************************************************************\
* CWIATestView::OnLoadpropstream()
*
* Reads a previously saved property stream file, and creates a property
* stream. This stream is then set to the currently selected item.
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnLoadpropstream()
{
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.ReadPropStreamFromFile("propstrm.wia", pIWiaItem);
if (SUCCEEDED(hResult))
StressStatus("Stream was restored successfully...");
else
StressStatus("* Stream Failed to be saved...",hResult);
}
else
StressStatus("* Target Item is NULL");
//
// Refresh property display
//
OnRefresh();
}
/**************************************************************************\
* CWIATestView::OnGetSetPropstreamTest()
*
* Gets a property stream from the currently selected item, and then
* Sets the same stream back to it.
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 2/14/1999 Original Version
*
\**************************************************************************/
void CWIATestView::OnGetSetPropstreamTest()
{
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.GetSetPropStreamTest(pIWiaItem);
if (SUCCEEDED(hResult))
StressStatus("GET / SET Test was successful ");
else
StressStatus("* GET / SET Test Failed...",hResult);
}
else
StressStatus("* Target Item is NULL");
//
// Refresh property display
//
OnRefresh();
}
/**************************************************************************\
* CWIATestView::OnAnalyzeItem()
*
* Runs the AnalyzeItem method of the currently selected item.
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 01/13/2000 Original Version
*
\**************************************************************************/
void CWIATestView::OnAnalyzeItem()
{
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.AnalyzeItem(pIWiaItem);
if (SUCCEEDED(hResult)) {
StressStatus("AnalyzeItem run successfully...");
OnReenumitems();
}
else
StressStatus("* AnalyzeItem failed...",hResult);
}
else
StressStatus("* Target Item is NULL");
}
/**************************************************************************\
* CWIATestView::OnCreateChildItem()
*
* Runs the AnalyzeItem method of the currently selected item.
*
*
* Arguments:
*
* none
*
* Return Value:
*
* void
*
* History:
*
* 01/13/2000 Original Version
*
\**************************************************************************/
void CWIATestView::OnCreateChildItem()
{
HRESULT hResult = S_OK;
IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
hResult = m_WIA.CreateChildItem(pIWiaItem);
if (SUCCEEDED(hResult)) {
StressStatus("Successfully created a new child item...");
OnReenumitems();
}
else
StressStatus("* CreateChildItem failed...",hResult);
}
else
StressStatus("* Target Item is NULL");
}
| [
"[email protected]"
] | |
fe62bf9849b2aac0d8006f61986cb535a6823e8b | 6c84f333385d1c9635562d8926da7bf81880d35c | /task1/itoBase.cpp | ea7b61443a3b595275192a98eb82242fe1adbf81 | [] | no_license | ergmyth/internship_tests_1 | 3d2cbba7d87319964c85c6752cb1ee6cad4a187f | 1a27a8929ddc6ef9d1ce6a6ff7d1c0e3f5fceb5f | refs/heads/master | 2021-01-04T21:22:35.235348 | 2020-02-15T18:31:59 | 2020-02-15T18:31:59 | 240,764,224 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,092 | cpp | //
// Created by Earl Leonarda on 14/02/2020.
//
#include "task1.hpp"
static size_t char2nb(unsigned char chr, string baseSrc, int baseSrc_len)
{
for (int i = 0; i < baseSrc_len; i++)
if (baseSrc[i] == chr)
return (i);
}
static size_t string2nb(string nb, string baseSrc, int baseSrc_len)
{
int step;
int str_len;
size_t res;
step = 0;
str_len = nb.length();
res = 0;
while (--str_len > -1)
res += char2nb(nb[str_len], baseSrc, baseSrc_len) * pow(baseSrc_len, step++);
return (res);
}
static string ft_itoa(size_t nb, string baseDst)
{
string res;
int baseDst_int;
int res_len;
size_t temp;
res_len = 1;
temp = nb;
baseDst_int = baseDst.length();
while (temp /= baseDst_int)
res_len++;
res[--res_len] = baseDst[nb % baseDst_int];
while (nb /= baseDst_int)
res[--res_len] = baseDst[nb % baseDst_int];
return (res);
}
string itoBase(string nb, string baseSrc, string baseDst)
{
size_t baseSrc_len;
string str;
size_t dec;
baseSrc_len = baseSrc.length();
dec = string2nb(nb, baseSrc, baseSrc_len);
str = ft_itoa(dec, baseDst);
return (str);
}
| [
"[email protected]"
] | |
4a6c3e5e8bc5dcadc75ab2e29773327b72312a8c | 2afd103f20d8118fe595f5f6ba2f891e3cf92644 | /comp/cpp_lab/pro1.cpp | 37eb9d23a843f6fe75d8397069563ba2f17b6f92 | [] | no_license | hoihoilee/Class-homeworks | c9e7d628ee3fecaad980cdfcc9c0b09a8353a493 | f3656c5ac1ef107b8668f294165cc7498b556c6d | refs/heads/master | 2020-04-14T11:43:51.320262 | 2019-10-28T12:36:56 | 2019-10-28T12:36:56 | 163,821,767 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | cpp | #include "std_lab_facilities.h"
int print_array(int n[]);
int sort(int n[]);
int main()
{
int n[10];
int i;
for (i = 0; i < 10; i++)
cin >> n[i];
print_array(n);
sort(n);
print_array(n);
return 0;
}
int print_array(int n[])
{
int i;
for (i = 0; i < 10; i++)
cout << n[i] << " " ;
cout << endl;
}
int sort(int n[])
{
int i, j, tmp;
for (i = 0; i < 10; i++)
{
for (j = 0; j < 9 - i; j++)
{
if (n[j] > n[j+1])
{
tmp = n[j];
n[j] = n[j+1];
n[j+1] = tmp;
}
}
}
}
| [
"[email protected]"
] | |
a10dc998dcb37c8934dd30430c5de47173240050 | 32d6248bed5ada969816927b28c166128bfe236f | /Prb_1151.cpp | 5ff0fbd3ffab12fedc5ca8f16d264773093160d5 | [] | no_license | Junaeid18/Uri | a02efa101a1388d9bd811b2f79fb4aaead5477ac | ee08f2cd583605c6e4a2ea8953d94890ced0ea36 | refs/heads/master | 2022-05-17T07:18:32.314497 | 2022-03-24T21:39:13 | 2022-03-24T21:39:13 | 200,537,507 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 290 | cpp | #include <iostream>
using namespace std;
int main()
{
int n,start {0},one {0},two {1},sum;
cin>>n;
cout<<0;
while (start < n-1)
{
cout<<" "<<two;
sum = one+two;
one = two;
two = sum;
++start;
}
cout<<endl;
return 0;
} | [
"[email protected]"
] | |
14731d4f529b4cbdd3b54d315ce583c68e924870 | 8f9cc916fb6dedfc3066beb60d6f0b3172df1373 | /puerta.ino | 2414f4149f88fbb2df2cdc1858b9be700446fd24 | [
"MIT"
] | permissive | CristobalNyram/puertaArduino | 9eca567868e4ca17ac9f705696ecc33ed4c5af69 | af04becc2f8d0a7c77e812ca232cb0d9034ad5ca | refs/heads/master | 2023-01-27T14:12:07.111653 | 2020-12-11T03:01:49 | 2020-12-11T03:01:49 | 320,451,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,157 | ino |
#include <Keypad.h> // importa libreria Keypad
#include <Servo.h>
Servo myservo; // crea el objeto servo
const byte FILAS = 4; // define numero de filas
const byte COLUMNAS = 4; // define numero de columnas
char keys[FILAS][COLUMNAS] = { // define la distribucion de teclas
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte pinesFilas[FILAS] = {12, 11, 10, 9}; // pines correspondientes a las filas
byte pinesColumnas[COLUMNAS] = {8, 7, 6, 5}; // pines correspondientes a las columnas
int ledRojo = 13;//declaramos el led que enceremos
Keypad teclado = Keypad(makeKeymap(keys), pinesFilas, pinesColumnas, FILAS, COLUMNAS); // crea objeto
char TECLA; // almacena la tecla presionada
char CLAVE[7]; // almacena en un array 6 digitos ingresados
char CLAVE_MAESTRA[7] = "123456"; // almacena en un array la contraseña maestra
byte INDICE = 0; // indice del array
void setup()
{
Serial.begin(9600); // inicializa comunicacion serie
pinMode(ledRojo, OUTPUT);
myservo.attach(0); // vincula el servo al pin digital 0
mysero.write(0);//incializamos en 0 angulos
}
void loop() {
TECLA = teclado.getKey(); // obtiene tecla presionada y asigna a variable
if (TECLA) // comprueba que se haya presionado una tecla
{
CLAVE[INDICE] = TECLA; // almacena en array la tecla presionada
INDICE++; // incrementa indice en uno
Serial.print(TECLA); // envia a monitor serial la tecla presionada
}
if (INDICE == 6) // si ya se almacenaron los 6 digitos
{
if (!strcmp(CLAVE, CLAVE_MAESTRA)) { // compara clave ingresada con clave maestra
Serial.println(" Correcta"); // imprime en monitor serial que es correcta la clave
digitalWrite(ledRojo, HIGH);
myservo.write(50); // ubica el servo a 50 grados(abrimos la puerta
delay(10000);
}
else {
Serial.println(" Incorrecta"); // imprime en monitor serial que es incorrecta la clave
}
INDICE = 0;
digitalWrite(ledRojo, LOW);//apagamos nuestro foco/led
myservo.write(0); //cerramos la puerta/
}
}
| [
"[email protected]"
] | |
f80e0dedf1dc7ae16acc6d6e0f02ca597ac0392b | 59c47e1f8b2738fc2b824462e31c1c713b0bdcd7 | /002-Qt_widget_Concerning/000-Qt-widget-project/WindowsAPP/BST_IDE/mdp/physical/physicalcpu.h | d6a259592475f399a62036a6bb5386c3c344b742 | [] | no_license | casterbn/Qt_project | 8efcc46e75e2bbe03dc4aeaafeb9e175fb7b04ab | 03115674eb3612e9dc65d4fd7bcbca9ba27f691c | refs/heads/master | 2021-10-19T07:27:24.550519 | 2019-02-19T05:26:22 | 2019-02-19T05:26:22 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 839 | h | #ifndef PHYSICALCPU_H
#define PHYSICALCPU_H
#include "physicalbase.h"
class PhysicalCPU : public PhysicalDevice
{
Q_OBJECT
public:
PhysicalCPU(QObject *parent = 0);
~PhysicalCPU();
quint32 InitPara();
QString GetInformation() { return QString("%1>%2 %3%").arg(mDevName).arg(mCpuModel).arg(mUsageRate); }
bool GotoIdel();
bool LeaveIdel();
quint32 Monitor(quint32 pCount);
public slots:
void UpdatePara(QObject* pObject);
public:
QString mCpuModel;
QString mUsbScanPath; //>@USB设备扫描目录,用于开机首次扫描已存在的USB设备
bool mAutoRelease;
NUM_INFO mThreshold;
int mUsageRate;
QFile *m_File;
bool mIsIdelState;
};
#endif // PHYSICALCPU_H
| [
"[email protected]"
] | |
89187ef3403d70fdc9718777ac197b259eab6521 | 6044ea7e01287cae22d9fa6cf6e0dc7f8ffd5943 | /IntersectionOfTwoLinkedLists.cpp | 9e08a0917f17d1e24d4b245167904a0867dd360d | [] | no_license | woods-jiang/leetcode | fbe271dd6a444736d8ab8beb06dfb52e337443e6 | f136e44ebb3f294d547d419e4b38d6eb06805a21 | refs/heads/master | 2020-05-20T06:03:39.040066 | 2015-08-05T23:31:51 | 2015-08-05T23:31:51 | 33,391,497 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 980 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
int lenghA=0;
int lenghB=0;
ListNode* pA = headA;
ListNode* pB = headB;
if (NULL == pA || NULL == pB)
{
return NULL;
}
while (NULL != pA)
{
lenghA += 1;
pA = pA->next;
}
while (NULL != pB)
{
lenghB += 1;
pB = pB->next;
}
pA = headA;
pB = headB;
if (lenghA > lenghB)
{
for (int i = lenghA - lenghB; i > 0; i--)
pA = pA->next;
}
else
{
for (int i = lenghB - lenghA; i > 0; i--)
pB = pB->next;
}
while (NULL != pA && NULL != pB)
{
if (pA->val == pB->val)
return pA;
pA = pA->next;
pB = pB->next;
}
return NULL;
}
};
| [
"[email protected]"
] | |
757ea438feaa5c4b01822b06a869c409e90adaea | 95a0bb23a05a96b9ef01f88dcc35c2bdaa7f2f14 | /1.9.1.12285/SDK/TDMFlag_classes.h | cdacaf6dc81a049d9801a6a029f90efe3202159e | [] | no_license | MuhanjalaRE/Midair-Community-Edition-SDKs | 38ccb53898cf22669d99724e7246eb543ae2d25d | 8f459da568912b3d737d6494db003537af45bf85 | refs/heads/main | 2023-04-06T03:49:42.732247 | 2021-04-14T11:35:28 | 2021-04-14T11:35:28 | 334,685,504 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,190 | h | #pragma once
// Name: mace, Version: 1.9.1.12285
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass TDMFlag.TDMFlag_C
// 0x0028 (FullSize[0x0518] - InheritedSize[0x04F0])
class ATDMFlag_C : public ATDMFlag
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x04F0(0x0008) (ZeroConstructor, Transient, DuplicateTransient)
class UParticleSystemComponent* P_FlagTrail; // 0x04F8(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash)
class UAudioComponent* IdleLoopSound; // 0x0500(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash)
unsigned char Team_Id; // 0x0508(0x0001) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
unsigned char UnknownData_1WA7[0x7]; // 0x0509(0x0007) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY)
class UMaterialInstanceDynamic* NewVar_1; // 0x0510(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
static UClass* StaticClass()
{
static UClass* ptr = nullptr;
if(!ptr){
ptr = UObject::FindClass("BlueprintGeneratedClass TDMFlag.TDMFlag_C");
}
return ptr;
}
void UserConstructionScript();
void ReceiveTick(float DeltaSeconds);
void ExecuteUbergraph_TDMFlag(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"[email protected]"
] | |
6d52e95df6f83236f61c09a045b423b6f0246d78 | d35a26e8957f737d6f96eafd58d7c07eac55e579 | /vector.cpp | 893fc04a14a0bd36b0b08a889f7ef886b14b9b4a | [] | no_license | Autonomous-Wang/Leetcode | 7d1e24976801a4f361b799e0e8e66aaa48c83575 | a68bc9d0395f66d5152c0d12b2366ff3e932a5f5 | refs/heads/master | 2021-06-14T15:31:17.210216 | 2017-04-06T20:22:07 | 2017-04-06T20:22:07 | 82,267,997 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,072 | cpp | #include <iostream>
#include <vector>
using namespace std;
void printvec(vector<int> &vec)
{
for (size_t i = 0; i < vec.size(); i++)
{
cout << "Vec[" << i << "] = " << vec[i] << endl;
}
}
void iterprint(vector<int> vec)
{
vector<int> :: iterator Iter;
for (Iter = vec.begin(); Iter != vec.end(); Iter++)
{
cout << *Iter << ' ';
}
cout << endl;
}
vector<int> removeElement(vector<int>& nums, int val)
{
vector<int> num(0);
for (int i = 0; i < nums.size(); i++)
{
if (nums[i] != val)
{
num.push_back(nums[i]);
}
}
return num;
}
int main()
{
const int size = 10;
vector<int> vec(size);
//cout << vec.size() << endl;
vector<int> :: iterator Iter;
Iter = vec.begin();
for (int i = 0; i < size; i++)
{
*Iter = i;
Iter++;
}
//iterprint(vec);
//vec.pop_back();
//vec.erase(vec.begin(), vec.begin() + 2);
//iter(vec);
vector<int> vecc;
vecc.push_back(3);
vecc.push_back(2);
vecc.push_back(2);
vecc.push_back(3);
iterprint(vecc);
vector<int> s;
s = removeElement(vecc, 3);
iterprint(s);
cout << s.size() <<endl;
} | [
"[email protected]"
] | |
0763166118b92742bf36e137d89c16af1c1e8b8f | ab786509980b232c973be7c042d9996dfd097601 | /ext/tgaimage.h | 929a9f258763604f670a9521ce225cdbb9c5f652 | [] | no_license | cdgiessen/TinyRenderer | 2c2d691695abf32c86f646147afa713e4099ac8a | f1f2c0bc90327f12e2fb738d6178e5b7b09ec088 | refs/heads/master | 2023-02-03T21:13:39.587670 | 2020-12-17T18:08:45 | 2020-12-17T18:08:45 | 310,068,160 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,331 | h | #pragma once
#include <cstdint>
#include <fstream>
#include <vector>
#pragma pack(push, 1)
struct TGA_Header
{
std::uint8_t idlength{};
std::uint8_t colormaptype{};
std::uint8_t datatypecode{};
std::uint16_t colormaporigin{};
std::uint16_t colormaplength{};
std::uint8_t colormapdepth{};
std::uint16_t x_origin{};
std::uint16_t y_origin{};
std::uint16_t width{};
std::uint16_t height{};
std::uint8_t bitsperpixel{};
std::uint8_t imagedescriptor{};
};
#pragma pack(pop)
struct TGAColor
{
std::uint8_t bgra[4] = {0, 0, 0, 0};
std::uint8_t bytespp = {0};
TGAColor() = default;
TGAColor(const std::uint8_t R, const std::uint8_t G, const std::uint8_t B,
const std::uint8_t A = 255)
: bgra{B, G, R, A}, bytespp(4)
{}
TGAColor(const std::uint8_t v) : bgra{v, 0, 0, 0}, bytespp(1) {}
TGAColor(const std::uint8_t *p, const std::uint8_t bpp) : bgra{0, 0, 0, 0}, bytespp(bpp)
{
for (size_t i = 0; i < bpp; i++) bgra[i] = p[i];
}
std::uint8_t &operator[](const size_t i) { return bgra[i]; }
TGAColor operator*(const double intensity) const
{
TGAColor res = *this;
double clamped = std::max(0., std::min(intensity, 1.));
for (size_t i = 0; i < 4; i++) res.bgra[i] = static_cast<uint8_t>(bgra[i] * clamped);
return res;
}
};
class TGAImage
{
protected:
std::vector<std::uint8_t> data;
uint32_t width{};
uint32_t height{};
uint32_t bytespp{};
bool load_rle_data(std::ifstream &in);
bool unload_rle_data(std::ofstream &out) const;
public:
enum Format
{
GRAYSCALE = 1,
RGB = 3,
RGBA = 4
};
TGAImage();
TGAImage(const size_t w, const size_t h, const size_t bpp);
bool read_tga_file(const std::string filename);
bool write_tga_file(const std::string filename, const bool v_flip = true,
const bool rle = true) const;
void flip_horizontally();
void flip_vertically();
void scale(const size_t w, const size_t h);
TGAColor get(const size_t x, const size_t y) const;
void set(const size_t x, const size_t y, const TGAColor &c);
size_t get_width() const;
size_t get_height() const;
size_t get_bytespp();
std::uint8_t *buffer();
void clear();
};
| [
"[email protected]"
] | |
475dda9e04269cc5e3994ba293d3ab8be3a4375a | c7a16a52129faceb90fac1e10b4438ee3d28d225 | /components/pdf/browser/pdf_navigation_throttle.cc | 0c52251976a898a9e9a84a7dfa2ef51bade596e0 | [
"BSD-3-Clause"
] | permissive | OxingchenO/chromium | 0159fbd6cf90e225c4375f9bbd5883cb3cfaef34 | 3c6e1f5fb4f8bc50b60b97861be570b84e32544e | refs/heads/master | 2023-05-15T01:20:02.591938 | 2021-06-22T10:02:23 | 2021-06-22T10:02:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,282 | cc | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/pdf/browser/pdf_navigation_throttle.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/common/constants.h"
#include "pdf/pdf_features.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
namespace pdf {
namespace {
// Used to scope the posted navigation task to the lifetime of `web_contents_`.
//
// Could use `WebContents::FromFrameTreeNodeId()` instead, but this doesn't work
// with a `MockNavigationHandle`.
class WebContentsLifetimeHelper
: public content::WebContentsUserData<WebContentsLifetimeHelper> {
public:
base::WeakPtr<WebContentsLifetimeHelper> GetWeakPtr() const {
return weak_factory_.GetWeakPtr();
}
void OpenUrl(const content::OpenURLParams& params) {
// `MimeHandlerViewGuest` navigates its embedder for calls to
// `WebContents::OpenURL()`, so use `LoadURLWithParams()` directly instead.
web_contents_->GetController().LoadURLWithParams(
content::NavigationController::LoadURLParams(params));
}
private:
friend class content::WebContentsUserData<WebContentsLifetimeHelper>;
WEB_CONTENTS_USER_DATA_KEY_DECL();
explicit WebContentsLifetimeHelper(content::WebContents* web_contents)
: web_contents_(web_contents) {}
content::WebContents* web_contents_;
base::WeakPtrFactory<WebContentsLifetimeHelper> weak_factory_{this};
};
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsLifetimeHelper)
} // namespace
// static
std::unique_ptr<content::NavigationThrottle>
PdfNavigationThrottle::MaybeCreateThrottleFor(
content::NavigationHandle* navigation_handle) {
if (!base::FeatureList::IsEnabled(chrome_pdf::features::kPdfUnseasoned))
return nullptr;
if (navigation_handle->IsInMainFrame())
return nullptr;
return std::make_unique<PdfNavigationThrottle>(navigation_handle);
}
PdfNavigationThrottle::PdfNavigationThrottle(
content::NavigationHandle* navigation_handle)
: content::NavigationThrottle(navigation_handle) {}
PdfNavigationThrottle::~PdfNavigationThrottle() = default;
const char* PdfNavigationThrottle::GetNameForLogging() {
return "PdfNavigationThrottle";
}
content::NavigationThrottle::ThrottleCheckResult
PdfNavigationThrottle::WillStartRequest() {
// Quickly ignore URLs that do not look like stream URLs. The path check does
// not need to be precise, it just needs to not match any legitimate PDF
// extension URL. We'll assume such URLs contain multiple path components, or
// a file extension.
const GURL& url = navigation_handle()->GetURL();
if (!url.SchemeIs(extensions::kExtensionScheme) ||
url.host_piece() != extension_misc::kPdfExtensionId ||
url.path_piece().find_last_of("/.") != 0) {
return PROCEED;
}
// TODO(crbug.com/1123621): Enqueue navigation to stream's original URL.
content::OpenURLParams params =
content::OpenURLParams::FromNavigationHandle(navigation_handle());
params.url = GURL("chrome://about");
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
// Uses same pattern as `PDFIFrameNavigationThrottle` to redirect navigation.
content::WebContents* web_contents = navigation_handle()->GetWebContents();
if (!web_contents)
return CANCEL_AND_IGNORE;
WebContentsLifetimeHelper::CreateForWebContents(web_contents);
WebContentsLifetimeHelper* helper =
WebContentsLifetimeHelper::FromWebContents(web_contents);
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&WebContentsLifetimeHelper::OpenUrl,
helper->GetWeakPtr(), std::move(params)));
return CANCEL_AND_IGNORE;
}
} // namespace pdf
| [
"[email protected]"
] | |
573afa29e13a8290c35a40a707758f24bfdae40e | bb16db1f002eb4b745e46cf957a8c44bfc25cc71 | /k1160pro/HNWidgets/hnwifiwidget.cpp | 6ceef989b66f8837ab4b867b5961975058f725cb | [] | no_license | jjzhang166/K1160 | 90ded5beae07f2e320f1453aaa93fbd529b00409 | fb9716bb7bead7b38df54b7b17925822bbbe1691 | refs/heads/master | 2021-07-05T05:26:39.774344 | 2017-09-26T09:37:15 | 2017-09-26T09:37:15 | 104,993,094 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,690 | cpp | #include "hnwifiwidget.h"
#include "ui_hnwifiwidget.h"
#include "hnlinux.h"
#include "HNDefine.h"
#include "HNDefine.h"
#include "hnmsgbox.h"
HNWIFIWidget::HNWIFIWidget(QWidget *parent) :
HNWIFIView(parent),
ui(new Ui::HNWIFIWidget)
{
ui->setupUi(this);
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(clickWIFI()), Qt::QueuedConnection);
m_pass = new HNPasswordDialog(this);
m_model = new HNWIFIModel(this);
setModel(m_model);
for(int i = ESSID_TYPE; i < ESSID_MAX; i++)
setColumnHidden(i, true);
horizontalHeader()->setResizeMode(0, QHeaderView::Fixed);
setColumnWidth(ESSID_STATUS, 40);
}
HNWIFIWidget::~HNWIFIWidget()
{
delete ui;
}
void HNWIFIWidget::clickWIFI()
{
QString name = m_model->data(m_model->index(currentIndex().row(), ESSID_NAME)).toString();
QString encryt = m_model->data(m_model->index(currentIndex().row(), ESSID_ENCRYP)).toString();
QString type = m_model->data(m_model->index(currentIndex().row(), ESSID_TYPE)).toString();
QString mac = m_model->data(m_model->index(currentIndex().row(), ESSID_BSSID)).toString();
HNEthManager::Instance()->setRefresh(false);
do
{
if("YES" == encryt)
{
m_pass->setWifiName(name);
if(HNPasswordDialog::Rejected == m_pass->exec())
break;
}
bool ok = m_model->setCurrentWifi(mac, m_pass->wifiPwd());
pline() << ok;
if(!ok)
{
HNMsgBox::warning(this, tr("Password error"));
break;
}
pline() << name << encryt << m_pass->wifiPwd();
}while(0);
HNEthManager::Instance()->setRefresh();
}
| [
"[email protected]"
] | |
3fc5d1450121b45d6ecf79e535886365ff06a4b1 | fa7a76c7646ced5f8ffbd009d4a21f05e187495a | /UVA Problems/UVA/UVA/Sort! Sort!! and Sort!!!.cpp | 22cd4fd62c1e7666cfb875b58cac64f22ccd8c5c | [] | no_license | osama-afifi/Online-Judges-Solutions | 5273018f8373f377b9dafa85521c97beaa6574a0 | f49130f8ccbe8abc062f1b51a204edb819699b3a | refs/heads/master | 2021-01-10T19:54:34.488053 | 2015-04-23T21:42:54 | 2015-04-23T21:42:54 | 21,754,051 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 912 | cpp | # include <iostream>
# include <math.h>
# include <iomanip>
# include <string>
# include <map>
# include <set>
# include <vector>
# include <algorithm>
using namespace std;
struct NO
{
long long num;
int type;
long long mod;
bool operator <(const NO &a)const
{
if(mod!=a.mod)
return mod<a.mod;
if(type!=a.type)
return type>a.type;
if(a.type==1 &&type==1)
return num>a.num;
else
return num<a.num;
};
};
int main()
{
freopen("input.in","r",stdin);
long long N;
long long M;
while(cin>>N>>M)
{
cout<<N<<" "<<M<<endl;
if(M==0 && N==0)break;
vector<NO> vec;
long long no;
for(int i=0;i<N;i++)
{
cin>>no;
NO temp;
temp.num=no;
temp.type=abs(no%2);
temp.mod=no%M;
vec.push_back(temp);
}
sort(vec.begin(),vec.end());
vector<NO> ::iterator it;
for(it=vec.begin();it!=vec.end();it++)
{
cout<<(*it).num<<endl;
}
}
return 0;
} | [
"[email protected]"
] | |
902c9cd942f6ada774470d9578cb2701b4392923 | c915814daef48722a27db20312e8aba72d08588e | /external/lodepng/lodepng.cpp | cbfd08e212e3c19bdff93207aa0c9b2024e3d81a | [] | no_license | jmrico01/opengl | 9ce27255dc57eea425ec8b25a9a7f0ada8fd749a | e2e59ae08b032a156c835e7d079292b641b1514c | refs/heads/master | 2021-04-03T01:46:14.417740 | 2018-03-14T03:25:05 | 2018-03-14T03:25:05 | 124,464,446 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 220,992 | cpp | /*
LodePNG version 20170917
Copyright (c) 2005-2017 Lode Vandevenne
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/*
The manual and changelog are in the header file "lodepng.h"
Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.
*/
#include "lodepng.h"
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Jose says: fuck you.
//#if defined(_MSC_VER) && (_MSC_VER >= 1310) /*Visual Studio: A few warning types are not desired here.*/
//#pragma warning( disable : 4244 ) /*implicit conversions: not warned by gcc -Wall -Wextra and requires too much casts*/
//#pragma warning( disable : 4996 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/
//#endif /*_MSC_VER */
const char* LODEPNG_VERSION_STRING = "20170917";
/*
This source file is built up in the following large parts. The code sections
with the "LODEPNG_COMPILE_" #defines divide this up further in an intermixed way.
-Tools for C and common code for PNG and Zlib
-C Code for Zlib (huffman, deflate, ...)
-C Code for PNG (file format chunks, adam7, PNG filters, color conversions, ...)
-The C++ wrapper around all of the above
*/
/*The malloc, realloc and free functions defined here with "lodepng_" in front
of the name, so that you can easily change them to others related to your
platform if needed. Everything else in the code calls these. Pass
-DLODEPNG_NO_COMPILE_ALLOCATORS to the compiler, or comment out
#define LODEPNG_COMPILE_ALLOCATORS in the header, to disable the ones here and
define them in your own project's source files without needing to change
lodepng source code. Don't forget to remove "static" if you copypaste them
from here.*/
#ifdef LODEPNG_COMPILE_ALLOCATORS
static void* lodepng_malloc(size_t size)
{
return malloc(size);
}
static void* lodepng_realloc(void* ptr, size_t new_size)
{
return realloc(ptr, new_size);
}
static void lodepng_free(void* ptr)
{
free(ptr);
}
#else /*LODEPNG_COMPILE_ALLOCATORS*/
void* lodepng_malloc(size_t size);
void* lodepng_realloc(void* ptr, size_t new_size);
void lodepng_free(void* ptr);
#endif /*LODEPNG_COMPILE_ALLOCATORS*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // Tools for C, and common code for PNG and Zlib. // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/*
Often in case of an error a value is assigned to a variable and then it breaks
out of a loop (to go to the cleanup phase of a function). This macro does that.
It makes the error handling code shorter and more readable.
Example: if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83);
*/
#define CERROR_BREAK(errorvar, code)\
{\
errorvar = code;\
break;\
}
/*version of CERROR_BREAK that assumes the common case where the error variable is named "error"*/
#define ERROR_BREAK(code) CERROR_BREAK(error, code)
/*Set error var to the error code, and return it.*/
#define CERROR_RETURN_ERROR(errorvar, code)\
{\
errorvar = code;\
return code;\
}
/*Try the code, if it returns error, also return the error.*/
#define CERROR_TRY_RETURN(call)\
{\
unsigned error = call;\
if(error) return error;\
}
/*Set error var to the error code, and return from the void function.*/
#define CERROR_RETURN(errorvar, code)\
{\
errorvar = code;\
return;\
}
/*
About uivector, ucvector and string:
-All of them wrap dynamic arrays or text strings in a similar way.
-LodePNG was originally written in C++. The vectors replace the std::vectors that were used in the C++ version.
-The string tools are made to avoid problems with compilers that declare things like strncat as deprecated.
-They're not used in the interface, only internally in this file as static functions.
-As with many other structs in this file, the init and cleanup functions serve as ctor and dtor.
*/
#ifdef LODEPNG_COMPILE_ZLIB
/*dynamic vector of unsigned ints*/
typedef struct uivector
{
unsigned* data;
size_t size; /*size in number of unsigned longs*/
size_t allocsize; /*allocated size in bytes*/
} uivector;
static void uivector_cleanup(void* p)
{
((uivector*)p)->size = ((uivector*)p)->allocsize = 0;
lodepng_free(((uivector*)p)->data);
((uivector*)p)->data = NULL;
}
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_reserve(uivector* p, size_t allocsize)
{
if(allocsize > p->allocsize)
{
size_t newsize = (allocsize > p->allocsize * 2) ? allocsize : (allocsize * 3 / 2);
void* data = lodepng_realloc(p->data, newsize);
if(data)
{
p->allocsize = newsize;
p->data = (unsigned*)data;
}
else return 0; /*error: not enough memory*/
}
return 1;
}
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_resize(uivector* p, size_t size)
{
if(!uivector_reserve(p, size * sizeof(unsigned))) return 0;
p->size = size;
return 1; /*success*/
}
/*resize and give all new elements the value*/
static unsigned uivector_resizev(uivector* p, size_t size, unsigned value)
{
size_t oldsize = p->size, i;
if(!uivector_resize(p, size)) return 0;
for(i = oldsize; i < size; ++i) p->data[i] = value;
return 1;
}
static void uivector_init(uivector* p)
{
p->data = NULL;
p->size = p->allocsize = 0;
}
#ifdef LODEPNG_COMPILE_ENCODER
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned uivector_push_back(uivector* p, unsigned c)
{
if(!uivector_resize(p, p->size + 1)) return 0;
p->data[p->size - 1] = c;
return 1;
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_ZLIB*/
/* /////////////////////////////////////////////////////////////////////////// */
/*dynamic vector of unsigned chars*/
typedef struct ucvector
{
unsigned char* data;
size_t size; /*used size*/
size_t allocsize; /*allocated size*/
} ucvector;
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned ucvector_reserve(ucvector* p, size_t allocsize)
{
if(allocsize > p->allocsize)
{
size_t newsize = (allocsize > p->allocsize * 2) ? allocsize : (allocsize * 3 / 2);
void* data = lodepng_realloc(p->data, newsize);
if(data)
{
p->allocsize = newsize;
p->data = (unsigned char*)data;
}
else return 0; /*error: not enough memory*/
}
return 1;
}
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned ucvector_resize(ucvector* p, size_t size)
{
if(!ucvector_reserve(p, size * sizeof(unsigned char))) return 0;
p->size = size;
return 1; /*success*/
}
#ifdef LODEPNG_COMPILE_PNG
static void ucvector_cleanup(void* p)
{
((ucvector*)p)->size = ((ucvector*)p)->allocsize = 0;
lodepng_free(((ucvector*)p)->data);
((ucvector*)p)->data = NULL;
}
static void ucvector_init(ucvector* p)
{
p->data = NULL;
p->size = p->allocsize = 0;
}
#endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ZLIB
/*you can both convert from vector to buffer&size and vica versa. If you use
init_buffer to take over a buffer and size, it is not needed to use cleanup*/
static void ucvector_init_buffer(ucvector* p, unsigned char* buffer, size_t size)
{
p->data = buffer;
p->allocsize = p->size = size;
}
#endif /*LODEPNG_COMPILE_ZLIB*/
#if (defined(LODEPNG_COMPILE_PNG) && defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)) || defined(LODEPNG_COMPILE_ENCODER)
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned ucvector_push_back(ucvector* p, unsigned char c)
{
if(!ucvector_resize(p, p->size + 1)) return 0;
p->data[p->size - 1] = c;
return 1;
}
#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_PNG
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*returns 1 if success, 0 if failure ==> nothing done*/
static unsigned string_resize(char** out, size_t size)
{
char* data = (char*)lodepng_realloc(*out, size + 1);
if(data)
{
data[size] = 0; /*null termination char*/
*out = data;
}
return data != 0;
}
/*init a {char*, size_t} pair for use as string*/
static void string_init(char** out)
{
*out = NULL;
string_resize(out, 0);
}
/*free the above pair again*/
static void string_cleanup(char** out)
{
lodepng_free(*out);
*out = NULL;
}
static void string_set(char** out, const char* in)
{
size_t i;
size_t insize = strlen(in);
if(string_resize(out, insize))
{
for(i = 0; i != insize; ++i)
{
(*out)[i] = in[i];
}
}
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
#endif /*LODEPNG_COMPILE_PNG*/
/* ////////////////////////////////////////////////////////////////////////// */
unsigned lodepng_read32bitInt(const unsigned char* buffer)
{
return (unsigned)((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]);
}
#if defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)
/*buffer must have at least 4 allocated bytes available*/
static void lodepng_set32bitInt(unsigned char* buffer, unsigned value)
{
buffer[0] = (unsigned char)((value >> 24) & 0xff);
buffer[1] = (unsigned char)((value >> 16) & 0xff);
buffer[2] = (unsigned char)((value >> 8) & 0xff);
buffer[3] = (unsigned char)((value ) & 0xff);
}
#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/
#ifdef LODEPNG_COMPILE_ENCODER
static void lodepng_add32bitInt(ucvector* buffer, unsigned value)
{
ucvector_resize(buffer, buffer->size + 4); /*todo: give error if resize failed*/
lodepng_set32bitInt(&buffer->data[buffer->size - 4], value);
}
#endif /*LODEPNG_COMPILE_ENCODER*/
/* ////////////////////////////////////////////////////////////////////////// */
/* / File IO / */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_DISK
/* returns negative value on error. This should be pure C compatible, so no fstat. */
static long lodepng_filesize(const char* filename)
{
FILE* file;
long size;
file = fopen(filename, "rb");
if(!file) return -1;
if(fseek(file, 0, SEEK_END) != 0)
{
fclose(file);
return -1;
}
size = ftell(file);
/* It may give LONG_MAX as directory size, this is invalid for us. */
if(size == LONG_MAX) size = -1;
fclose(file);
return size;
}
/* load file into buffer that already has the correct allocated size. Returns error code.*/
static unsigned lodepng_buffer_file(unsigned char* out, size_t size, const char* filename)
{
FILE* file;
size_t readsize;
file = fopen(filename, "rb");
if(!file) return 78;
readsize = fread(out, 1, size, file);
fclose(file);
if (readsize != size) return 78;
return 0;
}
unsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* filename)
{
long size = lodepng_filesize(filename);
if (size < 0) return 78;
*outsize = (size_t)size;
*out = (unsigned char*)lodepng_malloc((size_t)size);
if(!(*out) && size > 0) return 83; /*the above malloc failed*/
return lodepng_buffer_file(*out, (size_t)size, filename);
}
/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename)
{
FILE* file;
file = fopen(filename, "wb" );
if(!file) return 79;
fwrite((char*)buffer , 1 , buffersize, file);
fclose(file);
return 0;
}
#endif /*LODEPNG_COMPILE_DISK*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // End of common code and tools. Begin of Zlib related code. // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_ZLIB
#ifdef LODEPNG_COMPILE_ENCODER
/*TODO: this ignores potential out of memory errors*/
#define addBitToStream(/*size_t**/ bitpointer, /*ucvector**/ bitstream, /*unsigned char*/ bit)\
{\
/*add a new byte at the end*/\
if(((*bitpointer) & 7) == 0) ucvector_push_back(bitstream, (unsigned char)0);\
/*earlier bit of huffman code is in a lesser significant bit of an earlier byte*/\
(bitstream->data[bitstream->size - 1]) |= (bit << ((*bitpointer) & 0x7));\
++(*bitpointer);\
}
static void addBitsToStream(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)
{
size_t i;
for(i = 0; i != nbits; ++i) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> i) & 1));
}
static void addBitsToStreamReversed(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)
{
size_t i;
for(i = 0; i != nbits; ++i) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> (nbits - 1 - i)) & 1));
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_DECODER
#define READBIT(bitpointer, bitstream) ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (unsigned char)1)
static unsigned char readBitFromStream(size_t* bitpointer, const unsigned char* bitstream)
{
unsigned char result = (unsigned char)(READBIT(*bitpointer, bitstream));
++(*bitpointer);
return result;
}
static unsigned readBitsFromStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)
{
unsigned result = 0, i;
for(i = 0; i != nbits; ++i)
{
result += ((unsigned)READBIT(*bitpointer, bitstream)) << i;
++(*bitpointer);
}
return result;
}
#endif /*LODEPNG_COMPILE_DECODER*/
/* ////////////////////////////////////////////////////////////////////////// */
/* / Deflate - Huffman / */
/* ////////////////////////////////////////////////////////////////////////// */
#define FIRST_LENGTH_CODE_INDEX 257
#define LAST_LENGTH_CODE_INDEX 285
/*256 literals, the end code, some length codes, and 2 unused codes*/
#define NUM_DEFLATE_CODE_SYMBOLS 288
/*the distance codes have their own symbols, 30 used, 2 unused*/
#define NUM_DISTANCE_SYMBOLS 32
/*the code length codes. 0-15: code lengths, 16: copy previous 3-6 times, 17: 3-10 zeros, 18: 11-138 zeros*/
#define NUM_CODE_LENGTH_CODES 19
/*the base lengths represented by codes 257-285*/
static const unsigned LENGTHBASE[29]
= {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
67, 83, 99, 115, 131, 163, 195, 227, 258};
/*the extra bits used by codes 257-285 (added to base length)*/
static const unsigned LENGTHEXTRA[29]
= {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 5, 5, 5, 5, 0};
/*the base backwards distances (the bits of distance codes appear after length codes and use their own huffman tree)*/
static const unsigned DISTANCEBASE[30]
= {1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
/*the extra bits of backwards distances (added to base)*/
static const unsigned DISTANCEEXTRA[30]
= {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
/*the order in which "code length alphabet code lengths" are stored, out of this
the huffman tree of the dynamic huffman tree lengths is generated*/
static const unsigned CLCL_ORDER[NUM_CODE_LENGTH_CODES]
= {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/* ////////////////////////////////////////////////////////////////////////// */
/*
Huffman tree struct, containing multiple representations of the tree
*/
typedef struct HuffmanTree
{
unsigned* tree2d;
unsigned* tree1d;
unsigned* lengths; /*the lengths of the codes of the 1d-tree*/
unsigned maxbitlen; /*maximum number of bits a single code can get*/
unsigned numcodes; /*number of symbols in the alphabet = number of codes*/
} HuffmanTree;
/*function used for debug purposes to draw the tree in ascii art with C++*/
/*
static void HuffmanTree_draw(HuffmanTree* tree)
{
std::cout << "tree. length: " << tree->numcodes << " maxbitlen: " << tree->maxbitlen << std::endl;
for(size_t i = 0; i != tree->tree1d.size; ++i)
{
if(tree->lengths.data[i])
std::cout << i << " " << tree->tree1d.data[i] << " " << tree->lengths.data[i] << std::endl;
}
std::cout << std::endl;
}*/
static void HuffmanTree_init(HuffmanTree* tree)
{
tree->tree2d = 0;
tree->tree1d = 0;
tree->lengths = 0;
}
static void HuffmanTree_cleanup(HuffmanTree* tree)
{
lodepng_free(tree->tree2d);
lodepng_free(tree->tree1d);
lodepng_free(tree->lengths);
}
/*the tree representation used by the decoder. return value is error*/
static unsigned HuffmanTree_make2DTree(HuffmanTree* tree)
{
unsigned nodefilled = 0; /*up to which node it is filled*/
unsigned treepos = 0; /*position in the tree (1 of the numcodes columns)*/
unsigned n, i;
tree->tree2d = (unsigned*)lodepng_malloc(tree->numcodes * 2 * sizeof(unsigned));
if(!tree->tree2d) return 83; /*alloc fail*/
/*
convert tree1d[] to tree2d[][]. In the 2D array, a value of 32767 means
uninited, a value >= numcodes is an address to another bit, a value < numcodes
is a code. The 2 rows are the 2 possible bit values (0 or 1), there are as
many columns as codes - 1.
A good huffman tree has N * 2 - 1 nodes, of which N - 1 are internal nodes.
Here, the internal nodes are stored (what their 0 and 1 option point to).
There is only memory for such good tree currently, if there are more nodes
(due to too long length codes), error 55 will happen
*/
for(n = 0; n < tree->numcodes * 2; ++n)
{
tree->tree2d[n] = 32767; /*32767 here means the tree2d isn't filled there yet*/
}
for(n = 0; n < tree->numcodes; ++n) /*the codes*/
{
for(i = 0; i != tree->lengths[n]; ++i) /*the bits for this code*/
{
unsigned char bit = (unsigned char)((tree->tree1d[n] >> (tree->lengths[n] - i - 1)) & 1);
/*oversubscribed, see comment in lodepng_error_text*/
if(treepos > 2147483647 || treepos + 2 > tree->numcodes) return 55;
if(tree->tree2d[2 * treepos + bit] == 32767) /*not yet filled in*/
{
if(i + 1 == tree->lengths[n]) /*last bit*/
{
tree->tree2d[2 * treepos + bit] = n; /*put the current code in it*/
treepos = 0;
}
else
{
/*put address of the next step in here, first that address has to be found of course
(it's just nodefilled + 1)...*/
++nodefilled;
/*addresses encoded with numcodes added to it*/
tree->tree2d[2 * treepos + bit] = nodefilled + tree->numcodes;
treepos = nodefilled;
}
}
else treepos = tree->tree2d[2 * treepos + bit] - tree->numcodes;
}
}
for(n = 0; n < tree->numcodes * 2; ++n)
{
if(tree->tree2d[n] == 32767) tree->tree2d[n] = 0; /*remove possible remaining 32767's*/
}
return 0;
}
/*
Second step for the ...makeFromLengths and ...makeFromFrequencies functions.
numcodes, lengths and maxbitlen must already be filled in correctly. return
value is error.
*/
static unsigned HuffmanTree_makeFromLengths2(HuffmanTree* tree)
{
uivector blcount;
uivector nextcode;
unsigned error = 0;
unsigned bits, n;
uivector_init(&blcount);
uivector_init(&nextcode);
tree->tree1d = (unsigned*)lodepng_malloc(tree->numcodes * sizeof(unsigned));
if(!tree->tree1d) error = 83; /*alloc fail*/
if(!uivector_resizev(&blcount, tree->maxbitlen + 1, 0)
|| !uivector_resizev(&nextcode, tree->maxbitlen + 1, 0))
error = 83; /*alloc fail*/
if(!error)
{
/*step 1: count number of instances of each code length*/
for(bits = 0; bits != tree->numcodes; ++bits) ++blcount.data[tree->lengths[bits]];
/*step 2: generate the nextcode values*/
for(bits = 1; bits <= tree->maxbitlen; ++bits)
{
nextcode.data[bits] = (nextcode.data[bits - 1] + blcount.data[bits - 1]) << 1;
}
/*step 3: generate all the codes*/
for(n = 0; n != tree->numcodes; ++n)
{
if(tree->lengths[n] != 0) tree->tree1d[n] = nextcode.data[tree->lengths[n]]++;
}
}
uivector_cleanup(&blcount);
uivector_cleanup(&nextcode);
if(!error) return HuffmanTree_make2DTree(tree);
else return error;
}
/*
given the code lengths (as stored in the PNG file), generate the tree as defined
by Deflate. maxbitlen is the maximum bits that a code in the tree can have.
return value is error.
*/
static unsigned HuffmanTree_makeFromLengths(HuffmanTree* tree, const unsigned* bitlen,
size_t numcodes, unsigned maxbitlen)
{
unsigned i;
tree->lengths = (unsigned*)lodepng_malloc(numcodes * sizeof(unsigned));
if(!tree->lengths) return 83; /*alloc fail*/
for(i = 0; i != numcodes; ++i) tree->lengths[i] = bitlen[i];
tree->numcodes = (unsigned)numcodes; /*number of symbols*/
tree->maxbitlen = maxbitlen;
return HuffmanTree_makeFromLengths2(tree);
}
#ifdef LODEPNG_COMPILE_ENCODER
/*BPM: Boundary Package Merge, see "A Fast and Space-Economical Algorithm for Length-Limited Coding",
Jyrki Katajainen, Alistair Moffat, Andrew Turpin, 1995.*/
/*chain node for boundary package merge*/
typedef struct BPMNode
{
int weight; /*the sum of all weights in this chain*/
unsigned index; /*index of this leaf node (called "count" in the paper)*/
struct BPMNode* tail; /*the next nodes in this chain (null if last)*/
int in_use;
} BPMNode;
/*lists of chains*/
typedef struct BPMLists
{
/*memory pool*/
unsigned memsize;
BPMNode* memory;
unsigned numfree;
unsigned nextfree;
BPMNode** freelist;
/*two heads of lookahead chains per list*/
unsigned listsize;
BPMNode** chains0;
BPMNode** chains1;
} BPMLists;
/*creates a new chain node with the given parameters, from the memory in the lists */
static BPMNode* bpmnode_create(BPMLists* lists, int weight, unsigned index, BPMNode* tail)
{
unsigned i;
BPMNode* result;
/*memory full, so garbage collect*/
if(lists->nextfree >= lists->numfree)
{
/*mark only those that are in use*/
for(i = 0; i != lists->memsize; ++i) lists->memory[i].in_use = 0;
for(i = 0; i != lists->listsize; ++i)
{
BPMNode* node;
for(node = lists->chains0[i]; node != 0; node = node->tail) node->in_use = 1;
for(node = lists->chains1[i]; node != 0; node = node->tail) node->in_use = 1;
}
/*collect those that are free*/
lists->numfree = 0;
for(i = 0; i != lists->memsize; ++i)
{
if(!lists->memory[i].in_use) lists->freelist[lists->numfree++] = &lists->memory[i];
}
lists->nextfree = 0;
}
result = lists->freelist[lists->nextfree++];
result->weight = weight;
result->index = index;
result->tail = tail;
return result;
}
/*sort the leaves with stable mergesort*/
static void bpmnode_sort(BPMNode* leaves, size_t num)
{
BPMNode* mem = (BPMNode*)lodepng_malloc(sizeof(*leaves) * num);
size_t width, counter = 0;
for(width = 1; width < num; width *= 2)
{
BPMNode* a = (counter & 1) ? mem : leaves;
BPMNode* b = (counter & 1) ? leaves : mem;
size_t p;
for(p = 0; p < num; p += 2 * width)
{
size_t q = (p + width > num) ? num : (p + width);
size_t r = (p + 2 * width > num) ? num : (p + 2 * width);
size_t i = p, j = q, k;
for(k = p; k < r; k++)
{
if(i < q && (j >= r || a[i].weight <= a[j].weight)) b[k] = a[i++];
else b[k] = a[j++];
}
}
counter++;
}
if(counter & 1) memcpy(leaves, mem, sizeof(*leaves) * num);
lodepng_free(mem);
}
/*Boundary Package Merge step, numpresent is the amount of leaves, and c is the current chain.*/
static void boundaryPM(BPMLists* lists, BPMNode* leaves, size_t numpresent, int c, int num)
{
unsigned lastindex = lists->chains1[c]->index;
if(c == 0)
{
if(lastindex >= numpresent) return;
lists->chains0[c] = lists->chains1[c];
lists->chains1[c] = bpmnode_create(lists, leaves[lastindex].weight, lastindex + 1, 0);
}
else
{
/*sum of the weights of the head nodes of the previous lookahead chains.*/
int sum = lists->chains0[c - 1]->weight + lists->chains1[c - 1]->weight;
lists->chains0[c] = lists->chains1[c];
if(lastindex < numpresent && sum > leaves[lastindex].weight)
{
lists->chains1[c] = bpmnode_create(lists, leaves[lastindex].weight, lastindex + 1, lists->chains1[c]->tail);
return;
}
lists->chains1[c] = bpmnode_create(lists, sum, lastindex, lists->chains1[c - 1]);
/*in the end we are only interested in the chain of the last list, so no
need to recurse if we're at the last one (this gives measurable speedup)*/
if(num + 1 < (int)(2 * numpresent - 2))
{
boundaryPM(lists, leaves, numpresent, c - 1, num);
boundaryPM(lists, leaves, numpresent, c - 1, num);
}
}
}
unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequencies,
size_t numcodes, unsigned maxbitlen)
{
unsigned error = 0;
unsigned i;
size_t numpresent = 0; /*number of symbols with non-zero frequency*/
BPMNode* leaves; /*the symbols, only those with > 0 frequency*/
if(numcodes == 0) return 80; /*error: a tree of 0 symbols is not supposed to be made*/
if(((size_t)1u << (size_t)maxbitlen) < numcodes) return 80; /*error: represent all symbols*/
leaves = (BPMNode*)lodepng_malloc(numcodes * sizeof(*leaves));
if(!leaves) return 83; /*alloc fail*/
for(i = 0; i != numcodes; ++i)
{
if(frequencies[i] > 0)
{
leaves[numpresent].weight = (int)frequencies[i];
leaves[numpresent].index = i;
++numpresent;
}
}
for(i = 0; i != numcodes; ++i) lengths[i] = 0;
/*ensure at least two present symbols. There should be at least one symbol
according to RFC 1951 section 3.2.7. Some decoders incorrectly require two. To
make these work as well ensure there are at least two symbols. The
Package-Merge code below also doesn't work correctly if there's only one
symbol, it'd give it the theoritical 0 bits but in practice zlib wants 1 bit*/
if(numpresent == 0)
{
lengths[0] = lengths[1] = 1; /*note that for RFC 1951 section 3.2.7, only lengths[0] = 1 is needed*/
}
else if(numpresent == 1)
{
lengths[leaves[0].index] = 1;
lengths[leaves[0].index == 0 ? 1 : 0] = 1;
}
else
{
BPMLists lists;
BPMNode* node;
bpmnode_sort(leaves, numpresent);
lists.listsize = maxbitlen;
lists.memsize = 2 * maxbitlen * (maxbitlen + 1);
lists.nextfree = 0;
lists.numfree = lists.memsize;
lists.memory = (BPMNode*)lodepng_malloc(lists.memsize * sizeof(*lists.memory));
lists.freelist = (BPMNode**)lodepng_malloc(lists.memsize * sizeof(BPMNode*));
lists.chains0 = (BPMNode**)lodepng_malloc(lists.listsize * sizeof(BPMNode*));
lists.chains1 = (BPMNode**)lodepng_malloc(lists.listsize * sizeof(BPMNode*));
if(!lists.memory || !lists.freelist || !lists.chains0 || !lists.chains1) error = 83; /*alloc fail*/
if(!error)
{
for(i = 0; i != lists.memsize; ++i) lists.freelist[i] = &lists.memory[i];
bpmnode_create(&lists, leaves[0].weight, 1, 0);
bpmnode_create(&lists, leaves[1].weight, 2, 0);
for(i = 0; i != lists.listsize; ++i)
{
lists.chains0[i] = &lists.memory[0];
lists.chains1[i] = &lists.memory[1];
}
/*each boundaryPM call adds one chain to the last list, and we need 2 * numpresent - 2 chains.*/
for(i = 2; i != 2 * numpresent - 2; ++i) boundaryPM(&lists, leaves, numpresent, (int)maxbitlen - 1, (int)i);
for(node = lists.chains1[maxbitlen - 1]; node; node = node->tail)
{
for(i = 0; i != node->index; ++i) ++lengths[leaves[i].index];
}
}
lodepng_free(lists.memory);
lodepng_free(lists.freelist);
lodepng_free(lists.chains0);
lodepng_free(lists.chains1);
}
lodepng_free(leaves);
return error;
}
/*Create the Huffman tree given the symbol frequencies*/
static unsigned HuffmanTree_makeFromFrequencies(HuffmanTree* tree, const unsigned* frequencies,
size_t mincodes, size_t numcodes, unsigned maxbitlen)
{
unsigned error = 0;
while(!frequencies[numcodes - 1] && numcodes > mincodes) --numcodes; /*trim zeroes*/
tree->maxbitlen = maxbitlen;
tree->numcodes = (unsigned)numcodes; /*number of symbols*/
tree->lengths = (unsigned*)lodepng_realloc(tree->lengths, numcodes * sizeof(unsigned));
if(!tree->lengths) return 83; /*alloc fail*/
/*initialize all lengths to 0*/
memset(tree->lengths, 0, numcodes * sizeof(unsigned));
error = lodepng_huffman_code_lengths(tree->lengths, frequencies, numcodes, maxbitlen);
if(!error) error = HuffmanTree_makeFromLengths2(tree);
return error;
}
static unsigned HuffmanTree_getCode(const HuffmanTree* tree, unsigned index)
{
return tree->tree1d[index];
}
static unsigned HuffmanTree_getLength(const HuffmanTree* tree, unsigned index)
{
return tree->lengths[index];
}
#endif /*LODEPNG_COMPILE_ENCODER*/
/*get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/
static unsigned generateFixedLitLenTree(HuffmanTree* tree)
{
unsigned i, error = 0;
unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
if(!bitlen) return 83; /*alloc fail*/
/*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
for(i = 0; i <= 143; ++i) bitlen[i] = 8;
for(i = 144; i <= 255; ++i) bitlen[i] = 9;
for(i = 256; i <= 279; ++i) bitlen[i] = 7;
for(i = 280; i <= 287; ++i) bitlen[i] = 8;
error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);
lodepng_free(bitlen);
return error;
}
/*get the distance code tree of a deflated block with fixed tree, as specified in the deflate specification*/
static unsigned generateFixedDistanceTree(HuffmanTree* tree)
{
unsigned i, error = 0;
unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
if(!bitlen) return 83; /*alloc fail*/
/*there are 32 distance codes, but 30-31 are unused*/
for(i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen[i] = 5;
error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DISTANCE_SYMBOLS, 15);
lodepng_free(bitlen);
return error;
}
#ifdef LODEPNG_COMPILE_DECODER
/*
returns the code, or (unsigned)(-1) if error happened
inbitlength is the length of the complete buffer, in bits (so its byte length times 8)
*/
static unsigned huffmanDecodeSymbol(const unsigned char* in, size_t* bp,
const HuffmanTree* codetree, size_t inbitlength)
{
unsigned treepos = 0, ct;
for(;;)
{
if(*bp >= inbitlength) return (unsigned)(-1); /*error: end of input memory reached without endcode*/
/*
decode the symbol from the tree. The "readBitFromStream" code is inlined in
the expression below because this is the biggest bottleneck while decoding
*/
ct = codetree->tree2d[(treepos << 1) + READBIT(*bp, in)];
++(*bp);
if(ct < codetree->numcodes) return ct; /*the symbol is decoded, return it*/
else treepos = ct - codetree->numcodes; /*symbol not yet decoded, instead move tree position*/
if(treepos >= codetree->numcodes) return (unsigned)(-1); /*error: it appeared outside the codetree*/
}
}
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_DECODER
/* ////////////////////////////////////////////////////////////////////////// */
/* / Inflator (Decompressor) / */
/* ////////////////////////////////////////////////////////////////////////// */
/*get the tree of a deflated block with fixed tree, as specified in the deflate specification*/
static void getTreeInflateFixed(HuffmanTree* tree_ll, HuffmanTree* tree_d)
{
/*TODO: check for out of memory errors*/
generateFixedLitLenTree(tree_ll);
generateFixedDistanceTree(tree_d);
}
/*get the tree of a deflated block with dynamic tree, the tree itself is also Huffman compressed with a known tree*/
static unsigned getTreeInflateDynamic(HuffmanTree* tree_ll, HuffmanTree* tree_d,
const unsigned char* in, size_t* bp, size_t inlength)
{
/*make sure that length values that aren't filled in will be 0, or a wrong tree will be generated*/
unsigned error = 0;
unsigned n, HLIT, HDIST, HCLEN, i;
size_t inbitlength = inlength * 8;
/*see comments in deflateDynamic for explanation of the context and these variables, it is analogous*/
unsigned* bitlen_ll = 0; /*lit,len code lengths*/
unsigned* bitlen_d = 0; /*dist code lengths*/
/*code length code lengths ("clcl"), the bit lengths of the huffman tree used to compress bitlen_ll and bitlen_d*/
unsigned* bitlen_cl = 0;
HuffmanTree tree_cl; /*the code tree for code length codes (the huffman tree for compressed huffman trees)*/
if((*bp) + 14 > (inlength << 3)) return 49; /*error: the bit pointer is or will go past the memory*/
/*number of literal/length codes + 257. Unlike the spec, the value 257 is added to it here already*/
HLIT = readBitsFromStream(bp, in, 5) + 257;
/*number of distance codes. Unlike the spec, the value 1 is added to it here already*/
HDIST = readBitsFromStream(bp, in, 5) + 1;
/*number of code length codes. Unlike the spec, the value 4 is added to it here already*/
HCLEN = readBitsFromStream(bp, in, 4) + 4;
if((*bp) + HCLEN * 3 > (inlength << 3)) return 50; /*error: the bit pointer is or will go past the memory*/
HuffmanTree_init(&tree_cl);
while(!error)
{
/*read the code length codes out of 3 * (amount of code length codes) bits*/
bitlen_cl = (unsigned*)lodepng_malloc(NUM_CODE_LENGTH_CODES * sizeof(unsigned));
if(!bitlen_cl) ERROR_BREAK(83 /*alloc fail*/);
for(i = 0; i != NUM_CODE_LENGTH_CODES; ++i)
{
if(i < HCLEN) bitlen_cl[CLCL_ORDER[i]] = readBitsFromStream(bp, in, 3);
else bitlen_cl[CLCL_ORDER[i]] = 0; /*if not, it must stay 0*/
}
error = HuffmanTree_makeFromLengths(&tree_cl, bitlen_cl, NUM_CODE_LENGTH_CODES, 7);
if(error) break;
/*now we can use this tree to read the lengths for the tree that this function will return*/
bitlen_ll = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
bitlen_d = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
if(!bitlen_ll || !bitlen_d) ERROR_BREAK(83 /*alloc fail*/);
for(i = 0; i != NUM_DEFLATE_CODE_SYMBOLS; ++i) bitlen_ll[i] = 0;
for(i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen_d[i] = 0;
/*i is the current symbol we're reading in the part that contains the code lengths of lit/len and dist codes*/
i = 0;
while(i < HLIT + HDIST)
{
unsigned code = huffmanDecodeSymbol(in, bp, &tree_cl, inbitlength);
if(code <= 15) /*a length code*/
{
if(i < HLIT) bitlen_ll[i] = code;
else bitlen_d[i - HLIT] = code;
++i;
}
else if(code == 16) /*repeat previous*/
{
unsigned replength = 3; /*read in the 2 bits that indicate repeat length (3-6)*/
unsigned value; /*set value to the previous code*/
if(i == 0) ERROR_BREAK(54); /*can't repeat previous if i is 0*/
if((*bp + 2) > inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/
replength += readBitsFromStream(bp, in, 2);
if(i < HLIT + 1) value = bitlen_ll[i - 1];
else value = bitlen_d[i - HLIT - 1];
/*repeat this value in the next lengths*/
for(n = 0; n < replength; ++n)
{
if(i >= HLIT + HDIST) ERROR_BREAK(13); /*error: i is larger than the amount of codes*/
if(i < HLIT) bitlen_ll[i] = value;
else bitlen_d[i - HLIT] = value;
++i;
}
}
else if(code == 17) /*repeat "0" 3-10 times*/
{
unsigned replength = 3; /*read in the bits that indicate repeat length*/
if((*bp + 3) > inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/
replength += readBitsFromStream(bp, in, 3);
/*repeat this value in the next lengths*/
for(n = 0; n < replength; ++n)
{
if(i >= HLIT + HDIST) ERROR_BREAK(14); /*error: i is larger than the amount of codes*/
if(i < HLIT) bitlen_ll[i] = 0;
else bitlen_d[i - HLIT] = 0;
++i;
}
}
else if(code == 18) /*repeat "0" 11-138 times*/
{
unsigned replength = 11; /*read in the bits that indicate repeat length*/
if((*bp + 7) > inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/
replength += readBitsFromStream(bp, in, 7);
/*repeat this value in the next lengths*/
for(n = 0; n < replength; ++n)
{
if(i >= HLIT + HDIST) ERROR_BREAK(15); /*error: i is larger than the amount of codes*/
if(i < HLIT) bitlen_ll[i] = 0;
else bitlen_d[i - HLIT] = 0;
++i;
}
}
else /*if(code == (unsigned)(-1))*/ /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/
{
if(code == (unsigned)(-1))
{
/*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol
(10=no endcode, 11=wrong jump outside of tree)*/
error = (*bp) > inbitlength ? 10 : 11;
}
else error = 16; /*unexisting code, this can never happen*/
break;
}
}
if(error) break;
if(bitlen_ll[256] == 0) ERROR_BREAK(64); /*the length of the end code 256 must be larger than 0*/
/*now we've finally got HLIT and HDIST, so generate the code trees, and the function is done*/
error = HuffmanTree_makeFromLengths(tree_ll, bitlen_ll, NUM_DEFLATE_CODE_SYMBOLS, 15);
if(error) break;
error = HuffmanTree_makeFromLengths(tree_d, bitlen_d, NUM_DISTANCE_SYMBOLS, 15);
break; /*end of error-while*/
}
lodepng_free(bitlen_cl);
lodepng_free(bitlen_ll);
lodepng_free(bitlen_d);
HuffmanTree_cleanup(&tree_cl);
return error;
}
/*inflate a block with dynamic of fixed Huffman tree*/
static unsigned inflateHuffmanBlock(ucvector* out, const unsigned char* in, size_t* bp,
size_t* pos, size_t inlength, unsigned btype)
{
unsigned error = 0;
HuffmanTree tree_ll; /*the huffman tree for literal and length codes*/
HuffmanTree tree_d; /*the huffman tree for distance codes*/
size_t inbitlength = inlength * 8;
HuffmanTree_init(&tree_ll);
HuffmanTree_init(&tree_d);
if(btype == 1) getTreeInflateFixed(&tree_ll, &tree_d);
else if(btype == 2) error = getTreeInflateDynamic(&tree_ll, &tree_d, in, bp, inlength);
while(!error) /*decode all symbols until end reached, breaks at end code*/
{
/*code_ll is literal, length or end code*/
unsigned code_ll = huffmanDecodeSymbol(in, bp, &tree_ll, inbitlength);
if(code_ll <= 255) /*literal symbol*/
{
/*ucvector_push_back would do the same, but for some reason the two lines below run 10% faster*/
if(!ucvector_resize(out, (*pos) + 1)) ERROR_BREAK(83 /*alloc fail*/);
out->data[*pos] = (unsigned char)code_ll;
++(*pos);
}
else if(code_ll >= FIRST_LENGTH_CODE_INDEX && code_ll <= LAST_LENGTH_CODE_INDEX) /*length code*/
{
unsigned code_d, distance;
unsigned numextrabits_l, numextrabits_d; /*extra bits for length and distance*/
size_t start, forward, backward, length;
/*part 1: get length base*/
length = LENGTHBASE[code_ll - FIRST_LENGTH_CODE_INDEX];
/*part 2: get extra bits and add the value of that to length*/
numextrabits_l = LENGTHEXTRA[code_ll - FIRST_LENGTH_CODE_INDEX];
if((*bp + numextrabits_l) > inbitlength) ERROR_BREAK(51); /*error, bit pointer will jump past memory*/
length += readBitsFromStream(bp, in, numextrabits_l);
/*part 3: get distance code*/
code_d = huffmanDecodeSymbol(in, bp, &tree_d, inbitlength);
if(code_d > 29)
{
if(code_d == (unsigned)(-1)) /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/
{
/*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol
(10=no endcode, 11=wrong jump outside of tree)*/
error = (*bp) > inlength * 8 ? 10 : 11;
}
else error = 18; /*error: invalid distance code (30-31 are never used)*/
break;
}
distance = DISTANCEBASE[code_d];
/*part 4: get extra bits from distance*/
numextrabits_d = DISTANCEEXTRA[code_d];
if((*bp + numextrabits_d) > inbitlength) ERROR_BREAK(51); /*error, bit pointer will jump past memory*/
distance += readBitsFromStream(bp, in, numextrabits_d);
/*part 5: fill in all the out[n] values based on the length and dist*/
start = (*pos);
if(distance > start) ERROR_BREAK(52); /*too long backward distance*/
backward = start - distance;
if(!ucvector_resize(out, (*pos) + length)) ERROR_BREAK(83 /*alloc fail*/);
if (distance < length) {
for(forward = 0; forward < length; ++forward)
{
out->data[(*pos)++] = out->data[backward++];
}
} else {
memcpy(out->data + *pos, out->data + backward, length);
*pos += length;
}
}
else if(code_ll == 256)
{
break; /*end code, break the loop*/
}
else /*if(code == (unsigned)(-1))*/ /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/
{
/*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol
(10=no endcode, 11=wrong jump outside of tree)*/
error = ((*bp) > inlength * 8) ? 10 : 11;
break;
}
}
HuffmanTree_cleanup(&tree_ll);
HuffmanTree_cleanup(&tree_d);
return error;
}
static unsigned inflateNoCompression(ucvector* out, const unsigned char* in, size_t* bp, size_t* pos, size_t inlength)
{
size_t p;
unsigned LEN, NLEN, n, error = 0;
/*go to first boundary of byte*/
while(((*bp) & 0x7) != 0) ++(*bp);
p = (*bp) / 8; /*byte position*/
/*read LEN (2 bytes) and NLEN (2 bytes)*/
if(p + 4 >= inlength) return 52; /*error, bit pointer will jump past memory*/
LEN = in[p] + 256u * in[p + 1]; p += 2;
NLEN = in[p] + 256u * in[p + 1]; p += 2;
/*check if 16-bit NLEN is really the one's complement of LEN*/
if(LEN + NLEN != 65535) return 21; /*error: NLEN is not one's complement of LEN*/
if(!ucvector_resize(out, (*pos) + LEN)) return 83; /*alloc fail*/
/*read the literal data: LEN bytes are now stored in the out buffer*/
if(p + LEN > inlength) return 23; /*error: reading outside of in buffer*/
for(n = 0; n < LEN; ++n) out->data[(*pos)++] = in[p++];
(*bp) = p * 8;
return error;
}
static unsigned lodepng_inflatev(ucvector* out,
const unsigned char* in, size_t insize,
const LodePNGDecompressSettings* settings)
{
/*bit pointer in the "in" data, current byte is bp >> 3, current bit is bp & 0x7 (from lsb to msb of the byte)*/
size_t bp = 0;
unsigned BFINAL = 0;
size_t pos = 0; /*byte position in the out buffer*/
unsigned error = 0;
(void)settings;
while(!BFINAL)
{
unsigned BTYPE;
if(bp + 2 >= insize * 8) return 52; /*error, bit pointer will jump past memory*/
BFINAL = readBitFromStream(&bp, in);
BTYPE = 1u * readBitFromStream(&bp, in);
BTYPE += 2u * readBitFromStream(&bp, in);
if(BTYPE == 3) return 20; /*error: invalid BTYPE*/
else if(BTYPE == 0) error = inflateNoCompression(out, in, &bp, &pos, insize); /*no compression*/
else error = inflateHuffmanBlock(out, in, &bp, &pos, insize, BTYPE); /*compression, BTYPE 01 or 10*/
if(error) return error;
}
return error;
}
unsigned lodepng_inflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
const LodePNGDecompressSettings* settings)
{
unsigned error;
ucvector v;
ucvector_init_buffer(&v, *out, *outsize);
error = lodepng_inflatev(&v, in, insize, settings);
*out = v.data;
*outsize = v.size;
return error;
}
static unsigned inflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
const LodePNGDecompressSettings* settings)
{
if(settings->custom_inflate)
{
return settings->custom_inflate(out, outsize, in, insize, settings);
}
else
{
return lodepng_inflate(out, outsize, in, insize, settings);
}
}
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
/* ////////////////////////////////////////////////////////////////////////// */
/* / Deflator (Compressor) / */
/* ////////////////////////////////////////////////////////////////////////// */
static const size_t MAX_SUPPORTED_DEFLATE_LENGTH = 258;
/*bitlen is the size in bits of the code*/
static void addHuffmanSymbol(size_t* bp, ucvector* compressed, unsigned code, unsigned bitlen)
{
addBitsToStreamReversed(bp, compressed, code, bitlen);
}
/*search the index in the array, that has the largest value smaller than or equal to the given value,
given array must be sorted (if no value is smaller, it returns the size of the given array)*/
static size_t searchCodeIndex(const unsigned* array, size_t array_size, size_t value)
{
/*binary search (only small gain over linear). TODO: use CPU log2 instruction for getting symbols instead*/
size_t left = 1;
size_t right = array_size - 1;
while(left <= right) {
size_t mid = (left + right) >> 1;
if (array[mid] >= value) right = mid - 1;
else left = mid + 1;
}
if(left >= array_size || array[left] > value) left--;
return left;
}
static void addLengthDistance(uivector* values, size_t length, size_t distance)
{
/*values in encoded vector are those used by deflate:
0-255: literal bytes
256: end
257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits)
286-287: invalid*/
unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length);
unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]);
unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance);
unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]);
uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX);
uivector_push_back(values, extra_length);
uivector_push_back(values, dist_code);
uivector_push_back(values, extra_distance);
}
/*3 bytes of data get encoded into two bytes. The hash cannot use more than 3
bytes as input because 3 is the minimum match length for deflate*/
static const unsigned HASH_NUM_VALUES = 65536;
static const unsigned HASH_BIT_MASK = 65535; /*HASH_NUM_VALUES - 1, but C90 does not like that as initializer*/
typedef struct Hash
{
int* head; /*hash value to head circular pos - can be outdated if went around window*/
/*circular pos to prev circular pos*/
unsigned short* chain;
int* val; /*circular pos to hash value*/
/*TODO: do this not only for zeros but for any repeated byte. However for PNG
it's always going to be the zeros that dominate, so not important for PNG*/
int* headz; /*similar to head, but for chainz*/
unsigned short* chainz; /*those with same amount of zeros*/
unsigned short* zeros; /*length of zeros streak, used as a second hash chain*/
} Hash;
static unsigned hash_init(Hash* hash, unsigned windowsize)
{
unsigned i;
hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES);
hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize);
hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
hash->headz = (int*)lodepng_malloc(sizeof(int) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
hash->chainz = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
if(!hash->head || !hash->chain || !hash->val || !hash->headz|| !hash->chainz || !hash->zeros)
{
return 83; /*alloc fail*/
}
/*initialize hash table*/
for(i = 0; i != HASH_NUM_VALUES; ++i) hash->head[i] = -1;
for(i = 0; i != windowsize; ++i) hash->val[i] = -1;
for(i = 0; i != windowsize; ++i) hash->chain[i] = (unsigned short)i; /*same value as index indicates uninitialized*/
for(i = 0; i <= MAX_SUPPORTED_DEFLATE_LENGTH; ++i) hash->headz[i] = -1;
for(i = 0; i != windowsize; ++i) hash->chainz[i] = (unsigned short)i; /*same value as index indicates uninitialized*/
return 0;
}
static void hash_cleanup(Hash* hash)
{
lodepng_free(hash->head);
lodepng_free(hash->val);
lodepng_free(hash->chain);
lodepng_free(hash->zeros);
lodepng_free(hash->headz);
lodepng_free(hash->chainz);
}
static unsigned getHash(const unsigned char* data, size_t size, size_t pos)
{
unsigned result = 0;
if(pos + 2 < size)
{
/*A simple shift and xor hash is used. Since the data of PNGs is dominated
by zeroes due to the filters, a better hash does not have a significant
effect on speed in traversing the chain, and causes more time spend on
calculating the hash.*/
result ^= (unsigned)(data[pos + 0] << 0u);
result ^= (unsigned)(data[pos + 1] << 4u);
result ^= (unsigned)(data[pos + 2] << 8u);
} else {
size_t amount, i;
if(pos >= size) return 0;
amount = size - pos;
for(i = 0; i != amount; ++i) result ^= (unsigned)(data[pos + i] << (i * 8u));
}
return result & HASH_BIT_MASK;
}
static unsigned countZeros(const unsigned char* data, size_t size, size_t pos)
{
const unsigned char* start = data + pos;
const unsigned char* end = start + MAX_SUPPORTED_DEFLATE_LENGTH;
if(end > data + size) end = data + size;
data = start;
while(data != end && *data == 0) ++data;
/*subtracting two addresses returned as 32-bit number (max value is MAX_SUPPORTED_DEFLATE_LENGTH)*/
return (unsigned)(data - start);
}
/*wpos = pos & (windowsize - 1)*/
static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned short numzeros)
{
hash->val[wpos] = (int)hashval;
if(hash->head[hashval] != -1) hash->chain[wpos] = (unsigned short)hash->head[hashval];
hash->head[hashval] = (int)wpos;
hash->zeros[wpos] = numzeros;
if(hash->headz[numzeros] != -1) hash->chainz[wpos] = (unsigned short)hash->headz[numzeros];
hash->headz[numzeros] = (int)wpos;
}
/*
LZ77-encode the data. Return value is error code. The input are raw bytes, the output
is in the form of unsigned integers with codes representing for example literal bytes, or
length/distance pairs.
It uses a hash table technique to let it encode faster. When doing LZ77 encoding, a
sliding window (of windowsize) is used, and all past bytes in that window can be used as
the "dictionary". A brute force search through all possible distances would be slow, and
this hash technique is one out of several ways to speed this up.
*/
static unsigned encodeLZ77(uivector* out, Hash* hash,
const unsigned char* in, size_t inpos, size_t insize, unsigned windowsize,
unsigned minmatch, unsigned nicematch, unsigned lazymatching)
{
size_t pos;
unsigned i, error = 0;
/*for large window lengths, assume the user wants no compression loss. Otherwise, max hash chain length speedup.*/
unsigned maxchainlength = windowsize >= 8192 ? windowsize : windowsize / 8;
unsigned maxlazymatch = windowsize >= 8192 ? MAX_SUPPORTED_DEFLATE_LENGTH : 64;
unsigned usezeros = 1; /*not sure if setting it to false for windowsize < 8192 is better or worse*/
unsigned numzeros = 0;
unsigned offset; /*the offset represents the distance in LZ77 terminology*/
unsigned length;
unsigned lazy = 0;
unsigned lazylength = 0, lazyoffset = 0;
unsigned hashval;
unsigned current_offset, current_length;
unsigned prev_offset;
const unsigned char *lastptr, *foreptr, *backptr;
unsigned hashpos;
if(windowsize == 0 || windowsize > 32768) return 60; /*error: windowsize smaller/larger than allowed*/
if((windowsize & (windowsize - 1)) != 0) return 90; /*error: must be power of two*/
if(nicematch > MAX_SUPPORTED_DEFLATE_LENGTH) nicematch = MAX_SUPPORTED_DEFLATE_LENGTH;
for(pos = inpos; pos < insize; ++pos)
{
size_t wpos = pos & (windowsize - 1); /*position for in 'circular' hash buffers*/
unsigned chainlength = 0;
hashval = getHash(in, insize, pos);
if(usezeros && hashval == 0)
{
if(numzeros == 0) numzeros = countZeros(in, insize, pos);
else if(pos + numzeros > insize || in[pos + numzeros - 1] != 0) --numzeros;
}
else
{
numzeros = 0;
}
updateHashChain(hash, wpos, hashval, (unsigned short)numzeros);
/*the length and offset found for the current position*/
length = 0;
offset = 0;
hashpos = hash->chain[wpos];
lastptr = &in[insize < pos + MAX_SUPPORTED_DEFLATE_LENGTH ? insize : pos + MAX_SUPPORTED_DEFLATE_LENGTH];
/*search for the longest string*/
prev_offset = 0;
for(;;)
{
if(chainlength++ >= maxchainlength) break;
current_offset = hashpos <= (unsigned int)wpos ? (unsigned int)wpos - hashpos : (unsigned int)wpos - hashpos + windowsize;
if(current_offset < prev_offset) break; /*stop when went completely around the circular buffer*/
prev_offset = current_offset;
if(current_offset > 0)
{
/*test the next characters*/
foreptr = &in[pos];
backptr = &in[pos - current_offset];
/*common case in PNGs is lots of zeros. Quickly skip over them as a speedup*/
if(numzeros >= 3)
{
unsigned skip = hash->zeros[hashpos];
if(skip > numzeros) skip = numzeros;
backptr += skip;
foreptr += skip;
}
while(foreptr != lastptr && *backptr == *foreptr) /*maximum supported length by deflate is max length*/
{
++backptr;
++foreptr;
}
current_length = (unsigned)(foreptr - &in[pos]);
if(current_length > length)
{
length = current_length; /*the longest length*/
offset = current_offset; /*the offset that is related to this longest length*/
/*jump out once a length of max length is found (speed gain). This also jumps
out if length is MAX_SUPPORTED_DEFLATE_LENGTH*/
if(current_length >= nicematch) break;
}
}
if(hashpos == hash->chain[hashpos]) break;
if(numzeros >= 3 && length > numzeros)
{
hashpos = hash->chainz[hashpos];
if(hash->zeros[hashpos] != numzeros) break;
}
else
{
hashpos = hash->chain[hashpos];
/*outdated hash value, happens if particular value was not encountered in whole last window*/
if(hash->val[hashpos] != (int)hashval) break;
}
}
if(lazymatching)
{
if(!lazy && length >= 3 && length <= maxlazymatch && length < MAX_SUPPORTED_DEFLATE_LENGTH)
{
lazy = 1;
lazylength = length;
lazyoffset = offset;
continue; /*try the next byte*/
}
if(lazy)
{
lazy = 0;
if(pos == 0) ERROR_BREAK(81);
if(length > lazylength + 1)
{
/*push the previous character as literal*/
if(!uivector_push_back(out, in[pos - 1])) ERROR_BREAK(83 /*alloc fail*/);
}
else
{
length = lazylength;
offset = lazyoffset;
hash->head[hashval] = -1; /*the same hashchain update will be done, this ensures no wrong alteration*/
hash->headz[numzeros] = -1; /*idem*/
--pos;
}
}
}
if(length >= 3 && offset > windowsize) ERROR_BREAK(86 /*too big (or overflown negative) offset*/);
/*encode it as length/distance pair or literal value*/
if(length < 3) /*only lengths of 3 or higher are supported as length/distance pair*/
{
if(!uivector_push_back(out, in[pos])) ERROR_BREAK(83 /*alloc fail*/);
}
else if(length < minmatch || (length == 3 && offset > 4096))
{
/*compensate for the fact that longer offsets have more extra bits, a
length of only 3 may be not worth it then*/
if(!uivector_push_back(out, in[pos])) ERROR_BREAK(83 /*alloc fail*/);
}
else
{
addLengthDistance(out, length, offset);
for(i = 1; i < length; ++i)
{
++pos;
wpos = pos & (windowsize - 1);
hashval = getHash(in, insize, pos);
if(usezeros && hashval == 0)
{
if(numzeros == 0) numzeros = countZeros(in, insize, pos);
else if(pos + numzeros > insize || in[pos + numzeros - 1] != 0) --numzeros;
}
else
{
numzeros = 0;
}
updateHashChain(hash, wpos, hashval, (unsigned short)numzeros);
}
}
} /*end of the loop through each character of input*/
return error;
}
/* /////////////////////////////////////////////////////////////////////////// */
static unsigned deflateNoCompression(ucvector* out, const unsigned char* data, size_t datasize)
{
/*non compressed deflate block data: 1 bit BFINAL,2 bits BTYPE,(5 bits): it jumps to start of next byte,
2 bytes LEN, 2 bytes NLEN, LEN bytes literal DATA*/
size_t i, j, numdeflateblocks = (datasize + 65534) / 65535;
unsigned datapos = 0;
for(i = 0; i != numdeflateblocks; ++i)
{
unsigned BFINAL, BTYPE, LEN, NLEN;
unsigned char firstbyte;
BFINAL = (i == numdeflateblocks - 1);
BTYPE = 0;
firstbyte = (unsigned char)(BFINAL + ((BTYPE & 1) << 1) + ((BTYPE & 2) << 1));
ucvector_push_back(out, firstbyte);
LEN = 65535;
if(datasize - datapos < 65535) LEN = (unsigned)datasize - datapos;
NLEN = 65535 - LEN;
ucvector_push_back(out, (unsigned char)(LEN & 255));
ucvector_push_back(out, (unsigned char)(LEN >> 8));
ucvector_push_back(out, (unsigned char)(NLEN & 255));
ucvector_push_back(out, (unsigned char)(NLEN >> 8));
/*Decompressed data*/
for(j = 0; j < 65535 && datapos < datasize; ++j)
{
ucvector_push_back(out, data[datapos++]);
}
}
return 0;
}
/*
write the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees.
tree_ll: the tree for lit and len codes.
tree_d: the tree for distance codes.
*/
static void writeLZ77data(size_t* bp, ucvector* out, const uivector* lz77_encoded,
const HuffmanTree* tree_ll, const HuffmanTree* tree_d)
{
size_t i = 0;
for(i = 0; i != lz77_encoded->size; ++i)
{
unsigned val = lz77_encoded->data[i];
addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_ll, val), HuffmanTree_getLength(tree_ll, val));
if(val > 256) /*for a length code, 3 more things have to be added*/
{
unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;
unsigned n_length_extra_bits = LENGTHEXTRA[length_index];
unsigned length_extra_bits = lz77_encoded->data[++i];
unsigned distance_code = lz77_encoded->data[++i];
unsigned distance_index = distance_code;
unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];
unsigned distance_extra_bits = lz77_encoded->data[++i];
addBitsToStream(bp, out, length_extra_bits, n_length_extra_bits);
addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_d, distance_code),
HuffmanTree_getLength(tree_d, distance_code));
addBitsToStream(bp, out, distance_extra_bits, n_distance_extra_bits);
}
}
}
/*Deflate for a block of type "dynamic", that is, with freely, optimally, created huffman trees*/
static unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash,
const unsigned char* data, size_t datapos, size_t dataend,
const LodePNGCompressSettings* settings, unsigned final)
{
unsigned error = 0;
/*
A block is compressed as follows: The PNG data is lz77 encoded, resulting in
literal bytes and length/distance pairs. This is then huffman compressed with
two huffman trees. One huffman tree is used for the lit and len values ("ll"),
another huffman tree is used for the dist values ("d"). These two trees are
stored using their code lengths, and to compress even more these code lengths
are also run-length encoded and huffman compressed. This gives a huffman tree
of code lengths "cl". The code lenghts used to describe this third tree are
the code length code lengths ("clcl").
*/
/*The lz77 encoded data, represented with integers since there will also be length and distance codes in it*/
uivector lz77_encoded;
HuffmanTree tree_ll; /*tree for lit,len values*/
HuffmanTree tree_d; /*tree for distance codes*/
HuffmanTree tree_cl; /*tree for encoding the code lengths representing tree_ll and tree_d*/
uivector frequencies_ll; /*frequency of lit,len codes*/
uivector frequencies_d; /*frequency of dist codes*/
uivector frequencies_cl; /*frequency of code length codes*/
uivector bitlen_lld; /*lit,len,dist code lenghts (int bits), literally (without repeat codes).*/
uivector bitlen_lld_e; /*bitlen_lld encoded with repeat codes (this is a rudemtary run length compression)*/
/*bitlen_cl is the code length code lengths ("clcl"). The bit lengths of codes to represent tree_cl
(these are written as is in the file, it would be crazy to compress these using yet another huffman
tree that needs to be represented by yet another set of code lengths)*/
uivector bitlen_cl;
size_t datasize = dataend - datapos;
/*
Due to the huffman compression of huffman tree representations ("two levels"), there are some anologies:
bitlen_lld is to tree_cl what data is to tree_ll and tree_d.
bitlen_lld_e is to bitlen_lld what lz77_encoded is to data.
bitlen_cl is to bitlen_lld_e what bitlen_lld is to lz77_encoded.
*/
unsigned BFINAL = final;
size_t numcodes_ll, numcodes_d, i;
unsigned HLIT, HDIST, HCLEN;
uivector_init(&lz77_encoded);
HuffmanTree_init(&tree_ll);
HuffmanTree_init(&tree_d);
HuffmanTree_init(&tree_cl);
uivector_init(&frequencies_ll);
uivector_init(&frequencies_d);
uivector_init(&frequencies_cl);
uivector_init(&bitlen_lld);
uivector_init(&bitlen_lld_e);
uivector_init(&bitlen_cl);
/*This while loop never loops due to a break at the end, it is here to
allow breaking out of it to the cleanup phase on error conditions.*/
while(!error)
{
if(settings->use_lz77)
{
error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize,
settings->minmatch, settings->nicematch, settings->lazymatching);
if(error) break;
}
else
{
if(!uivector_resize(&lz77_encoded, datasize)) ERROR_BREAK(83 /*alloc fail*/);
for(i = datapos; i < dataend; ++i) lz77_encoded.data[i - datapos] = data[i]; /*no LZ77, but still will be Huffman compressed*/
}
if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83 /*alloc fail*/);
if(!uivector_resizev(&frequencies_d, 30, 0)) ERROR_BREAK(83 /*alloc fail*/);
/*Count the frequencies of lit, len and dist codes*/
for(i = 0; i != lz77_encoded.size; ++i)
{
unsigned symbol = lz77_encoded.data[i];
++frequencies_ll.data[symbol];
if(symbol > 256)
{
unsigned dist = lz77_encoded.data[i + 2];
++frequencies_d.data[dist];
i += 3;
}
}
frequencies_ll.data[256] = 1; /*there will be exactly 1 end code, at the end of the block*/
/*Make both huffman trees, one for the lit and len codes, one for the dist codes*/
error = HuffmanTree_makeFromFrequencies(&tree_ll, frequencies_ll.data, 257, frequencies_ll.size, 15);
if(error) break;
/*2, not 1, is chosen for mincodes: some buggy PNG decoders require at least 2 symbols in the dist tree*/
error = HuffmanTree_makeFromFrequencies(&tree_d, frequencies_d.data, 2, frequencies_d.size, 15);
if(error) break;
numcodes_ll = tree_ll.numcodes; if(numcodes_ll > 286) numcodes_ll = 286;
numcodes_d = tree_d.numcodes; if(numcodes_d > 30) numcodes_d = 30;
/*store the code lengths of both generated trees in bitlen_lld*/
for(i = 0; i != numcodes_ll; ++i) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_ll, (unsigned)i));
for(i = 0; i != numcodes_d; ++i) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_d, (unsigned)i));
/*run-length compress bitlen_ldd into bitlen_lld_e by using repeat codes 16 (copy length 3-6 times),
17 (3-10 zeroes), 18 (11-138 zeroes)*/
for(i = 0; i != (unsigned)bitlen_lld.size; ++i)
{
unsigned j = 0; /*amount of repititions*/
while(i + j + 1 < (unsigned)bitlen_lld.size && bitlen_lld.data[i + j + 1] == bitlen_lld.data[i]) ++j;
if(bitlen_lld.data[i] == 0 && j >= 2) /*repeat code for zeroes*/
{
++j; /*include the first zero*/
if(j <= 10) /*repeat code 17 supports max 10 zeroes*/
{
uivector_push_back(&bitlen_lld_e, 17);
uivector_push_back(&bitlen_lld_e, j - 3);
}
else /*repeat code 18 supports max 138 zeroes*/
{
if(j > 138) j = 138;
uivector_push_back(&bitlen_lld_e, 18);
uivector_push_back(&bitlen_lld_e, j - 11);
}
i += (j - 1);
}
else if(j >= 3) /*repeat code for value other than zero*/
{
size_t k;
unsigned num = j / 6, rest = j % 6;
uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]);
for(k = 0; k < num; ++k)
{
uivector_push_back(&bitlen_lld_e, 16);
uivector_push_back(&bitlen_lld_e, 6 - 3);
}
if(rest >= 3)
{
uivector_push_back(&bitlen_lld_e, 16);
uivector_push_back(&bitlen_lld_e, rest - 3);
}
else j -= rest;
i += j;
}
else /*too short to benefit from repeat code*/
{
uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]);
}
}
/*generate tree_cl, the huffmantree of huffmantrees*/
if(!uivector_resizev(&frequencies_cl, NUM_CODE_LENGTH_CODES, 0)) ERROR_BREAK(83 /*alloc fail*/);
for(i = 0; i != bitlen_lld_e.size; ++i)
{
++frequencies_cl.data[bitlen_lld_e.data[i]];
/*after a repeat code come the bits that specify the number of repetitions,
those don't need to be in the frequencies_cl calculation*/
if(bitlen_lld_e.data[i] >= 16) ++i;
}
error = HuffmanTree_makeFromFrequencies(&tree_cl, frequencies_cl.data,
frequencies_cl.size, frequencies_cl.size, 7);
if(error) break;
if(!uivector_resize(&bitlen_cl, tree_cl.numcodes)) ERROR_BREAK(83 /*alloc fail*/);
for(i = 0; i != tree_cl.numcodes; ++i)
{
/*lenghts of code length tree is in the order as specified by deflate*/
bitlen_cl.data[i] = HuffmanTree_getLength(&tree_cl, CLCL_ORDER[i]);
}
while(bitlen_cl.data[bitlen_cl.size - 1] == 0 && bitlen_cl.size > 4)
{
/*remove zeros at the end, but minimum size must be 4*/
if(!uivector_resize(&bitlen_cl, bitlen_cl.size - 1)) ERROR_BREAK(83 /*alloc fail*/);
}
if(error) break;
/*
Write everything into the output
After the BFINAL and BTYPE, the dynamic block consists out of the following:
- 5 bits HLIT, 5 bits HDIST, 4 bits HCLEN
- (HCLEN+4)*3 bits code lengths of code length alphabet
- HLIT + 257 code lenghts of lit/length alphabet (encoded using the code length
alphabet, + possible repetition codes 16, 17, 18)
- HDIST + 1 code lengths of distance alphabet (encoded using the code length
alphabet, + possible repetition codes 16, 17, 18)
- compressed data
- 256 (end code)
*/
/*Write block type*/
addBitToStream(bp, out, BFINAL);
addBitToStream(bp, out, 0); /*first bit of BTYPE "dynamic"*/
addBitToStream(bp, out, 1); /*second bit of BTYPE "dynamic"*/
/*write the HLIT, HDIST and HCLEN values*/
HLIT = (unsigned)(numcodes_ll - 257);
HDIST = (unsigned)(numcodes_d - 1);
HCLEN = (unsigned)bitlen_cl.size - 4;
/*trim zeroes for HCLEN. HLIT and HDIST were already trimmed at tree creation*/
while(!bitlen_cl.data[HCLEN + 4 - 1] && HCLEN > 0) --HCLEN;
addBitsToStream(bp, out, HLIT, 5);
addBitsToStream(bp, out, HDIST, 5);
addBitsToStream(bp, out, HCLEN, 4);
/*write the code lenghts of the code length alphabet*/
for(i = 0; i != HCLEN + 4; ++i) addBitsToStream(bp, out, bitlen_cl.data[i], 3);
/*write the lenghts of the lit/len AND the dist alphabet*/
for(i = 0; i != bitlen_lld_e.size; ++i)
{
addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_cl, bitlen_lld_e.data[i]),
HuffmanTree_getLength(&tree_cl, bitlen_lld_e.data[i]));
/*extra bits of repeat codes*/
if(bitlen_lld_e.data[i] == 16) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 2);
else if(bitlen_lld_e.data[i] == 17) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 3);
else if(bitlen_lld_e.data[i] == 18) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 7);
}
/*write the compressed data symbols*/
writeLZ77data(bp, out, &lz77_encoded, &tree_ll, &tree_d);
/*error: the length of the end code 256 must be larger than 0*/
if(HuffmanTree_getLength(&tree_ll, 256) == 0) ERROR_BREAK(64);
/*write the end code*/
addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, 256), HuffmanTree_getLength(&tree_ll, 256));
break; /*end of error-while*/
}
/*cleanup*/
uivector_cleanup(&lz77_encoded);
HuffmanTree_cleanup(&tree_ll);
HuffmanTree_cleanup(&tree_d);
HuffmanTree_cleanup(&tree_cl);
uivector_cleanup(&frequencies_ll);
uivector_cleanup(&frequencies_d);
uivector_cleanup(&frequencies_cl);
uivector_cleanup(&bitlen_lld_e);
uivector_cleanup(&bitlen_lld);
uivector_cleanup(&bitlen_cl);
return error;
}
static unsigned deflateFixed(ucvector* out, size_t* bp, Hash* hash,
const unsigned char* data,
size_t datapos, size_t dataend,
const LodePNGCompressSettings* settings, unsigned final)
{
HuffmanTree tree_ll; /*tree for literal values and length codes*/
HuffmanTree tree_d; /*tree for distance codes*/
unsigned BFINAL = final;
unsigned error = 0;
size_t i;
HuffmanTree_init(&tree_ll);
HuffmanTree_init(&tree_d);
generateFixedLitLenTree(&tree_ll);
generateFixedDistanceTree(&tree_d);
addBitToStream(bp, out, BFINAL);
addBitToStream(bp, out, 1); /*first bit of BTYPE*/
addBitToStream(bp, out, 0); /*second bit of BTYPE*/
if(settings->use_lz77) /*LZ77 encoded*/
{
uivector lz77_encoded;
uivector_init(&lz77_encoded);
error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize,
settings->minmatch, settings->nicematch, settings->lazymatching);
if(!error) writeLZ77data(bp, out, &lz77_encoded, &tree_ll, &tree_d);
uivector_cleanup(&lz77_encoded);
}
else /*no LZ77, but still will be Huffman compressed*/
{
for(i = datapos; i < dataend; ++i)
{
addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, data[i]), HuffmanTree_getLength(&tree_ll, data[i]));
}
}
/*add END code*/
if(!error) addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, 256), HuffmanTree_getLength(&tree_ll, 256));
/*cleanup*/
HuffmanTree_cleanup(&tree_ll);
HuffmanTree_cleanup(&tree_d);
return error;
}
static unsigned lodepng_deflatev(ucvector* out, const unsigned char* in, size_t insize,
const LodePNGCompressSettings* settings)
{
unsigned error = 0;
size_t i, blocksize, numdeflateblocks;
size_t bp = 0; /*the bit pointer*/
Hash hash;
if(settings->btype > 2) return 61;
else if(settings->btype == 0) return deflateNoCompression(out, in, insize);
else if(settings->btype == 1) blocksize = insize;
else /*if(settings->btype == 2)*/
{
/*on PNGs, deflate blocks of 65-262k seem to give most dense encoding*/
blocksize = insize / 8 + 8;
if(blocksize < 65536) blocksize = 65536;
if(blocksize > 262144) blocksize = 262144;
}
numdeflateblocks = (insize + blocksize - 1) / blocksize;
if(numdeflateblocks == 0) numdeflateblocks = 1;
error = hash_init(&hash, settings->windowsize);
if(error) return error;
for(i = 0; i != numdeflateblocks && !error; ++i)
{
unsigned final = (i == numdeflateblocks - 1);
size_t start = i * blocksize;
size_t end = start + blocksize;
if(end > insize) end = insize;
if(settings->btype == 1) error = deflateFixed(out, &bp, &hash, in, start, end, settings, final);
else if(settings->btype == 2) error = deflateDynamic(out, &bp, &hash, in, start, end, settings, final);
}
hash_cleanup(&hash);
return error;
}
unsigned lodepng_deflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
const LodePNGCompressSettings* settings)
{
unsigned error;
ucvector v;
ucvector_init_buffer(&v, *out, *outsize);
error = lodepng_deflatev(&v, in, insize, settings);
*out = v.data;
*outsize = v.size;
return error;
}
static unsigned deflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
const LodePNGCompressSettings* settings)
{
if(settings->custom_deflate)
{
return settings->custom_deflate(out, outsize, in, insize, settings);
}
else
{
return lodepng_deflate(out, outsize, in, insize, settings);
}
}
#endif /*LODEPNG_COMPILE_DECODER*/
/* ////////////////////////////////////////////////////////////////////////// */
/* / Adler32 */
/* ////////////////////////////////////////////////////////////////////////// */
static unsigned update_adler32(unsigned adler, const unsigned char* data, unsigned len)
{
unsigned s1 = adler & 0xffff;
unsigned s2 = (adler >> 16) & 0xffff;
while(len > 0)
{
/*at least 5550 sums can be done before the sums overflow, saving a lot of module divisions*/
unsigned amount = len > 5550 ? 5550 : len;
len -= amount;
while(amount > 0)
{
s1 += (*data++);
s2 += s1;
--amount;
}
s1 %= 65521;
s2 %= 65521;
}
return (s2 << 16) | s1;
}
/*Return the adler32 of the bytes data[0..len-1]*/
static unsigned adler32(const unsigned char* data, unsigned len)
{
return update_adler32(1L, data, len);
}
/* ////////////////////////////////////////////////////////////////////////// */
/* / Zlib / */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_DECODER
unsigned lodepng_zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGDecompressSettings* settings)
{
unsigned error = 0;
unsigned CM, CINFO, FDICT;
if(insize < 2) return 53; /*error, size of zlib data too small*/
/*read information from zlib header*/
if((in[0] * 256 + in[1]) % 31 != 0)
{
/*error: 256 * in[0] + in[1] must be a multiple of 31, the FCHECK value is supposed to be made that way*/
return 24;
}
CM = in[0] & 15;
CINFO = (in[0] >> 4) & 15;
/*FCHECK = in[1] & 31;*/ /*FCHECK is already tested above*/
FDICT = (in[1] >> 5) & 1;
/*FLEVEL = (in[1] >> 6) & 3;*/ /*FLEVEL is not used here*/
if(CM != 8 || CINFO > 7)
{
/*error: only compression method 8: inflate with sliding window of 32k is supported by the PNG spec*/
return 25;
}
if(FDICT != 0)
{
/*error: the specification of PNG says about the zlib stream:
"The additional flags shall not specify a preset dictionary."*/
return 26;
}
error = inflate(out, outsize, in + 2, insize - 2, settings);
if(error) return error;
if(!settings->ignore_adler32)
{
unsigned ADLER32 = lodepng_read32bitInt(&in[insize - 4]);
unsigned checksum = adler32(*out, (unsigned)(*outsize));
if(checksum != ADLER32) return 58; /*error, adler checksum not correct, data must be corrupted*/
}
return 0; /*no error*/
}
static unsigned zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGDecompressSettings* settings)
{
if(settings->custom_zlib)
{
return settings->custom_zlib(out, outsize, in, insize, settings);
}
else
{
return lodepng_zlib_decompress(out, outsize, in, insize, settings);
}
}
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
unsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGCompressSettings* settings)
{
/*initially, *out must be NULL and outsize 0, if you just give some random *out
that's pointing to a non allocated buffer, this'll crash*/
ucvector outv;
size_t i;
unsigned error;
unsigned char* deflatedata = 0;
size_t deflatesize = 0;
/*zlib data: 1 byte CMF (CM+CINFO), 1 byte FLG, deflate data, 4 byte ADLER32 checksum of the Decompressed data*/
unsigned CMF = 120; /*0b01111000: CM 8, CINFO 7. With CINFO 7, any window size up to 32768 can be used.*/
unsigned FLEVEL = 0;
unsigned FDICT = 0;
unsigned CMFFLG = 256 * CMF + FDICT * 32 + FLEVEL * 64;
unsigned FCHECK = 31 - CMFFLG % 31;
CMFFLG += FCHECK;
/*ucvector-controlled version of the output buffer, for dynamic array*/
ucvector_init_buffer(&outv, *out, *outsize);
ucvector_push_back(&outv, (unsigned char)(CMFFLG >> 8));
ucvector_push_back(&outv, (unsigned char)(CMFFLG & 255));
error = deflate(&deflatedata, &deflatesize, in, insize, settings);
if(!error)
{
unsigned ADLER32 = adler32(in, (unsigned)insize);
for(i = 0; i != deflatesize; ++i) ucvector_push_back(&outv, deflatedata[i]);
lodepng_free(deflatedata);
lodepng_add32bitInt(&outv, ADLER32);
}
*out = outv.data;
*outsize = outv.size;
return error;
}
/* compress using the default or custom zlib function */
static unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGCompressSettings* settings)
{
if(settings->custom_zlib)
{
return settings->custom_zlib(out, outsize, in, insize, settings);
}
else
{
return lodepng_zlib_compress(out, outsize, in, insize, settings);
}
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#else /*no LODEPNG_COMPILE_ZLIB*/
#ifdef LODEPNG_COMPILE_DECODER
static unsigned zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGDecompressSettings* settings)
{
if(!settings->custom_zlib) return 87; /*no custom zlib function provided */
return settings->custom_zlib(out, outsize, in, insize, settings);
}
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
static unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,
size_t insize, const LodePNGCompressSettings* settings)
{
if(!settings->custom_zlib) return 87; /*no custom zlib function provided */
return settings->custom_zlib(out, outsize, in, insize, settings);
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_ZLIB*/
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_ENCODER
/*this is a good tradeoff between speed and compression ratio*/
#define DEFAULT_WINDOWSIZE 2048
void lodepng_compress_settings_init(LodePNGCompressSettings* settings)
{
/*compress with dynamic huffman tree (not in the mathematical sense, just not the predefined one)*/
settings->btype = 2;
settings->use_lz77 = 1;
settings->windowsize = DEFAULT_WINDOWSIZE;
settings->minmatch = 3;
settings->nicematch = 128;
settings->lazymatching = 1;
settings->custom_zlib = 0;
settings->custom_deflate = 0;
settings->custom_context = 0;
}
const LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, DEFAULT_WINDOWSIZE, 3, 128, 1, 0, 0, 0};
#endif /*LODEPNG_COMPILE_ENCODER*/
#ifdef LODEPNG_COMPILE_DECODER
void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings)
{
settings->ignore_adler32 = 0;
settings->custom_zlib = 0;
settings->custom_inflate = 0;
settings->custom_context = 0;
}
const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0, 0};
#endif /*LODEPNG_COMPILE_DECODER*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // End of Zlib related code. Begin of PNG related code. // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_PNG
/* ////////////////////////////////////////////////////////////////////////// */
/* / CRC32 / */
/* ////////////////////////////////////////////////////////////////////////// */
#ifndef LODEPNG_NO_COMPILE_CRC
/* CRC polynomial: 0xedb88320 */
static unsigned lodepng_crc32_table[256] = {
0u, 1996959894u, 3993919788u, 2567524794u, 124634137u, 1886057615u, 3915621685u, 2657392035u,
249268274u, 2044508324u, 3772115230u, 2547177864u, 162941995u, 2125561021u, 3887607047u, 2428444049u,
498536548u, 1789927666u, 4089016648u, 2227061214u, 450548861u, 1843258603u, 4107580753u, 2211677639u,
325883990u, 1684777152u, 4251122042u, 2321926636u, 335633487u, 1661365465u, 4195302755u, 2366115317u,
997073096u, 1281953886u, 3579855332u, 2724688242u, 1006888145u, 1258607687u, 3524101629u, 2768942443u,
901097722u, 1119000684u, 3686517206u, 2898065728u, 853044451u, 1172266101u, 3705015759u, 2882616665u,
651767980u, 1373503546u, 3369554304u, 3218104598u, 565507253u, 1454621731u, 3485111705u, 3099436303u,
671266974u, 1594198024u, 3322730930u, 2970347812u, 795835527u, 1483230225u, 3244367275u, 3060149565u,
1994146192u, 31158534u, 2563907772u, 4023717930u, 1907459465u, 112637215u, 2680153253u, 3904427059u,
2013776290u, 251722036u, 2517215374u, 3775830040u, 2137656763u, 141376813u, 2439277719u, 3865271297u,
1802195444u, 476864866u, 2238001368u, 4066508878u, 1812370925u, 453092731u, 2181625025u, 4111451223u,
1706088902u, 314042704u, 2344532202u, 4240017532u, 1658658271u, 366619977u, 2362670323u, 4224994405u,
1303535960u, 984961486u, 2747007092u, 3569037538u, 1256170817u, 1037604311u, 2765210733u, 3554079995u,
1131014506u, 879679996u, 2909243462u, 3663771856u, 1141124467u, 855842277u, 2852801631u, 3708648649u,
1342533948u, 654459306u, 3188396048u, 3373015174u, 1466479909u, 544179635u, 3110523913u, 3462522015u,
1591671054u, 702138776u, 2966460450u, 3352799412u, 1504918807u, 783551873u, 3082640443u, 3233442989u,
3988292384u, 2596254646u, 62317068u, 1957810842u, 3939845945u, 2647816111u, 81470997u, 1943803523u,
3814918930u, 2489596804u, 225274430u, 2053790376u, 3826175755u, 2466906013u, 167816743u, 2097651377u,
4027552580u, 2265490386u, 503444072u, 1762050814u, 4150417245u, 2154129355u, 426522225u, 1852507879u,
4275313526u, 2312317920u, 282753626u, 1742555852u, 4189708143u, 2394877945u, 397917763u, 1622183637u,
3604390888u, 2714866558u, 953729732u, 1340076626u, 3518719985u, 2797360999u, 1068828381u, 1219638859u,
3624741850u, 2936675148u, 906185462u, 1090812512u, 3747672003u, 2825379669u, 829329135u, 1181335161u,
3412177804u, 3160834842u, 628085408u, 1382605366u, 3423369109u, 3138078467u, 570562233u, 1426400815u,
3317316542u, 2998733608u, 733239954u, 1555261956u, 3268935591u, 3050360625u, 752459403u, 1541320221u,
2607071920u, 3965973030u, 1969922972u, 40735498u, 2617837225u, 3943577151u, 1913087877u, 83908371u,
2512341634u, 3803740692u, 2075208622u, 213261112u, 2463272603u, 3855990285u, 2094854071u, 198958881u,
2262029012u, 4057260610u, 1759359992u, 534414190u, 2176718541u, 4139329115u, 1873836001u, 414664567u,
2282248934u, 4279200368u, 1711684554u, 285281116u, 2405801727u, 4167216745u, 1634467795u, 376229701u,
2685067896u, 3608007406u, 1308918612u, 956543938u, 2808555105u, 3495958263u, 1231636301u, 1047427035u,
2932959818u, 3654703836u, 1088359270u, 936918000u, 2847714899u, 3736837829u, 1202900863u, 817233897u,
3183342108u, 3401237130u, 1404277552u, 615818150u, 3134207493u, 3453421203u, 1423857449u, 601450431u,
3009837614u, 3294710456u, 1567103746u, 711928724u, 3020668471u, 3272380065u, 1510334235u, 755167117u
};
/*Return the CRC of the bytes buf[0..len-1].*/
unsigned lodepng_crc32(const unsigned char* data, size_t length)
{
unsigned r = 0xffffffffu;
size_t i;
for(i = 0; i < length; ++i)
{
r = lodepng_crc32_table[(r ^ data[i]) & 0xff] ^ (r >> 8);
}
return r ^ 0xffffffffu;
}
#else /* !LODEPNG_NO_COMPILE_CRC */
unsigned lodepng_crc32(const unsigned char* data, size_t length);
#endif /* !LODEPNG_NO_COMPILE_CRC */
/* ////////////////////////////////////////////////////////////////////////// */
/* / Reading and writing single bits and bytes from/to stream for LodePNG / */
/* ////////////////////////////////////////////////////////////////////////// */
static unsigned char readBitFromReversedStream(size_t* bitpointer, const unsigned char* bitstream)
{
unsigned char result = (unsigned char)((bitstream[(*bitpointer) >> 3] >> (7 - ((*bitpointer) & 0x7))) & 1);
++(*bitpointer);
return result;
}
static unsigned readBitsFromReversedStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)
{
unsigned result = 0;
size_t i;
for(i = 0 ; i < nbits; ++i)
{
result <<= 1;
result |= (unsigned)readBitFromReversedStream(bitpointer, bitstream);
}
return result;
}
#ifdef LODEPNG_COMPILE_DECODER
static void setBitOfReversedStream0(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)
{
/*the current bit in bitstream must be 0 for this to work*/
if(bit)
{
/*earlier bit of huffman code is in a lesser significant bit of an earlier byte*/
bitstream[(*bitpointer) >> 3] |= (bit << (7 - ((*bitpointer) & 0x7)));
}
++(*bitpointer);
}
#endif /*LODEPNG_COMPILE_DECODER*/
static void setBitOfReversedStream(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)
{
/*the current bit in bitstream may be 0 or 1 for this to work*/
if(bit == 0) bitstream[(*bitpointer) >> 3] &= (unsigned char)(~(1 << (7 - ((*bitpointer) & 0x7))));
else bitstream[(*bitpointer) >> 3] |= (1 << (7 - ((*bitpointer) & 0x7)));
++(*bitpointer);
}
/* ////////////////////////////////////////////////////////////////////////// */
/* / PNG chunks / */
/* ////////////////////////////////////////////////////////////////////////// */
unsigned lodepng_chunk_length(const unsigned char* chunk)
{
return lodepng_read32bitInt(&chunk[0]);
}
void lodepng_chunk_type(char type[5], const unsigned char* chunk)
{
unsigned i;
for(i = 0; i != 4; ++i) type[i] = (char)chunk[4 + i];
type[4] = 0; /*null termination char*/
}
unsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type)
{
if(strlen(type) != 4) return 0;
return (chunk[4] == type[0] && chunk[5] == type[1] && chunk[6] == type[2] && chunk[7] == type[3]);
}
unsigned char lodepng_chunk_ancillary(const unsigned char* chunk)
{
return((chunk[4] & 32) != 0);
}
unsigned char lodepng_chunk_private(const unsigned char* chunk)
{
return((chunk[6] & 32) != 0);
}
unsigned char lodepng_chunk_safetocopy(const unsigned char* chunk)
{
return((chunk[7] & 32) != 0);
}
unsigned char* lodepng_chunk_data(unsigned char* chunk)
{
return &chunk[8];
}
const unsigned char* lodepng_chunk_data_const(const unsigned char* chunk)
{
return &chunk[8];
}
unsigned lodepng_chunk_check_crc(const unsigned char* chunk)
{
unsigned length = lodepng_chunk_length(chunk);
unsigned CRC = lodepng_read32bitInt(&chunk[length + 8]);
/*the CRC is taken of the data and the 4 chunk type letters, not the length*/
unsigned checksum = lodepng_crc32(&chunk[4], length + 4);
if(CRC != checksum) return 1;
else return 0;
}
void lodepng_chunk_generate_crc(unsigned char* chunk)
{
unsigned length = lodepng_chunk_length(chunk);
unsigned CRC = lodepng_crc32(&chunk[4], length + 4);
lodepng_set32bitInt(chunk + 8 + length, CRC);
}
unsigned char* lodepng_chunk_next(unsigned char* chunk)
{
unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;
return &chunk[total_chunk_length];
}
const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk)
{
unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;
return &chunk[total_chunk_length];
}
unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk)
{
unsigned i;
unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;
unsigned char *chunk_start, *new_buffer;
size_t new_length = (*outlength) + total_chunk_length;
if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/
new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);
if(!new_buffer) return 83; /*alloc fail*/
(*out) = new_buffer;
(*outlength) = new_length;
chunk_start = &(*out)[new_length - total_chunk_length];
for(i = 0; i != total_chunk_length; ++i) chunk_start[i] = chunk[i];
return 0;
}
unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
const char* type, const unsigned char* data)
{
unsigned i;
unsigned char *chunk, *new_buffer;
size_t new_length = (*outlength) + length + 12;
if(new_length < length + 12 || new_length < (*outlength)) return 77; /*integer overflow happened*/
new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);
if(!new_buffer) return 83; /*alloc fail*/
(*out) = new_buffer;
(*outlength) = new_length;
chunk = &(*out)[(*outlength) - length - 12];
/*1: length*/
lodepng_set32bitInt(chunk, (unsigned)length);
/*2: chunk name (4 letters)*/
chunk[4] = (unsigned char)type[0];
chunk[5] = (unsigned char)type[1];
chunk[6] = (unsigned char)type[2];
chunk[7] = (unsigned char)type[3];
/*3: the data*/
for(i = 0; i != length; ++i) chunk[8 + i] = data[i];
/*4: CRC (of the chunkname characters and the data)*/
lodepng_chunk_generate_crc(chunk);
return 0;
}
/* ////////////////////////////////////////////////////////////////////////// */
/* / Color types and such / */
/* ////////////////////////////////////////////////////////////////////////// */
/*return type is a LodePNG error code*/
static unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) /*bd = bitdepth*/
{
switch(colortype)
{
case 0: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break; /*grey*/
case 2: if(!( bd == 8 || bd == 16)) return 37; break; /*RGB*/
case 3: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 )) return 37; break; /*palette*/
case 4: if(!( bd == 8 || bd == 16)) return 37; break; /*grey + alpha*/
case 6: if(!( bd == 8 || bd == 16)) return 37; break; /*RGBA*/
default: return 31;
}
return 0; /*allowed color type / bits combination*/
}
static unsigned getNumColorChannels(LodePNGColorType colortype)
{
switch(colortype)
{
case 0: return 1; /*grey*/
case 2: return 3; /*RGB*/
case 3: return 1; /*palette*/
case 4: return 2; /*grey + alpha*/
case 6: return 4; /*RGBA*/
}
return 0; /*unexisting color type*/
}
static unsigned lodepng_get_bpp_lct(LodePNGColorType colortype, unsigned bitdepth)
{
/*bits per pixel is amount of channels * bits per channel*/
return getNumColorChannels(colortype) * bitdepth;
}
/* ////////////////////////////////////////////////////////////////////////// */
void lodepng_color_mode_init(LodePNGColorMode* info)
{
info->key_defined = 0;
info->key_r = info->key_g = info->key_b = 0;
info->colortype = LCT_RGBA;
info->bitdepth = 8;
info->palette = 0;
info->palettesize = 0;
}
void lodepng_color_mode_cleanup(LodePNGColorMode* info)
{
lodepng_palette_clear(info);
}
unsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source)
{
size_t i;
lodepng_color_mode_cleanup(dest);
*dest = *source;
if(source->palette)
{
dest->palette = (unsigned char*)lodepng_malloc(1024);
if(!dest->palette && source->palettesize) return 83; /*alloc fail*/
for(i = 0; i != source->palettesize * 4; ++i) dest->palette[i] = source->palette[i];
}
return 0;
}
static int lodepng_color_mode_equal(const LodePNGColorMode* a, const LodePNGColorMode* b)
{
size_t i;
if(a->colortype != b->colortype) return 0;
if(a->bitdepth != b->bitdepth) return 0;
if(a->key_defined != b->key_defined) return 0;
if(a->key_defined)
{
if(a->key_r != b->key_r) return 0;
if(a->key_g != b->key_g) return 0;
if(a->key_b != b->key_b) return 0;
}
/*if one of the palette sizes is 0, then we consider it to be the same as the
other: it means that e.g. the palette was not given by the user and should be
considered the same as the palette inside the PNG.*/
if(1/*a->palettesize != 0 && b->palettesize != 0*/) {
if(a->palettesize != b->palettesize) return 0;
for(i = 0; i != a->palettesize * 4; ++i)
{
if(a->palette[i] != b->palette[i]) return 0;
}
}
return 1;
}
void lodepng_palette_clear(LodePNGColorMode* info)
{
if(info->palette) lodepng_free(info->palette);
info->palette = 0;
info->palettesize = 0;
}
unsigned lodepng_palette_add(LodePNGColorMode* info,
unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
unsigned char* data;
/*the same resize technique as C++ std::vectors is used, and here it's made so that for a palette with
the max of 256 colors, it'll have the exact alloc size*/
if(!info->palette) /*allocate palette if empty*/
{
/*room for 256 colors with 4 bytes each*/
data = (unsigned char*)lodepng_realloc(info->palette, 1024);
if(!data) return 83; /*alloc fail*/
else info->palette = data;
}
info->palette[4 * info->palettesize + 0] = r;
info->palette[4 * info->palettesize + 1] = g;
info->palette[4 * info->palettesize + 2] = b;
info->palette[4 * info->palettesize + 3] = a;
++info->palettesize;
return 0;
}
unsigned lodepng_get_bpp(const LodePNGColorMode* info)
{
/*calculate bits per pixel out of colortype and bitdepth*/
return lodepng_get_bpp_lct(info->colortype, info->bitdepth);
}
unsigned lodepng_get_channels(const LodePNGColorMode* info)
{
return getNumColorChannels(info->colortype);
}
unsigned lodepng_is_greyscale_type(const LodePNGColorMode* info)
{
return info->colortype == LCT_GREY || info->colortype == LCT_GREY_ALPHA;
}
unsigned lodepng_is_alpha_type(const LodePNGColorMode* info)
{
return (info->colortype & 4) != 0; /*4 or 6*/
}
unsigned lodepng_is_palette_type(const LodePNGColorMode* info)
{
return info->colortype == LCT_PALETTE;
}
unsigned lodepng_has_palette_alpha(const LodePNGColorMode* info)
{
size_t i;
for(i = 0; i != info->palettesize; ++i)
{
if(info->palette[i * 4 + 3] < 255) return 1;
}
return 0;
}
unsigned lodepng_can_have_alpha(const LodePNGColorMode* info)
{
return info->key_defined
|| lodepng_is_alpha_type(info)
|| lodepng_has_palette_alpha(info);
}
size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color)
{
/*will not overflow for any color type if roughly w * h < 268435455*/
size_t bpp = lodepng_get_bpp(color);
size_t n = w * h;
return ((n / 8) * bpp) + ((n & 7) * bpp + 7) / 8;
}
size_t lodepng_get_raw_size_lct(unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
{
/*will not overflow for any color type if roughly w * h < 268435455*/
size_t bpp = lodepng_get_bpp_lct(colortype, bitdepth);
size_t n = w * h;
return ((n / 8) * bpp) + ((n & 7) * bpp + 7) / 8;
}
#ifdef LODEPNG_COMPILE_PNG
#ifdef LODEPNG_COMPILE_DECODER
/*in an idat chunk, each scanline is a multiple of 8 bits, unlike the lodepng output buffer*/
static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, const LodePNGColorMode* color)
{
/*will not overflow for any color type if roughly w * h < 268435455*/
size_t bpp = lodepng_get_bpp(color);
size_t line = ((w / 8) * bpp) + ((w & 7) * bpp + 7) / 8;
return h * line;
}
#endif /*LODEPNG_COMPILE_DECODER*/
#endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
static void LodePNGUnknownChunks_init(LodePNGInfo* info)
{
unsigned i;
for(i = 0; i != 3; ++i) info->unknown_chunks_data[i] = 0;
for(i = 0; i != 3; ++i) info->unknown_chunks_size[i] = 0;
}
static void LodePNGUnknownChunks_cleanup(LodePNGInfo* info)
{
unsigned i;
for(i = 0; i != 3; ++i) lodepng_free(info->unknown_chunks_data[i]);
}
static unsigned LodePNGUnknownChunks_copy(LodePNGInfo* dest, const LodePNGInfo* src)
{
unsigned i;
LodePNGUnknownChunks_cleanup(dest);
for(i = 0; i != 3; ++i)
{
size_t j;
dest->unknown_chunks_size[i] = src->unknown_chunks_size[i];
dest->unknown_chunks_data[i] = (unsigned char*)lodepng_malloc(src->unknown_chunks_size[i]);
if(!dest->unknown_chunks_data[i] && dest->unknown_chunks_size[i]) return 83; /*alloc fail*/
for(j = 0; j < src->unknown_chunks_size[i]; ++j)
{
dest->unknown_chunks_data[i][j] = src->unknown_chunks_data[i][j];
}
}
return 0;
}
/******************************************************************************/
static void LodePNGText_init(LodePNGInfo* info)
{
info->text_num = 0;
info->text_keys = NULL;
info->text_strings = NULL;
}
static void LodePNGText_cleanup(LodePNGInfo* info)
{
size_t i;
for(i = 0; i != info->text_num; ++i)
{
string_cleanup(&info->text_keys[i]);
string_cleanup(&info->text_strings[i]);
}
lodepng_free(info->text_keys);
lodepng_free(info->text_strings);
}
static unsigned LodePNGText_copy(LodePNGInfo* dest, const LodePNGInfo* source)
{
size_t i = 0;
dest->text_keys = 0;
dest->text_strings = 0;
dest->text_num = 0;
for(i = 0; i != source->text_num; ++i)
{
CERROR_TRY_RETURN(lodepng_add_text(dest, source->text_keys[i], source->text_strings[i]));
}
return 0;
}
void lodepng_clear_text(LodePNGInfo* info)
{
LodePNGText_cleanup(info);
}
unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str)
{
char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1)));
char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num + 1)));
if(!new_keys || !new_strings)
{
lodepng_free(new_keys);
lodepng_free(new_strings);
return 83; /*alloc fail*/
}
++info->text_num;
info->text_keys = new_keys;
info->text_strings = new_strings;
string_init(&info->text_keys[info->text_num - 1]);
string_set(&info->text_keys[info->text_num - 1], key);
string_init(&info->text_strings[info->text_num - 1]);
string_set(&info->text_strings[info->text_num - 1], str);
return 0;
}
/******************************************************************************/
static void LodePNGIText_init(LodePNGInfo* info)
{
info->itext_num = 0;
info->itext_keys = NULL;
info->itext_langtags = NULL;
info->itext_transkeys = NULL;
info->itext_strings = NULL;
}
static void LodePNGIText_cleanup(LodePNGInfo* info)
{
size_t i;
for(i = 0; i != info->itext_num; ++i)
{
string_cleanup(&info->itext_keys[i]);
string_cleanup(&info->itext_langtags[i]);
string_cleanup(&info->itext_transkeys[i]);
string_cleanup(&info->itext_strings[i]);
}
lodepng_free(info->itext_keys);
lodepng_free(info->itext_langtags);
lodepng_free(info->itext_transkeys);
lodepng_free(info->itext_strings);
}
static unsigned LodePNGIText_copy(LodePNGInfo* dest, const LodePNGInfo* source)
{
size_t i = 0;
dest->itext_keys = 0;
dest->itext_langtags = 0;
dest->itext_transkeys = 0;
dest->itext_strings = 0;
dest->itext_num = 0;
for(i = 0; i != source->itext_num; ++i)
{
CERROR_TRY_RETURN(lodepng_add_itext(dest, source->itext_keys[i], source->itext_langtags[i],
source->itext_transkeys[i], source->itext_strings[i]));
}
return 0;
}
void lodepng_clear_itext(LodePNGInfo* info)
{
LodePNGIText_cleanup(info);
}
unsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag,
const char* transkey, const char* str)
{
char** new_keys = (char**)(lodepng_realloc(info->itext_keys, sizeof(char*) * (info->itext_num + 1)));
char** new_langtags = (char**)(lodepng_realloc(info->itext_langtags, sizeof(char*) * (info->itext_num + 1)));
char** new_transkeys = (char**)(lodepng_realloc(info->itext_transkeys, sizeof(char*) * (info->itext_num + 1)));
char** new_strings = (char**)(lodepng_realloc(info->itext_strings, sizeof(char*) * (info->itext_num + 1)));
if(!new_keys || !new_langtags || !new_transkeys || !new_strings)
{
lodepng_free(new_keys);
lodepng_free(new_langtags);
lodepng_free(new_transkeys);
lodepng_free(new_strings);
return 83; /*alloc fail*/
}
++info->itext_num;
info->itext_keys = new_keys;
info->itext_langtags = new_langtags;
info->itext_transkeys = new_transkeys;
info->itext_strings = new_strings;
string_init(&info->itext_keys[info->itext_num - 1]);
string_set(&info->itext_keys[info->itext_num - 1], key);
string_init(&info->itext_langtags[info->itext_num - 1]);
string_set(&info->itext_langtags[info->itext_num - 1], langtag);
string_init(&info->itext_transkeys[info->itext_num - 1]);
string_set(&info->itext_transkeys[info->itext_num - 1], transkey);
string_init(&info->itext_strings[info->itext_num - 1]);
string_set(&info->itext_strings[info->itext_num - 1], str);
return 0;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
void lodepng_info_init(LodePNGInfo* info)
{
lodepng_color_mode_init(&info->color);
info->interlace_method = 0;
info->compression_method = 0;
info->filter_method = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
info->background_defined = 0;
info->background_r = info->background_g = info->background_b = 0;
LodePNGText_init(info);
LodePNGIText_init(info);
info->time_defined = 0;
info->phys_defined = 0;
LodePNGUnknownChunks_init(info);
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
void lodepng_info_cleanup(LodePNGInfo* info)
{
lodepng_color_mode_cleanup(&info->color);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
LodePNGText_cleanup(info);
LodePNGIText_cleanup(info);
LodePNGUnknownChunks_cleanup(info);
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source)
{
lodepng_info_cleanup(dest);
*dest = *source;
lodepng_color_mode_init(&dest->color);
CERROR_TRY_RETURN(lodepng_color_mode_copy(&dest->color, &source->color));
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
CERROR_TRY_RETURN(LodePNGText_copy(dest, source));
CERROR_TRY_RETURN(LodePNGIText_copy(dest, source));
LodePNGUnknownChunks_init(dest);
CERROR_TRY_RETURN(LodePNGUnknownChunks_copy(dest, source));
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
return 0;
}
void lodepng_info_swap(LodePNGInfo* a, LodePNGInfo* b)
{
LodePNGInfo temp = *a;
*a = *b;
*b = temp;
}
/* ////////////////////////////////////////////////////////////////////////// */
/*index: bitgroup index, bits: bitgroup size(1, 2 or 4), in: bitgroup value, out: octet array to add bits to*/
static void addColorBits(unsigned char* out, size_t index, unsigned bits, unsigned in)
{
unsigned m = bits == 1 ? 7 : bits == 2 ? 3 : 1; /*8 / bits - 1*/
/*p = the partial index in the byte, e.g. with 4 palettebits it is 0 for first half or 1 for second half*/
unsigned p = index & m;
in &= (1u << bits) - 1u; /*filter out any other bits of the input value*/
in = in << (bits * (m - p));
if(p == 0) out[index * bits / 8] = (unsigned char)in;
else out[index * bits / 8] |= in;
}
typedef struct ColorTree ColorTree;
/*
One node of a color tree
This is the data structure used to count the number of unique colors and to get a palette
index for a color. It's like an octree, but because the alpha channel is used too, each
node has 16 instead of 8 children.
*/
struct ColorTree
{
ColorTree* children[16]; /*up to 16 pointers to ColorTree of next level*/
int index; /*the payload. Only has a meaningful value if this is in the last level*/
};
static void color_tree_init(ColorTree* tree)
{
int i;
for(i = 0; i != 16; ++i) tree->children[i] = 0;
tree->index = -1;
}
static void color_tree_cleanup(ColorTree* tree)
{
int i;
for(i = 0; i != 16; ++i)
{
if(tree->children[i])
{
color_tree_cleanup(tree->children[i]);
lodepng_free(tree->children[i]);
}
}
}
/*returns -1 if color not present, its index otherwise*/
static int color_tree_get(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
int bit = 0;
for(bit = 0; bit < 8; ++bit)
{
int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
if(!tree->children[i]) return -1;
else tree = tree->children[i];
}
return tree ? tree->index : -1;
}
#ifdef LODEPNG_COMPILE_ENCODER
static int color_tree_has(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
return color_tree_get(tree, r, g, b, a) >= 0;
}
#endif /*LODEPNG_COMPILE_ENCODER*/
/*color is not allowed to already exist.
Index should be >= 0 (it's signed to be compatible with using -1 for "doesn't exist")*/
static void color_tree_add(ColorTree* tree,
unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned index)
{
int bit;
for(bit = 0; bit < 8; ++bit)
{
int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
if(!tree->children[i])
{
tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree));
color_tree_init(tree->children[i]);
}
tree = tree->children[i];
}
tree->index = (int)index;
}
/*put a pixel, given its RGBA color, into image of any color type*/
static unsigned rgba8ToPixel(unsigned char* out, size_t i,
const LodePNGColorMode* mode, ColorTree* tree /*for palette*/,
unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
if(mode->colortype == LCT_GREY)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
if(mode->bitdepth == 8) out[i] = grey;
else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = grey;
else
{
/*take the most significant bits of grey*/
grey = (grey >> (8 - mode->bitdepth)) & ((1 << mode->bitdepth) - 1);
addColorBits(out, i, mode->bitdepth, grey);
}
}
else if(mode->colortype == LCT_RGB)
{
if(mode->bitdepth == 8)
{
out[i * 3 + 0] = r;
out[i * 3 + 1] = g;
out[i * 3 + 2] = b;
}
else
{
out[i * 6 + 0] = out[i * 6 + 1] = r;
out[i * 6 + 2] = out[i * 6 + 3] = g;
out[i * 6 + 4] = out[i * 6 + 5] = b;
}
}
else if(mode->colortype == LCT_PALETTE)
{
int index = color_tree_get(tree, r, g, b, a);
if(index < 0) return 82; /*color not in palette*/
if(mode->bitdepth == 8) out[i] = (unsigned char)index;
else addColorBits(out, i, mode->bitdepth, (unsigned)index);
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
if(mode->bitdepth == 8)
{
out[i * 2 + 0] = grey;
out[i * 2 + 1] = a;
}
else if(mode->bitdepth == 16)
{
out[i * 4 + 0] = out[i * 4 + 1] = grey;
out[i * 4 + 2] = out[i * 4 + 3] = a;
}
}
else if(mode->colortype == LCT_RGBA)
{
if(mode->bitdepth == 8)
{
out[i * 4 + 0] = r;
out[i * 4 + 1] = g;
out[i * 4 + 2] = b;
out[i * 4 + 3] = a;
}
else
{
out[i * 8 + 0] = out[i * 8 + 1] = r;
out[i * 8 + 2] = out[i * 8 + 3] = g;
out[i * 8 + 4] = out[i * 8 + 5] = b;
out[i * 8 + 6] = out[i * 8 + 7] = a;
}
}
return 0; /*no error*/
}
/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
static void rgba16ToPixel(unsigned char* out, size_t i,
const LodePNGColorMode* mode,
unsigned short r, unsigned short g, unsigned short b, unsigned short a)
{
if(mode->colortype == LCT_GREY)
{
unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
out[i * 2 + 0] = (grey >> 8) & 255;
out[i * 2 + 1] = grey & 255;
}
else if(mode->colortype == LCT_RGB)
{
out[i * 6 + 0] = (r >> 8) & 255;
out[i * 6 + 1] = r & 255;
out[i * 6 + 2] = (g >> 8) & 255;
out[i * 6 + 3] = g & 255;
out[i * 6 + 4] = (b >> 8) & 255;
out[i * 6 + 5] = b & 255;
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
out[i * 4 + 0] = (grey >> 8) & 255;
out[i * 4 + 1] = grey & 255;
out[i * 4 + 2] = (a >> 8) & 255;
out[i * 4 + 3] = a & 255;
}
else if(mode->colortype == LCT_RGBA)
{
out[i * 8 + 0] = (r >> 8) & 255;
out[i * 8 + 1] = r & 255;
out[i * 8 + 2] = (g >> 8) & 255;
out[i * 8 + 3] = g & 255;
out[i * 8 + 4] = (b >> 8) & 255;
out[i * 8 + 5] = b & 255;
out[i * 8 + 6] = (a >> 8) & 255;
out[i * 8 + 7] = a & 255;
}
}
/*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/
static void getPixelColorRGBA8(unsigned char* r, unsigned char* g,
unsigned char* b, unsigned char* a,
const unsigned char* in, size_t i,
const LodePNGColorMode* mode)
{
if(mode->colortype == LCT_GREY)
{
if(mode->bitdepth == 8)
{
*r = *g = *b = in[i];
if(mode->key_defined && *r == mode->key_r) *a = 0;
else *a = 255;
}
else if(mode->bitdepth == 16)
{
*r = *g = *b = in[i * 2 + 0];
if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
else *a = 255;
}
else
{
unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/
size_t j = i * mode->bitdepth;
unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);
*r = *g = *b = (unsigned char)((value * 255) / highest);
if(mode->key_defined && value == mode->key_r) *a = 0;
else *a = 255;
}
}
else if(mode->colortype == LCT_RGB)
{
if(mode->bitdepth == 8)
{
*r = in[i * 3 + 0]; *g = in[i * 3 + 1]; *b = in[i * 3 + 2];
if(mode->key_defined && *r == mode->key_r && *g == mode->key_g && *b == mode->key_b) *a = 0;
else *a = 255;
}
else
{
*r = in[i * 6 + 0];
*g = in[i * 6 + 2];
*b = in[i * 6 + 4];
if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
&& 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
&& 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
else *a = 255;
}
}
else if(mode->colortype == LCT_PALETTE)
{
unsigned index;
if(mode->bitdepth == 8) index = in[i];
else
{
size_t j = i * mode->bitdepth;
index = readBitsFromReversedStream(&j, in, mode->bitdepth);
}
if(index >= mode->palettesize)
{
/*This is an error according to the PNG spec, but common PNG decoders make it black instead.
Done here too, slightly faster due to no error handling needed.*/
*r = *g = *b = 0;
*a = 255;
}
else
{
*r = mode->palette[index * 4 + 0];
*g = mode->palette[index * 4 + 1];
*b = mode->palette[index * 4 + 2];
*a = mode->palette[index * 4 + 3];
}
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
if(mode->bitdepth == 8)
{
*r = *g = *b = in[i * 2 + 0];
*a = in[i * 2 + 1];
}
else
{
*r = *g = *b = in[i * 4 + 0];
*a = in[i * 4 + 2];
}
}
else if(mode->colortype == LCT_RGBA)
{
if(mode->bitdepth == 8)
{
*r = in[i * 4 + 0];
*g = in[i * 4 + 1];
*b = in[i * 4 + 2];
*a = in[i * 4 + 3];
}
else
{
*r = in[i * 8 + 0];
*g = in[i * 8 + 2];
*b = in[i * 8 + 4];
*a = in[i * 8 + 6];
}
}
}
/*Similar to getPixelColorRGBA8, but with all the for loops inside of the color
mode test cases, optimized to convert the colors much faster, when converting
to RGBA or RGB with 8 bit per cannel. buffer must be RGBA or RGB output with
enough memory, if has_alpha is true the output is RGBA. mode has the color mode
of the input buffer.*/
static void getPixelColorsRGBA8(unsigned char* buffer, size_t numpixels,
unsigned has_alpha, const unsigned char* in,
const LodePNGColorMode* mode)
{
unsigned num_channels = has_alpha ? 4 : 3;
size_t i;
if(mode->colortype == LCT_GREY)
{
if(mode->bitdepth == 8)
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = buffer[1] = buffer[2] = in[i];
if(has_alpha) buffer[3] = mode->key_defined && in[i] == mode->key_r ? 0 : 255;
}
}
else if(mode->bitdepth == 16)
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = buffer[1] = buffer[2] = in[i * 2];
if(has_alpha) buffer[3] = mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r ? 0 : 255;
}
}
else
{
unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/
size_t j = 0;
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);
buffer[0] = buffer[1] = buffer[2] = (unsigned char)((value * 255) / highest);
if(has_alpha) buffer[3] = mode->key_defined && value == mode->key_r ? 0 : 255;
}
}
}
else if(mode->colortype == LCT_RGB)
{
if(mode->bitdepth == 8)
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = in[i * 3 + 0];
buffer[1] = in[i * 3 + 1];
buffer[2] = in[i * 3 + 2];
if(has_alpha) buffer[3] = mode->key_defined && buffer[0] == mode->key_r
&& buffer[1]== mode->key_g && buffer[2] == mode->key_b ? 0 : 255;
}
}
else
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = in[i * 6 + 0];
buffer[1] = in[i * 6 + 2];
buffer[2] = in[i * 6 + 4];
if(has_alpha) buffer[3] = mode->key_defined
&& 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
&& 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
&& 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b ? 0 : 255;
}
}
}
else if(mode->colortype == LCT_PALETTE)
{
unsigned index;
size_t j = 0;
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
if(mode->bitdepth == 8) index = in[i];
else index = readBitsFromReversedStream(&j, in, mode->bitdepth);
if(index >= mode->palettesize)
{
/*This is an error according to the PNG spec, but most PNG decoders make it black instead.
Done here too, slightly faster due to no error handling needed.*/
buffer[0] = buffer[1] = buffer[2] = 0;
if(has_alpha) buffer[3] = 255;
}
else
{
buffer[0] = mode->palette[index * 4 + 0];
buffer[1] = mode->palette[index * 4 + 1];
buffer[2] = mode->palette[index * 4 + 2];
if(has_alpha) buffer[3] = mode->palette[index * 4 + 3];
}
}
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
if(mode->bitdepth == 8)
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = buffer[1] = buffer[2] = in[i * 2 + 0];
if(has_alpha) buffer[3] = in[i * 2 + 1];
}
}
else
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = buffer[1] = buffer[2] = in[i * 4 + 0];
if(has_alpha) buffer[3] = in[i * 4 + 2];
}
}
}
else if(mode->colortype == LCT_RGBA)
{
if(mode->bitdepth == 8)
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = in[i * 4 + 0];
buffer[1] = in[i * 4 + 1];
buffer[2] = in[i * 4 + 2];
if(has_alpha) buffer[3] = in[i * 4 + 3];
}
}
else
{
for(i = 0; i != numpixels; ++i, buffer += num_channels)
{
buffer[0] = in[i * 8 + 0];
buffer[1] = in[i * 8 + 2];
buffer[2] = in[i * 8 + 4];
if(has_alpha) buffer[3] = in[i * 8 + 6];
}
}
}
}
/*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with
given color type, but the given color type must be 16-bit itself.*/
static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,
const unsigned char* in, size_t i, const LodePNGColorMode* mode)
{
if(mode->colortype == LCT_GREY)
{
*r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];
if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
else *a = 65535;
}
else if(mode->colortype == LCT_RGB)
{
*r = 256u * in[i * 6 + 0] + in[i * 6 + 1];
*g = 256u * in[i * 6 + 2] + in[i * 6 + 3];
*b = 256u * in[i * 6 + 4] + in[i * 6 + 5];
if(mode->key_defined
&& 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
&& 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
&& 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
else *a = 65535;
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
*r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1];
*a = 256u * in[i * 4 + 2] + in[i * 4 + 3];
}
else if(mode->colortype == LCT_RGBA)
{
*r = 256u * in[i * 8 + 0] + in[i * 8 + 1];
*g = 256u * in[i * 8 + 2] + in[i * 8 + 3];
*b = 256u * in[i * 8 + 4] + in[i * 8 + 5];
*a = 256u * in[i * 8 + 6] + in[i * 8 + 7];
}
}
unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,
unsigned w, unsigned h)
{
size_t i;
ColorTree tree;
size_t numpixels = w * h;
unsigned error = 0;
if(lodepng_color_mode_equal(mode_out, mode_in))
{
size_t numbytes = lodepng_get_raw_size(w, h, mode_in);
for(i = 0; i != numbytes; ++i) out[i] = in[i];
return 0;
}
if(mode_out->colortype == LCT_PALETTE)
{
size_t palettesize = mode_out->palettesize;
const unsigned char* palette = mode_out->palette;
size_t palsize = ((size_t)1) << mode_out->bitdepth;
/*if the user specified output palette but did not give the values, assume
they want the values of the input color type (assuming that one is palette).
Note that we never create a new palette ourselves.*/
if(palettesize == 0)
{
palettesize = mode_in->palettesize;
palette = mode_in->palette;
}
if(palettesize < palsize) palsize = palettesize;
color_tree_init(&tree);
for(i = 0; i != palsize; ++i)
{
const unsigned char* p = &palette[i * 4];
color_tree_add(&tree, p[0], p[1], p[2], p[3], (unsigned int)i);
}
}
if(mode_in->bitdepth == 16 && mode_out->bitdepth == 16)
{
for(i = 0; i != numpixels; ++i)
{
unsigned short r = 0, g = 0, b = 0, a = 0;
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
rgba16ToPixel(out, i, mode_out, r, g, b, a);
}
}
else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGBA)
{
getPixelColorsRGBA8(out, numpixels, 1, in, mode_in);
}
else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGB)
{
getPixelColorsRGBA8(out, numpixels, 0, in, mode_in);
}
else
{
unsigned char r = 0, g = 0, b = 0, a = 0;
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
error = rgba8ToPixel(out, i, mode_out, &tree, r, g, b, a);
if (error) break;
}
}
if(mode_out->colortype == LCT_PALETTE)
{
color_tree_cleanup(&tree);
}
return error;
}
#ifdef LODEPNG_COMPILE_ENCODER
void lodepng_color_profile_init(LodePNGColorProfile* profile)
{
profile->colored = 0;
profile->key = 0;
profile->key_r = profile->key_g = profile->key_b = 0;
profile->alpha = 0;
profile->numcolors = 0;
profile->bits = 1;
}
/*function used for debug purposes with C++*/
/*void printColorProfile(LodePNGColorProfile* p)
{
std::cout << "colored: " << (int)p->colored << ", ";
std::cout << "key: " << (int)p->key << ", ";
std::cout << "key_r: " << (int)p->key_r << ", ";
std::cout << "key_g: " << (int)p->key_g << ", ";
std::cout << "key_b: " << (int)p->key_b << ", ";
std::cout << "alpha: " << (int)p->alpha << ", ";
std::cout << "numcolors: " << (int)p->numcolors << ", ";
std::cout << "bits: " << (int)p->bits << std::endl;
}*/
/*Returns how many bits needed to represent given value (max 8 bit)*/
static unsigned getValueRequiredBits(unsigned char value)
{
if(value == 0 || value == 255) return 1;
/*The scaling of 2-bit and 4-bit values uses multiples of 85 and 17*/
if(value % 17 == 0) return value % 85 == 0 ? 2 : 4;
return 8;
}
/*profile must already have been inited with mode.
It's ok to set some parameters of profile to done already.*/
unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
const unsigned char* in, unsigned w, unsigned h,
const LodePNGColorMode* mode)
{
unsigned error = 0;
size_t i;
ColorTree tree;
size_t numpixels = w * h;
unsigned colored_done = lodepng_is_greyscale_type(mode) ? 1 : 0;
unsigned alpha_done = lodepng_can_have_alpha(mode) ? 0 : 1;
unsigned numcolors_done = 0;
unsigned bpp = lodepng_get_bpp(mode);
unsigned bits_done = bpp == 1 ? 1 : 0;
unsigned maxnumcolors = 257;
unsigned sixteen = 0;
if(bpp <= 8) maxnumcolors = bpp == 1 ? 2 : (bpp == 2 ? 4 : (bpp == 4 ? 16 : 256));
color_tree_init(&tree);
/*Check if the 16-bit input is truly 16-bit*/
if(mode->bitdepth == 16)
{
unsigned short r, g, b, a;
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
if((r & 255) != ((r >> 8) & 255) || (g & 255) != ((g >> 8) & 255) ||
(b & 255) != ((b >> 8) & 255) || (a & 255) != ((a >> 8) & 255)) /*first and second byte differ*/
{
sixteen = 1;
break;
}
}
}
if(sixteen)
{
unsigned short r = 0, g = 0, b = 0, a = 0;
profile->bits = 16;
bits_done = numcolors_done = 1; /*counting colors no longer useful, palette doesn't support 16-bit*/
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
if(!colored_done && (r != g || r != b))
{
profile->colored = 1;
colored_done = 1;
}
if(!alpha_done)
{
unsigned matchkey = (r == profile->key_r && g == profile->key_g && b == profile->key_b);
if(a != 65535 && (a != 0 || (profile->key && !matchkey)))
{
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
}
else if(a == 0 && !profile->alpha && !profile->key)
{
profile->key = 1;
profile->key_r = r;
profile->key_g = g;
profile->key_b = b;
}
else if(a == 65535 && profile->key && matchkey)
{
/* Color key cannot be used if an opaque pixel also has that RGB color. */
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
}
}
if(alpha_done && numcolors_done && colored_done && bits_done) break;
}
if(profile->key && !profile->alpha)
{
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
if(a != 0 && r == profile->key_r && g == profile->key_g && b == profile->key_b)
{
/* Color key cannot be used if an opaque pixel also has that RGB color. */
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
}
}
}
}
else /* < 16-bit */
{
unsigned char r = 0, g = 0, b = 0, a = 0;
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode);
if(!bits_done && profile->bits < 8)
{
/*only r is checked, < 8 bits is only relevant for greyscale*/
unsigned bits = getValueRequiredBits(r);
if(bits > profile->bits) profile->bits = bits;
}
bits_done = (profile->bits >= bpp);
if(!colored_done && (r != g || r != b))
{
profile->colored = 1;
colored_done = 1;
if(profile->bits < 8) profile->bits = 8; /*PNG has no colored modes with less than 8-bit per channel*/
}
if(!alpha_done)
{
unsigned matchkey = (r == profile->key_r && g == profile->key_g && b == profile->key_b);
if(a != 255 && (a != 0 || (profile->key && !matchkey)))
{
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
}
else if(a == 0 && !profile->alpha && !profile->key)
{
profile->key = 1;
profile->key_r = r;
profile->key_g = g;
profile->key_b = b;
}
else if(a == 255 && profile->key && matchkey)
{
/* Color key cannot be used if an opaque pixel also has that RGB color. */
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
}
}
if(!numcolors_done)
{
if(!color_tree_has(&tree, r, g, b, a))
{
color_tree_add(&tree, r, g, b, a, profile->numcolors);
if(profile->numcolors < 256)
{
unsigned char* p = profile->palette;
unsigned n = profile->numcolors;
p[n * 4 + 0] = r;
p[n * 4 + 1] = g;
p[n * 4 + 2] = b;
p[n * 4 + 3] = a;
}
++profile->numcolors;
numcolors_done = profile->numcolors >= maxnumcolors;
}
}
if(alpha_done && numcolors_done && colored_done && bits_done) break;
}
if(profile->key && !profile->alpha)
{
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode);
if(a != 0 && r == profile->key_r && g == profile->key_g && b == profile->key_b)
{
/* Color key cannot be used if an opaque pixel also has that RGB color. */
profile->alpha = 1;
profile->key = 0;
alpha_done = 1;
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
}
}
}
/*make the profile's key always 16-bit for consistency - repeat each byte twice*/
profile->key_r += (profile->key_r << 8);
profile->key_g += (profile->key_g << 8);
profile->key_b += (profile->key_b << 8);
}
color_tree_cleanup(&tree);
return error;
}
/*Automatically chooses color type that gives smallest amount of bits in the
output image, e.g. grey if there are only greyscale pixels, palette if there
are less than 256 colors, ...
Updates values of mode with a potentially smaller color model. mode_out should
contain the user chosen color model, but will be overwritten with the new chosen one.*/
unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
const unsigned char* image, unsigned w, unsigned h,
const LodePNGColorMode* mode_in)
{
LodePNGColorProfile prof;
unsigned error = 0;
unsigned i, n, palettebits, palette_ok;
lodepng_color_profile_init(&prof);
error = lodepng_get_color_profile(&prof, image, w, h, mode_in);
if(error) return error;
mode_out->key_defined = 0;
if(prof.key && w * h <= 16)
{
prof.alpha = 1; /*too few pixels to justify tRNS chunk overhead*/
prof.key = 0;
if(prof.bits < 8) prof.bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
}
n = prof.numcolors;
palettebits = n <= 2 ? 1 : (n <= 4 ? 2 : (n <= 16 ? 4 : 8));
palette_ok = n <= 256 && prof.bits <= 8;
if(w * h < n * 2) palette_ok = 0; /*don't add palette overhead if image has only a few pixels*/
if(!prof.colored && prof.bits <= palettebits) palette_ok = 0; /*grey is less overhead*/
if(palette_ok)
{
unsigned char* p = prof.palette;
lodepng_palette_clear(mode_out); /*remove potential earlier palette*/
for(i = 0; i != prof.numcolors; ++i)
{
error = lodepng_palette_add(mode_out, p[i * 4 + 0], p[i * 4 + 1], p[i * 4 + 2], p[i * 4 + 3]);
if(error) break;
}
mode_out->colortype = LCT_PALETTE;
mode_out->bitdepth = palettebits;
if(mode_in->colortype == LCT_PALETTE && mode_in->palettesize >= mode_out->palettesize
&& mode_in->bitdepth == mode_out->bitdepth)
{
/*If input should have same palette colors, keep original to preserve its order and prevent conversion*/
lodepng_color_mode_cleanup(mode_out);
lodepng_color_mode_copy(mode_out, mode_in);
}
}
else /*8-bit or 16-bit per channel*/
{
mode_out->bitdepth = prof.bits;
mode_out->colortype = prof.alpha ? (prof.colored ? LCT_RGBA : LCT_GREY_ALPHA)
: (prof.colored ? LCT_RGB : LCT_GREY);
if(prof.key)
{
unsigned mask = (1u << mode_out->bitdepth) - 1u; /*profile always uses 16-bit, mask converts it*/
mode_out->key_r = prof.key_r & mask;
mode_out->key_g = prof.key_g & mask;
mode_out->key_b = prof.key_b & mask;
mode_out->key_defined = 1;
}
}
return error;
}
#endif /* #ifdef LODEPNG_COMPILE_ENCODER */
/*
Paeth predicter, used by PNG filter type 4
The parameters are of type short, but should come from unsigned chars, the shorts
are only needed to make the paeth calculation correct.
*/
static unsigned char paethPredictor(short a, short b, short c)
{
short pa = (short)abs(b - c);
short pb = (short)abs(a - c);
short pc = (short)abs(a + b - c - c);
if(pc < pa && pc < pb) return (unsigned char)c;
else if(pb < pa) return (unsigned char)b;
else return (unsigned char)a;
}
/*shared values used by multiple Adam7 related functions*/
static const unsigned ADAM7_IX[7] = { 0, 4, 0, 2, 0, 1, 0 }; /*x start values*/
static const unsigned ADAM7_IY[7] = { 0, 0, 4, 0, 2, 0, 1 }; /*y start values*/
static const unsigned ADAM7_DX[7] = { 8, 8, 4, 4, 2, 2, 1 }; /*x delta values*/
static const unsigned ADAM7_DY[7] = { 8, 8, 8, 4, 4, 2, 2 }; /*y delta values*/
/*
Outputs various dimensions and positions in the image related to the Adam7 reduced images.
passw: output containing the width of the 7 passes
passh: output containing the height of the 7 passes
filter_passstart: output containing the index of the start and end of each
reduced image with filter bytes
padded_passstart output containing the index of the start and end of each
reduced image when without filter bytes but with padded scanlines
passstart: output containing the index of the start and end of each reduced
image without padding between scanlines, but still padding between the images
w, h: width and height of non-interlaced image
bpp: bits per pixel
"padded" is only relevant if bpp is less than 8 and a scanline or image does not
end at a full byte
*/
static void Adam7_getpassvalues(unsigned passw[7], unsigned passh[7], size_t filter_passstart[8],
size_t padded_passstart[8], size_t passstart[8], unsigned w, unsigned h, unsigned bpp)
{
/*the passstart values have 8 values: the 8th one indicates the byte after the end of the 7th (= last) pass*/
unsigned i;
/*calculate width and height in pixels of each pass*/
for(i = 0; i != 7; ++i)
{
passw[i] = (w + ADAM7_DX[i] - ADAM7_IX[i] - 1) / ADAM7_DX[i];
passh[i] = (h + ADAM7_DY[i] - ADAM7_IY[i] - 1) / ADAM7_DY[i];
if(passw[i] == 0) passh[i] = 0;
if(passh[i] == 0) passw[i] = 0;
}
filter_passstart[0] = padded_passstart[0] = passstart[0] = 0;
for(i = 0; i != 7; ++i)
{
/*if passw[i] is 0, it's 0 bytes, not 1 (no filtertype-byte)*/
filter_passstart[i + 1] = filter_passstart[i]
+ ((passw[i] && passh[i]) ? passh[i] * (1 + (passw[i] * bpp + 7) / 8) : 0);
/*bits padded if needed to fill full byte at end of each scanline*/
padded_passstart[i + 1] = padded_passstart[i] + passh[i] * ((passw[i] * bpp + 7) / 8);
/*only padded at end of reduced image*/
passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7) / 8;
}
}
#ifdef LODEPNG_COMPILE_DECODER
/* ////////////////////////////////////////////////////////////////////////// */
/* / PNG Decoder / */
/* ////////////////////////////////////////////////////////////////////////// */
/*read the information from the header and store it in the LodePNGInfo. return value is error*/
unsigned lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state,
const unsigned char* in, size_t insize)
{
LodePNGInfo* info = &state->info_png;
if(insize == 0 || in == 0)
{
CERROR_RETURN_ERROR(state->error, 48); /*error: the given data is empty*/
}
if(insize < 33)
{
CERROR_RETURN_ERROR(state->error, 27); /*error: the data length is smaller than the length of a PNG header*/
}
/*when decoding a new PNG image, make sure all parameters created after previous decoding are reset*/
lodepng_info_cleanup(info);
lodepng_info_init(info);
if(in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71
|| in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10)
{
CERROR_RETURN_ERROR(state->error, 28); /*error: the first 8 bytes are not the correct PNG signature*/
}
if(lodepng_chunk_length(in + 8) != 13)
{
CERROR_RETURN_ERROR(state->error, 94); /*error: header size must be 13 bytes*/
}
if(!lodepng_chunk_type_equals(in + 8, "IHDR"))
{
CERROR_RETURN_ERROR(state->error, 29); /*error: it doesn't start with a IHDR chunk!*/
}
/*read the values given in the header*/
*w = lodepng_read32bitInt(&in[16]);
*h = lodepng_read32bitInt(&in[20]);
info->color.bitdepth = in[24];
info->color.colortype = (LodePNGColorType)in[25];
info->compression_method = in[26];
info->filter_method = in[27];
info->interlace_method = in[28];
if(*w == 0 || *h == 0)
{
CERROR_RETURN_ERROR(state->error, 93);
}
if(!state->decoder.ignore_crc)
{
unsigned CRC = lodepng_read32bitInt(&in[29]);
unsigned checksum = lodepng_crc32(&in[12], 17);
if(CRC != checksum)
{
CERROR_RETURN_ERROR(state->error, 57); /*invalid CRC*/
}
}
/*error: only compression method 0 is allowed in the specification*/
if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32);
/*error: only filter method 0 is allowed in the specification*/
if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33);
/*error: only interlace methods 0 and 1 exist in the specification*/
if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34);
state->error = checkColorValidity(info->color.colortype, info->color.bitdepth);
return state->error;
}
static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scanline, const unsigned char* precon,
size_t bytewidth, unsigned char filterType, size_t length)
{
/*
For PNG filter method 0
unfilter a PNG image scanline by scanline. when the pixels are smaller than 1 byte,
the filter works byte per byte (bytewidth = 1)
precon is the previous unfiltered scanline, recon the result, scanline the current one
the incoming scanlines do NOT include the filtertype byte, that one is given in the parameter filterType instead
recon and scanline MAY be the same memory address! precon must be disjoint.
*/
size_t i;
switch(filterType)
{
case 0:
for(i = 0; i != length; ++i) recon[i] = scanline[i];
break;
case 1:
for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i];
for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + recon[i - bytewidth];
break;
case 2:
if(precon)
{
for(i = 0; i != length; ++i) recon[i] = scanline[i] + precon[i];
}
else
{
for(i = 0; i != length; ++i) recon[i] = scanline[i];
}
break;
case 3:
if(precon)
{
for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i] + (precon[i] >> 1);
for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) >> 1);
}
else
{
for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i];
for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + (recon[i - bytewidth] >> 1);
}
break;
case 4:
if(precon)
{
for(i = 0; i != bytewidth; ++i)
{
recon[i] = (scanline[i] + precon[i]); /*paethPredictor(0, precon[i], 0) is always precon[i]*/
}
for(i = bytewidth; i < length; ++i)
{
recon[i] = (scanline[i] + paethPredictor(recon[i - bytewidth], precon[i], precon[i - bytewidth]));
}
}
else
{
for(i = 0; i != bytewidth; ++i)
{
recon[i] = scanline[i];
}
for(i = bytewidth; i < length; ++i)
{
/*paethPredictor(recon[i - bytewidth], 0, 0) is always recon[i - bytewidth]*/
recon[i] = (scanline[i] + recon[i - bytewidth]);
}
}
break;
default: return 36; /*error: unexisting filter type given*/
}
return 0;
}
static unsigned unfilter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)
{
/*
For PNG filter method 0
this function unfilters a single image (e.g. without interlacing this is called once, with Adam7 seven times)
out must have enough bytes allocated already, in must have the scanlines + 1 filtertype byte per scanline
w and h are image dimensions or dimensions of reduced image, bpp is bits per pixel
in and out are allowed to be the same memory address (but aren't the same size since in has the extra filter bytes)
*/
unsigned y;
unsigned char* prevline = 0;
/*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/
size_t bytewidth = (bpp + 7) / 8;
size_t linebytes = (w * bpp + 7) / 8;
for(y = 0; y < h; ++y)
{
size_t outindex = linebytes * y;
size_t inindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
unsigned char filterType = in[inindex];
CERROR_TRY_RETURN(unfilterScanline(&out[outindex], &in[inindex + 1], prevline, bytewidth, filterType, linebytes));
prevline = &out[outindex];
}
return 0;
}
/*
in: Adam7 interlaced image, with no padding bits between scanlines, but between
reduced images so that each reduced image starts at a byte.
out: the same pixels, but re-ordered so that they're now a non-interlaced image with size w*h
bpp: bits per pixel
out has the following size in bits: w * h * bpp.
in is possibly bigger due to padding bits between reduced images.
out must be big enough AND must be 0 everywhere if bpp < 8 in the current implementation
(because that's likely a little bit faster)
NOTE: comments about padding bits are only relevant if bpp < 8
*/
static void Adam7_deinterlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)
{
unsigned passw[7], passh[7];
size_t filter_passstart[8], padded_passstart[8], passstart[8];
unsigned i;
Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
if(bpp >= 8)
{
for(i = 0; i != 7; ++i)
{
unsigned x, y, b;
size_t bytewidth = bpp / 8;
for(y = 0; y < passh[i]; ++y)
for(x = 0; x < passw[i]; ++x)
{
size_t pixelinstart = passstart[i] + (y * passw[i] + x) * bytewidth;
size_t pixeloutstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w + ADAM7_IX[i] + x * ADAM7_DX[i]) * bytewidth;
for(b = 0; b < bytewidth; ++b)
{
out[pixeloutstart + b] = in[pixelinstart + b];
}
}
}
}
else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/
{
for(i = 0; i != 7; ++i)
{
unsigned x, y, b;
unsigned ilinebits = bpp * passw[i];
unsigned olinebits = bpp * w;
size_t obp, ibp; /*bit pointers (for out and in buffer)*/
for(y = 0; y < passh[i]; ++y)
for(x = 0; x < passw[i]; ++x)
{
ibp = (8 * passstart[i]) + (y * ilinebits + x * bpp);
obp = (ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp;
for(b = 0; b < bpp; ++b)
{
unsigned char bit = readBitFromReversedStream(&ibp, in);
/*note that this function assumes the out buffer is completely 0, use setBitOfReversedStream otherwise*/
setBitOfReversedStream0(&obp, out, bit);
}
}
}
}
}
static void removePaddingBits(unsigned char* out, const unsigned char* in,
size_t olinebits, size_t ilinebits, unsigned h)
{
/*
After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
for the Adam7 code, the color convert code and the output to the user.
in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
only useful if (ilinebits - olinebits) is a value in the range 1..7
*/
unsigned y;
size_t diff = ilinebits - olinebits;
size_t ibp = 0, obp = 0; /*input and output bit pointers*/
for(y = 0; y < h; ++y)
{
size_t x;
for(x = 0; x < olinebits; ++x)
{
unsigned char bit = readBitFromReversedStream(&ibp, in);
setBitOfReversedStream(&obp, out, bit);
}
ibp += diff;
}
}
/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
the IDAT chunks (with filter index bytes and possible padding bits)
return value is error*/
static unsigned postProcessScanlines(unsigned char* out, unsigned char* in,
unsigned w, unsigned h, const LodePNGInfo* info_png)
{
/*
This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
Steps:
*) if no Adam7: 1) unfilter 2) remove padding bits (= posible extra bits per scanline if bpp < 8)
*) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) Adam7_deinterlace
NOTE: the in buffer will be overwritten with intermediate data!
*/
unsigned bpp = lodepng_get_bpp(&info_png->color);
if(bpp == 0) return 31; /*error: invalid colortype*/
if(info_png->interlace_method == 0)
{
if(bpp < 8 && w * bpp != ((w * bpp + 7) / 8) * 8)
{
CERROR_TRY_RETURN(unfilter(in, in, w, h, bpp));
removePaddingBits(out, in, w * bpp, ((w * bpp + 7) / 8) * 8, h);
}
/*we can immediately filter into the out buffer, no other steps needed*/
else CERROR_TRY_RETURN(unfilter(out, in, w, h, bpp));
}
else /*interlace_method is 1 (Adam7)*/
{
unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];
unsigned i;
Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
for(i = 0; i != 7; ++i)
{
CERROR_TRY_RETURN(unfilter(&in[padded_passstart[i]], &in[filter_passstart[i]], passw[i], passh[i], bpp));
/*TODO: possible efficiency improvement: if in this reduced image the bits fit nicely in 1 scanline,
move bytes instead of bits or move not at all*/
if(bpp < 8)
{
/*remove padding bits in scanlines; after this there still may be padding
bits between the different reduced images: each reduced image still starts nicely at a byte*/
removePaddingBits(&in[passstart[i]], &in[padded_passstart[i]], passw[i] * bpp,
((passw[i] * bpp + 7) / 8) * 8, passh[i]);
}
}
Adam7_deinterlace(out, in, w, h, bpp);
}
return 0;
}
static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
{
unsigned pos = 0, i;
if(color->palette) lodepng_free(color->palette);
color->palettesize = chunkLength / 3;
color->palette = (unsigned char*)lodepng_malloc(4 * color->palettesize);
if(!color->palette && color->palettesize)
{
color->palettesize = 0;
return 83; /*alloc fail*/
}
if(color->palettesize > 256) return 38; /*error: palette too big*/
for(i = 0; i != color->palettesize; ++i)
{
color->palette[4 * i + 0] = data[pos++]; /*R*/
color->palette[4 * i + 1] = data[pos++]; /*G*/
color->palette[4 * i + 2] = data[pos++]; /*B*/
color->palette[4 * i + 3] = 255; /*alpha*/
}
return 0; /* OK */
}
static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
{
unsigned i;
if(color->colortype == LCT_PALETTE)
{
/*error: more alpha values given than there are palette entries*/
if(chunkLength > color->palettesize) return 38;
for(i = 0; i != chunkLength; ++i) color->palette[4 * i + 3] = data[i];
}
else if(color->colortype == LCT_GREY)
{
/*error: this chunk must be 2 bytes for greyscale image*/
if(chunkLength != 2) return 30;
color->key_defined = 1;
color->key_r = color->key_g = color->key_b = 256u * data[0] + data[1];
}
else if(color->colortype == LCT_RGB)
{
/*error: this chunk must be 6 bytes for RGB image*/
if(chunkLength != 6) return 41;
color->key_defined = 1;
color->key_r = 256u * data[0] + data[1];
color->key_g = 256u * data[2] + data[3];
color->key_b = 256u * data[4] + data[5];
}
else return 42; /*error: tRNS chunk not allowed for other color models*/
return 0; /* OK */
}
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*background color chunk (bKGD)*/
static unsigned readChunk_bKGD(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
if(info->color.colortype == LCT_PALETTE)
{
/*error: this chunk must be 1 byte for indexed color image*/
if(chunkLength != 1) return 43;
info->background_defined = 1;
info->background_r = info->background_g = info->background_b = data[0];
}
else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
{
/*error: this chunk must be 2 bytes for greyscale image*/
if(chunkLength != 2) return 44;
info->background_defined = 1;
info->background_r = info->background_g = info->background_b = 256u * data[0] + data[1];
}
else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
{
/*error: this chunk must be 6 bytes for greyscale image*/
if(chunkLength != 6) return 45;
info->background_defined = 1;
info->background_r = 256u * data[0] + data[1];
info->background_g = 256u * data[2] + data[3];
info->background_b = 256u * data[4] + data[5];
}
return 0; /* OK */
}
/*text chunk (tEXt)*/
static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
unsigned error = 0;
char *key = 0, *str = 0;
unsigned i;
while(!error) /*not really a while loop, only used to break on error*/
{
unsigned length, string2_begin;
length = 0;
while(length < chunkLength && data[length] != 0) ++length;
/*even though it's not allowed by the standard, no error is thrown if
there's no null termination char, if the text is empty*/
if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
key = (char*)lodepng_malloc(length + 1);
if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
key[length] = 0;
for(i = 0; i != length; ++i) key[i] = (char)data[i];
string2_begin = length + 1; /*skip keyword null terminator*/
length = chunkLength < (size_t)string2_begin ? 0 : (unsigned int)(chunkLength - string2_begin);
str = (char*)lodepng_malloc(length + 1);
if(!str) CERROR_BREAK(error, 83); /*alloc fail*/
str[length] = 0;
for(i = 0; i != length; ++i) str[i] = (char)data[string2_begin + i];
error = lodepng_add_text(info, key, str);
break;
}
lodepng_free(key);
lodepng_free(str);
return error;
}
/*compressed text chunk (zTXt)*/
static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,
const unsigned char* data, size_t chunkLength)
{
unsigned error = 0;
unsigned i;
unsigned length, string2_begin;
char *key = 0;
ucvector decoded;
ucvector_init(&decoded);
while(!error) /*not really a while loop, only used to break on error*/
{
for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
if(length + 2 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/
if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
key = (char*)lodepng_malloc(length + 1);
if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
key[length] = 0;
for(i = 0; i != length; ++i) key[i] = (char)data[i];
if(data[length + 1] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/
string2_begin = length + 2;
if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/
length = (unsigned int)(chunkLength - string2_begin);
/*will fail if zlib error, e.g. if length is too small*/
error = zlib_decompress(&decoded.data, &decoded.size,
(unsigned char*)(&data[string2_begin]),
length, zlibsettings);
if(error) break;
ucvector_push_back(&decoded, 0);
error = lodepng_add_text(info, key, (char*)decoded.data);
break;
}
lodepng_free(key);
ucvector_cleanup(&decoded);
return error;
}
/*international text chunk (iTXt)*/
static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,
const unsigned char* data, size_t chunkLength)
{
unsigned error = 0;
unsigned i;
unsigned length, begin, compressed;
char *key = 0, *langtag = 0, *transkey = 0;
ucvector decoded;
ucvector_init(&decoded);
while(!error) /*not really a while loop, only used to break on error*/
{
/*Quick check if the chunk length isn't too small. Even without check
it'd still fail with other error checks below if it's too short. This just gives a different error code.*/
if(chunkLength < 5) CERROR_BREAK(error, 30); /*iTXt chunk too short*/
/*read the key*/
for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
if(length + 3 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination char, corrupt?*/
if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
key = (char*)lodepng_malloc(length + 1);
if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
key[length] = 0;
for(i = 0; i != length; ++i) key[i] = (char)data[i];
/*read the compression method*/
compressed = data[length + 1];
if(data[length + 2] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/
/*even though it's not allowed by the standard, no error is thrown if
there's no null termination char, if the text is empty for the next 3 texts*/
/*read the langtag*/
begin = length + 3;
length = 0;
for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;
langtag = (char*)lodepng_malloc(length + 1);
if(!langtag) CERROR_BREAK(error, 83); /*alloc fail*/
langtag[length] = 0;
for(i = 0; i != length; ++i) langtag[i] = (char)data[begin + i];
/*read the transkey*/
begin += length + 1;
length = 0;
for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;
transkey = (char*)lodepng_malloc(length + 1);
if(!transkey) CERROR_BREAK(error, 83); /*alloc fail*/
transkey[length] = 0;
for(i = 0; i != length; ++i) transkey[i] = (char)data[begin + i];
/*read the actual text*/
begin += length + 1;
length = chunkLength < (size_t)begin ? 0 : (unsigned int)(chunkLength - begin);
if(compressed)
{
/*will fail if zlib error, e.g. if length is too small*/
error = zlib_decompress(&decoded.data, &decoded.size,
(unsigned char*)(&data[begin]),
length, zlibsettings);
if(error) break;
if(decoded.allocsize < decoded.size) decoded.allocsize = decoded.size;
ucvector_push_back(&decoded, 0);
}
else
{
if(!ucvector_resize(&decoded, length + 1)) CERROR_BREAK(error, 83 /*alloc fail*/);
decoded.data[length] = 0;
for(i = 0; i != length; ++i) decoded.data[i] = data[begin + i];
}
error = lodepng_add_itext(info, key, langtag, transkey, (char*)decoded.data);
break;
}
lodepng_free(key);
lodepng_free(langtag);
lodepng_free(transkey);
ucvector_cleanup(&decoded);
return error;
}
static unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
if(chunkLength != 7) return 73; /*invalid tIME chunk size*/
info->time_defined = 1;
info->time.year = 256u * data[0] + data[1];
info->time.month = data[2];
info->time.day = data[3];
info->time.hour = data[4];
info->time.minute = data[5];
info->time.second = data[6];
return 0; /* OK */
}
static unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)
{
if(chunkLength != 9) return 74; /*invalid pHYs chunk size*/
info->phys_defined = 1;
info->phys_x = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3];
info->phys_y = 16777216u * data[4] + 65536u * data[5] + 256u * data[6] + data[7];
info->phys_unit = data[8];
return 0; /* OK */
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*read a PNG, the result will be in the same color type as the PNG (hence "generic")*/
static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,
LodePNGState* state,
const unsigned char* in, size_t insize)
{
unsigned char IEND = 0;
const unsigned char* chunk;
size_t i;
ucvector idat; /*the data from idat chunks*/
ucvector scanlines;
size_t predict;
size_t numpixels;
size_t outsize = 0;
/*for unknown chunk order*/
unsigned unknown = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
unsigned critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*provide some proper output values if error will happen*/
*out = 0;
state->error = lodepng_inspect(w, h, state, in, insize); /*reads header and resets other parameters in state->info_png*/
if(state->error) return;
numpixels = *w * *h;
/*multiplication overflow*/
if(*h != 0 && numpixels / *h != *w) CERROR_RETURN(state->error, 92);
/*multiplication overflow possible further below. Allows up to 2^31-1 pixel
bytes with 16-bit RGBA, the rest is room for filter bytes.*/
if(numpixels > 268435455) CERROR_RETURN(state->error, 92);
ucvector_init(&idat);
chunk = &in[33]; /*first byte of the first chunk after the header*/
/*loop through the chunks, ignoring unknown chunks and stopping at IEND chunk.
IDAT data is put at the start of the in buffer*/
while(!IEND && !state->error)
{
unsigned chunkLength;
const unsigned char* data; /*the data in the chunk*/
/*error: size of the in buffer too small to contain next chunk*/
if((size_t)((chunk - in) + 12) > insize || chunk < in) CERROR_BREAK(state->error, 30);
/*length of the data of the chunk, excluding the length bytes, chunk type and CRC bytes*/
chunkLength = lodepng_chunk_length(chunk);
/*error: chunk length larger than the max PNG chunk size*/
if(chunkLength > 2147483647) CERROR_BREAK(state->error, 63);
if((size_t)((chunk - in) + chunkLength + 12) > insize || (chunk + chunkLength + 12) < in)
{
CERROR_BREAK(state->error, 64); /*error: size of the in buffer too small to contain next chunk*/
}
data = lodepng_chunk_data_const(chunk);
/*IDAT chunk, containing compressed image data*/
if(lodepng_chunk_type_equals(chunk, "IDAT"))
{
size_t oldsize = idat.size;
if(!ucvector_resize(&idat, oldsize + chunkLength)) CERROR_BREAK(state->error, 83 /*alloc fail*/);
for(i = 0; i != chunkLength; ++i) idat.data[oldsize + i] = data[i];
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
critical_pos = 3;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
/*IEND chunk*/
else if(lodepng_chunk_type_equals(chunk, "IEND"))
{
IEND = 1;
}
/*palette chunk (PLTE)*/
else if(lodepng_chunk_type_equals(chunk, "PLTE"))
{
state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
if(state->error) break;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
critical_pos = 2;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
/*palette transparency chunk (tRNS)*/
else if(lodepng_chunk_type_equals(chunk, "tRNS"))
{
state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
if(state->error) break;
}
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*background color chunk (bKGD)*/
else if(lodepng_chunk_type_equals(chunk, "bKGD"))
{
state->error = readChunk_bKGD(&state->info_png, data, chunkLength);
if(state->error) break;
}
/*text chunk (tEXt)*/
else if(lodepng_chunk_type_equals(chunk, "tEXt"))
{
if(state->decoder.read_text_chunks)
{
state->error = readChunk_tEXt(&state->info_png, data, chunkLength);
if(state->error) break;
}
}
/*compressed text chunk (zTXt)*/
else if(lodepng_chunk_type_equals(chunk, "zTXt"))
{
if(state->decoder.read_text_chunks)
{
state->error = readChunk_zTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);
if(state->error) break;
}
}
/*international text chunk (iTXt)*/
else if(lodepng_chunk_type_equals(chunk, "iTXt"))
{
if(state->decoder.read_text_chunks)
{
state->error = readChunk_iTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);
if(state->error) break;
}
}
else if(lodepng_chunk_type_equals(chunk, "tIME"))
{
state->error = readChunk_tIME(&state->info_png, data, chunkLength);
if(state->error) break;
}
else if(lodepng_chunk_type_equals(chunk, "pHYs"))
{
state->error = readChunk_pHYs(&state->info_png, data, chunkLength);
if(state->error) break;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
else /*it's not an implemented chunk type, so ignore it: skip over the data*/
{
/*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/
if(!lodepng_chunk_ancillary(chunk)) CERROR_BREAK(state->error, 69);
unknown = 1;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
if(state->decoder.remember_unknown_chunks)
{
state->error = lodepng_chunk_append(&state->info_png.unknown_chunks_data[critical_pos - 1],
&state->info_png.unknown_chunks_size[critical_pos - 1], chunk);
if(state->error) break;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
if(!state->decoder.ignore_crc && !unknown) /*check CRC if wanted, only on known chunk types*/
{
if(lodepng_chunk_check_crc(chunk)) CERROR_BREAK(state->error, 57); /*invalid CRC*/
}
if(!IEND) chunk = lodepng_chunk_next_const(chunk);
}
ucvector_init(&scanlines);
/*predict output size, to allocate exact size for output buffer to avoid more dynamic allocation.
If the decompressed size does not match the prediction, the image must be corrupt.*/
if(state->info_png.interlace_method == 0)
{
/*The extra *h is added because this are the filter bytes every scanline starts with*/
predict = lodepng_get_raw_size_idat(*w, *h, &state->info_png.color) + *h;
}
else
{
/*Adam-7 interlaced: predicted size is the sum of the 7 sub-images sizes*/
const LodePNGColorMode* color = &state->info_png.color;
predict = 0;
predict += lodepng_get_raw_size_idat((*w + 7) >> 3, (*h + 7) >> 3, color) + ((*h + 7) >> 3);
if(*w > 4) predict += lodepng_get_raw_size_idat((*w + 3) >> 3, (*h + 7) >> 3, color) + ((*h + 7) >> 3);
predict += lodepng_get_raw_size_idat((*w + 3) >> 2, (*h + 3) >> 3, color) + ((*h + 3) >> 3);
if(*w > 2) predict += lodepng_get_raw_size_idat((*w + 1) >> 2, (*h + 3) >> 2, color) + ((*h + 3) >> 2);
predict += lodepng_get_raw_size_idat((*w + 1) >> 1, (*h + 1) >> 2, color) + ((*h + 1) >> 2);
if(*w > 1) predict += lodepng_get_raw_size_idat((*w + 0) >> 1, (*h + 1) >> 1, color) + ((*h + 1) >> 1);
predict += lodepng_get_raw_size_idat((*w + 0), (*h + 0) >> 1, color) + ((*h + 0) >> 1);
}
if(!state->error && !ucvector_reserve(&scanlines, predict)) state->error = 83; /*alloc fail*/
if(!state->error)
{
state->error = zlib_decompress(&scanlines.data, &scanlines.size, idat.data,
idat.size, &state->decoder.zlibsettings);
if(!state->error && scanlines.size != predict) state->error = 91; /*decompressed size doesn't match prediction*/
}
ucvector_cleanup(&idat);
if(!state->error)
{
outsize = lodepng_get_raw_size(*w, *h, &state->info_png.color);
*out = (unsigned char*)lodepng_malloc(outsize);
if(!*out) state->error = 83; /*alloc fail*/
}
if(!state->error)
{
for(i = 0; i < outsize; i++) (*out)[i] = 0;
state->error = postProcessScanlines(*out, scanlines.data, *w, *h, &state->info_png);
}
ucvector_cleanup(&scanlines);
}
unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
LodePNGState* state,
const unsigned char* in, size_t insize)
{
*out = 0;
decodeGeneric(out, w, h, state, in, insize);
if(state->error) return state->error;
if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color))
{
/*same color type, no copying or converting of data needed*/
/*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype
the raw image has to the end user*/
if(!state->decoder.color_convert)
{
state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);
if(state->error) return state->error;
}
}
else
{
/*color conversion needed; sort of copy of the data*/
unsigned char* data = *out;
size_t outsize;
/*TODO: check if this works according to the statement in the documentation: "The converter can convert
from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/
if(!(state->info_raw.colortype == LCT_RGB || state->info_raw.colortype == LCT_RGBA)
&& !(state->info_raw.bitdepth == 8))
{
return 56; /*unsupported color mode conversion*/
}
outsize = lodepng_get_raw_size(*w, *h, &state->info_raw);
*out = (unsigned char*)lodepng_malloc(outsize);
if(!(*out))
{
state->error = 83; /*alloc fail*/
}
else state->error = lodepng_convert(*out, data, &state->info_raw,
&state->info_png.color, *w, *h);
lodepng_free(data);
}
return state->error;
}
unsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in,
size_t insize, LodePNGColorType colortype, unsigned bitdepth)
{
unsigned error;
LodePNGState state;
lodepng_state_init(&state);
state.info_raw.colortype = colortype;
state.info_raw.bitdepth = bitdepth;
error = lodepng_decode(out, w, h, &state, in, insize);
lodepng_state_cleanup(&state);
return error;
}
unsigned lodepng_decode32(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in, size_t insize)
{
return lodepng_decode_memory(out, w, h, in, insize, LCT_RGBA, 8);
}
unsigned lodepng_decode24(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in, size_t insize)
{
return lodepng_decode_memory(out, w, h, in, insize, LCT_RGB, 8);
}
#ifdef LODEPNG_COMPILE_DISK
unsigned lodepng_decode_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename,
LodePNGColorType colortype, unsigned bitdepth)
{
unsigned char* buffer = 0;
size_t buffersize;
unsigned error;
error = lodepng_load_file(&buffer, &buffersize, filename);
if(!error) error = lodepng_decode_memory(out, w, h, buffer, buffersize, colortype, bitdepth);
lodepng_free(buffer);
return error;
}
unsigned lodepng_decode32_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename)
{
return lodepng_decode_file(out, w, h, filename, LCT_RGBA, 8);
}
unsigned lodepng_decode24_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename)
{
return lodepng_decode_file(out, w, h, filename, LCT_RGB, 8);
}
#endif /*LODEPNG_COMPILE_DISK*/
void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings)
{
settings->color_convert = 1;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
settings->read_text_chunks = 1;
settings->remember_unknown_chunks = 0;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
settings->ignore_crc = 0;
lodepng_decompress_settings_init(&settings->zlibsettings);
}
#endif /*LODEPNG_COMPILE_DECODER*/
#if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER)
void lodepng_state_init(LodePNGState* state)
{
#ifdef LODEPNG_COMPILE_DECODER
lodepng_decoder_settings_init(&state->decoder);
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
lodepng_encoder_settings_init(&state->encoder);
#endif /*LODEPNG_COMPILE_ENCODER*/
lodepng_color_mode_init(&state->info_raw);
lodepng_info_init(&state->info_png);
state->error = 1;
}
void lodepng_state_cleanup(LodePNGState* state)
{
lodepng_color_mode_cleanup(&state->info_raw);
lodepng_info_cleanup(&state->info_png);
}
void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source)
{
lodepng_state_cleanup(dest);
*dest = *source;
lodepng_color_mode_init(&dest->info_raw);
lodepng_info_init(&dest->info_png);
dest->error = lodepng_color_mode_copy(&dest->info_raw, &source->info_raw); if(dest->error) return;
dest->error = lodepng_info_copy(&dest->info_png, &source->info_png); if(dest->error) return;
}
#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */
#ifdef LODEPNG_COMPILE_ENCODER
/* ////////////////////////////////////////////////////////////////////////// */
/* / PNG Encoder / */
/* ////////////////////////////////////////////////////////////////////////// */
/*chunkName must be string of 4 characters*/
static unsigned addChunk(ucvector* out, const char* chunkName, const unsigned char* data, size_t length)
{
CERROR_TRY_RETURN(lodepng_chunk_create(&out->data, &out->size, (unsigned)length, chunkName, data));
out->allocsize = out->size; /*fix the allocsize again*/
return 0;
}
static void writeSignature(ucvector* out)
{
/*8 bytes PNG signature, aka the magic bytes*/
ucvector_push_back(out, 137);
ucvector_push_back(out, 80);
ucvector_push_back(out, 78);
ucvector_push_back(out, 71);
ucvector_push_back(out, 13);
ucvector_push_back(out, 10);
ucvector_push_back(out, 26);
ucvector_push_back(out, 10);
}
static unsigned addChunk_IHDR(ucvector* out, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth, unsigned interlace_method)
{
unsigned error = 0;
ucvector header;
ucvector_init(&header);
lodepng_add32bitInt(&header, w); /*width*/
lodepng_add32bitInt(&header, h); /*height*/
ucvector_push_back(&header, (unsigned char)bitdepth); /*bit depth*/
ucvector_push_back(&header, (unsigned char)colortype); /*color type*/
ucvector_push_back(&header, 0); /*compression method*/
ucvector_push_back(&header, 0); /*filter method*/
ucvector_push_back(&header, (unsigned char)interlace_method); /*interlace method*/
error = addChunk(out, "IHDR", header.data, header.size);
ucvector_cleanup(&header);
return error;
}
static unsigned addChunk_PLTE(ucvector* out, const LodePNGColorMode* info)
{
unsigned error = 0;
size_t i;
ucvector PLTE;
ucvector_init(&PLTE);
for(i = 0; i != info->palettesize * 4; ++i)
{
/*add all channels except alpha channel*/
if(i % 4 != 3) ucvector_push_back(&PLTE, info->palette[i]);
}
error = addChunk(out, "PLTE", PLTE.data, PLTE.size);
ucvector_cleanup(&PLTE);
return error;
}
static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)
{
unsigned error = 0;
size_t i;
ucvector tRNS;
ucvector_init(&tRNS);
if(info->colortype == LCT_PALETTE)
{
size_t amount = info->palettesize;
/*the tail of palette values that all have 255 as alpha, does not have to be encoded*/
for(i = info->palettesize; i != 0; --i)
{
if(info->palette[4 * (i - 1) + 3] == 255) --amount;
else break;
}
/*add only alpha channel*/
for(i = 0; i != amount; ++i) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);
}
else if(info->colortype == LCT_GREY)
{
if(info->key_defined)
{
ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
}
}
else if(info->colortype == LCT_RGB)
{
if(info->key_defined)
{
ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
ucvector_push_back(&tRNS, (unsigned char)(info->key_g >> 8));
ucvector_push_back(&tRNS, (unsigned char)(info->key_g & 255));
ucvector_push_back(&tRNS, (unsigned char)(info->key_b >> 8));
ucvector_push_back(&tRNS, (unsigned char)(info->key_b & 255));
}
}
error = addChunk(out, "tRNS", tRNS.data, tRNS.size);
ucvector_cleanup(&tRNS);
return error;
}
static unsigned addChunk_IDAT(ucvector* out, const unsigned char* data, size_t datasize,
LodePNGCompressSettings* zlibsettings)
{
ucvector zlibdata;
unsigned error = 0;
/*compress with the Zlib compressor*/
ucvector_init(&zlibdata);
error = zlib_compress(&zlibdata.data, &zlibdata.size, data, datasize, zlibsettings);
if(!error) error = addChunk(out, "IDAT", zlibdata.data, zlibdata.size);
ucvector_cleanup(&zlibdata);
return error;
}
static unsigned addChunk_IEND(ucvector* out)
{
unsigned error = 0;
error = addChunk(out, "IEND", 0, 0);
return error;
}
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
static unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)
{
unsigned error = 0;
size_t i;
ucvector text;
ucvector_init(&text);
for(i = 0; keyword[i] != 0; ++i) ucvector_push_back(&text, (unsigned char)keyword[i]);
if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
ucvector_push_back(&text, 0); /*0 termination char*/
for(i = 0; textstring[i] != 0; ++i) ucvector_push_back(&text, (unsigned char)textstring[i]);
error = addChunk(out, "tEXt", text.data, text.size);
ucvector_cleanup(&text);
return error;
}
static unsigned addChunk_zTXt(ucvector* out, const char* keyword, const char* textstring,
LodePNGCompressSettings* zlibsettings)
{
unsigned error = 0;
ucvector data, compressed;
size_t i, textsize = strlen(textstring);
ucvector_init(&data);
ucvector_init(&compressed);
for(i = 0; keyword[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)keyword[i]);
if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
ucvector_push_back(&data, 0); /*0 termination char*/
ucvector_push_back(&data, 0); /*compression method: 0*/
error = zlib_compress(&compressed.data, &compressed.size,
(unsigned char*)textstring, textsize, zlibsettings);
if(!error)
{
for(i = 0; i != compressed.size; ++i) ucvector_push_back(&data, compressed.data[i]);
error = addChunk(out, "zTXt", data.data, data.size);
}
ucvector_cleanup(&compressed);
ucvector_cleanup(&data);
return error;
}
static unsigned addChunk_iTXt(ucvector* out, unsigned compressed, const char* keyword, const char* langtag,
const char* transkey, const char* textstring, LodePNGCompressSettings* zlibsettings)
{
unsigned error = 0;
ucvector data;
size_t i, textsize = strlen(textstring);
ucvector_init(&data);
for(i = 0; keyword[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)keyword[i]);
if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
ucvector_push_back(&data, 0); /*null termination char*/
ucvector_push_back(&data, compressed ? 1 : 0); /*compression flag*/
ucvector_push_back(&data, 0); /*compression method*/
for(i = 0; langtag[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)langtag[i]);
ucvector_push_back(&data, 0); /*null termination char*/
for(i = 0; transkey[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)transkey[i]);
ucvector_push_back(&data, 0); /*null termination char*/
if(compressed)
{
ucvector compressed_data;
ucvector_init(&compressed_data);
error = zlib_compress(&compressed_data.data, &compressed_data.size,
(unsigned char*)textstring, textsize, zlibsettings);
if(!error)
{
for(i = 0; i != compressed_data.size; ++i) ucvector_push_back(&data, compressed_data.data[i]);
}
ucvector_cleanup(&compressed_data);
}
else /*not compressed*/
{
for(i = 0; textstring[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)textstring[i]);
}
if(!error) error = addChunk(out, "iTXt", data.data, data.size);
ucvector_cleanup(&data);
return error;
}
static unsigned addChunk_bKGD(ucvector* out, const LodePNGInfo* info)
{
unsigned error = 0;
ucvector bKGD;
ucvector_init(&bKGD);
if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
{
ucvector_push_back(&bKGD, (unsigned char)(info->background_r >> 8));
ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255));
}
else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
{
ucvector_push_back(&bKGD, (unsigned char)(info->background_r >> 8));
ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255));
ucvector_push_back(&bKGD, (unsigned char)(info->background_g >> 8));
ucvector_push_back(&bKGD, (unsigned char)(info->background_g & 255));
ucvector_push_back(&bKGD, (unsigned char)(info->background_b >> 8));
ucvector_push_back(&bKGD, (unsigned char)(info->background_b & 255));
}
else if(info->color.colortype == LCT_PALETTE)
{
ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255)); /*palette index*/
}
error = addChunk(out, "bKGD", bKGD.data, bKGD.size);
ucvector_cleanup(&bKGD);
return error;
}
static unsigned addChunk_tIME(ucvector* out, const LodePNGTime* time)
{
unsigned error = 0;
unsigned char* data = (unsigned char*)lodepng_malloc(7);
if(!data) return 83; /*alloc fail*/
data[0] = (unsigned char)(time->year >> 8);
data[1] = (unsigned char)(time->year & 255);
data[2] = (unsigned char)time->month;
data[3] = (unsigned char)time->day;
data[4] = (unsigned char)time->hour;
data[5] = (unsigned char)time->minute;
data[6] = (unsigned char)time->second;
error = addChunk(out, "tIME", data, 7);
lodepng_free(data);
return error;
}
static unsigned addChunk_pHYs(ucvector* out, const LodePNGInfo* info)
{
unsigned error = 0;
ucvector data;
ucvector_init(&data);
lodepng_add32bitInt(&data, info->phys_x);
lodepng_add32bitInt(&data, info->phys_y);
ucvector_push_back(&data, (unsigned char)info->phys_unit);
error = addChunk(out, "pHYs", data.data, data.size);
ucvector_cleanup(&data);
return error;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
static void filterScanline(unsigned char* out, const unsigned char* scanline, const unsigned char* prevline,
size_t length, size_t bytewidth, unsigned char filterType)
{
size_t i;
switch(filterType)
{
case 0: /*None*/
for(i = 0; i != length; ++i) out[i] = scanline[i];
break;
case 1: /*Sub*/
for(i = 0; i != bytewidth; ++i) out[i] = scanline[i];
for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - scanline[i - bytewidth];
break;
case 2: /*Up*/
if(prevline)
{
for(i = 0; i != length; ++i) out[i] = scanline[i] - prevline[i];
}
else
{
for(i = 0; i != length; ++i) out[i] = scanline[i];
}
break;
case 3: /*Average*/
if(prevline)
{
for(i = 0; i != bytewidth; ++i) out[i] = scanline[i] - (prevline[i] >> 1);
for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - ((scanline[i - bytewidth] + prevline[i]) >> 1);
}
else
{
for(i = 0; i != bytewidth; ++i) out[i] = scanline[i];
for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - (scanline[i - bytewidth] >> 1);
}
break;
case 4: /*Paeth*/
if(prevline)
{
/*paethPredictor(0, prevline[i], 0) is always prevline[i]*/
for(i = 0; i != bytewidth; ++i) out[i] = (scanline[i] - prevline[i]);
for(i = bytewidth; i < length; ++i)
{
out[i] = (scanline[i] - paethPredictor(scanline[i - bytewidth], prevline[i], prevline[i - bytewidth]));
}
}
else
{
for(i = 0; i != bytewidth; ++i) out[i] = scanline[i];
/*paethPredictor(scanline[i - bytewidth], 0, 0) is always scanline[i - bytewidth]*/
for(i = bytewidth; i < length; ++i) out[i] = (scanline[i] - scanline[i - bytewidth]);
}
break;
default: return; /*unexisting filter type given*/
}
}
/* log2 approximation. A slight bit faster than std::log. */
static float flog2(float f)
{
float result = 0;
while(f > 32) { result += 4; f /= 16; }
while(f > 2) { ++result; f /= 2; }
return result + 1.442695f * (f * f * f / 3 - 3 * f * f / 2 + 3 * f - 1.83333f);
}
static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h,
const LodePNGColorMode* info, const LodePNGEncoderSettings* settings)
{
/*
For PNG filter method 0
out must be a buffer with as size: h + (w * h * bpp + 7) / 8, because there are
the scanlines with 1 extra byte per scanline
*/
unsigned bpp = lodepng_get_bpp(info);
/*the width of a scanline in bytes, not including the filter type*/
size_t linebytes = (w * bpp + 7) / 8;
/*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/
size_t bytewidth = (bpp + 7) / 8;
const unsigned char* prevline = 0;
unsigned x, y;
unsigned error = 0;
LodePNGFilterStrategy strategy = settings->filter_strategy;
/*
There is a heuristic called the minimum sum of absolute differences heuristic, suggested by the PNG standard:
* If the image type is Palette, or the bit depth is smaller than 8, then do not filter the image (i.e.
use fixed filtering, with the filter None).
* (The other case) If the image type is Grayscale or RGB (with or without Alpha), and the bit depth is
not smaller than 8, then use adaptive filtering heuristic as follows: independently for each row, apply
all five filters and select the filter that produces the smallest sum of absolute values per row.
This heuristic is used if filter strategy is LFS_MINSUM and filter_palette_zero is true.
If filter_palette_zero is true and filter_strategy is not LFS_MINSUM, the above heuristic is followed,
but for "the other case", whatever strategy filter_strategy is set to instead of the minimum sum
heuristic is used.
*/
if(settings->filter_palette_zero &&
(info->colortype == LCT_PALETTE || info->bitdepth < 8)) strategy = LFS_ZERO;
if(bpp == 0) return 31; /*error: invalid color type*/
if(strategy == LFS_ZERO)
{
for(y = 0; y != h; ++y)
{
size_t outindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
size_t inindex = linebytes * y;
out[outindex] = 0; /*filter type byte*/
filterScanline(&out[outindex + 1], &in[inindex], prevline, linebytes, bytewidth, 0);
prevline = &in[inindex];
}
}
else if(strategy == LFS_MINSUM)
{
/*adaptive filtering*/
size_t sum[5];
unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
size_t smallest = 0;
unsigned char type, bestType = 0;
for(type = 0; type != 5; ++type)
{
attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
if(!attempt[type]) return 83; /*alloc fail*/
}
if(!error)
{
for(y = 0; y != h; ++y)
{
/*try the 5 filter types*/
for(type = 0; type != 5; ++type)
{
filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, type);
/*calculate the sum of the result*/
sum[type] = 0;
if(type == 0)
{
for(x = 0; x != linebytes; ++x) sum[type] += (unsigned char)(attempt[type][x]);
}
else
{
for(x = 0; x != linebytes; ++x)
{
/*For differences, each byte should be treated as signed, values above 127 are negative
(converted to signed char). Filtertype 0 isn't a difference though, so use unsigned there.
This means filtertype 0 is almost never chosen, but that is justified.*/
unsigned char s = attempt[type][x];
sum[type] += s < 128 ? s : (255U - s);
}
}
/*check if this is smallest sum (or if type == 0 it's the first case so always store the values)*/
if(type == 0 || sum[type] < smallest)
{
bestType = type;
smallest = sum[type];
}
}
prevline = &in[y * linebytes];
/*now fill the out values*/
out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/
for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
}
for(type = 0; type != 5; ++type) lodepng_free(attempt[type]);
}
else if(strategy == LFS_ENTROPY)
{
float sum[5];
unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
float smallest = 0;
unsigned type, bestType = 0;
unsigned count[256];
for(type = 0; type != 5; ++type)
{
attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
if(!attempt[type]) return 83; /*alloc fail*/
}
for(y = 0; y != h; ++y)
{
/*try the 5 filter types*/
for(type = 0; type != 5; ++type)
{
filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, (unsigned char)type);
for(x = 0; x != 256; ++x) count[x] = 0;
for(x = 0; x != linebytes; ++x) ++count[attempt[type][x]];
++count[type]; /*the filter type itself is part of the scanline*/
sum[type] = 0;
for(x = 0; x != 256; ++x)
{
float p = count[x] / (float)(linebytes + 1);
sum[type] += count[x] == 0 ? 0 : flog2(1 / p) * p;
}
/*check if this is smallest sum (or if type == 0 it's the first case so always store the values)*/
if(type == 0 || sum[type] < smallest)
{
bestType = type;
smallest = sum[type];
}
}
prevline = &in[y * linebytes];
/*now fill the out values*/
out[y * (linebytes + 1)] = (unsigned char)bestType; /*the first byte of a scanline will be the filter type*/
for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
for(type = 0; type != 5; ++type) lodepng_free(attempt[type]);
}
else if(strategy == LFS_PREDEFINED)
{
for(y = 0; y != h; ++y)
{
size_t outindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
size_t inindex = linebytes * y;
unsigned char type = settings->predefined_filters[y];
out[outindex] = type; /*filter type byte*/
filterScanline(&out[outindex + 1], &in[inindex], prevline, linebytes, bytewidth, type);
prevline = &in[inindex];
}
}
else if(strategy == LFS_BRUTE_FORCE)
{
/*brute force filter chooser.
deflate the scanline after every filter attempt to see which one deflates best.
This is very slow and gives only slightly smaller, sometimes even larger, result*/
size_t size[5];
unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
size_t smallest = 0;
unsigned type = 0, bestType = 0;
unsigned char* dummy;
LodePNGCompressSettings zlibsettings = settings->zlibsettings;
/*use fixed tree on the attempts so that the tree is not adapted to the filtertype on purpose,
to simulate the true case where the tree is the same for the whole image. Sometimes it gives
better result with dynamic tree anyway. Using the fixed tree sometimes gives worse, but in rare
cases better compression. It does make this a bit less slow, so it's worth doing this.*/
zlibsettings.btype = 1;
/*a custom encoder likely doesn't read the btype setting and is optimized for complete PNG
images only, so disable it*/
zlibsettings.custom_zlib = 0;
zlibsettings.custom_deflate = 0;
for(type = 0; type != 5; ++type)
{
attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
if(!attempt[type]) return 83; /*alloc fail*/
}
for(y = 0; y != h; ++y) /*try the 5 filter types*/
{
for(type = 0; type != 5; ++type)
{
unsigned testsize = (unsigned int)linebytes;
/*if(testsize > 8) testsize /= 8;*/ /*it already works good enough by testing a part of the row*/
filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, (unsigned char)type);
size[type] = 0;
dummy = 0;
zlib_compress(&dummy, &size[type], attempt[type], testsize, &zlibsettings);
lodepng_free(dummy);
/*check if this is smallest size (or if type == 0 it's the first case so always store the values)*/
if(type == 0 || size[type] < smallest)
{
bestType = type;
smallest = size[type];
}
}
prevline = &in[y * linebytes];
out[y * (linebytes + 1)] = (unsigned char)bestType; /*the first byte of a scanline will be the filter type*/
for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
for(type = 0; type != 5; ++type) lodepng_free(attempt[type]);
}
else return 88; /* unknown filter strategy */
return error;
}
static void addPaddingBits(unsigned char* out, const unsigned char* in,
size_t olinebits, size_t ilinebits, unsigned h)
{
/*The opposite of the removePaddingBits function
olinebits must be >= ilinebits*/
unsigned y;
size_t diff = olinebits - ilinebits;
size_t obp = 0, ibp = 0; /*bit pointers*/
for(y = 0; y != h; ++y)
{
size_t x;
for(x = 0; x < ilinebits; ++x)
{
unsigned char bit = readBitFromReversedStream(&ibp, in);
setBitOfReversedStream(&obp, out, bit);
}
/*obp += diff; --> no, fill in some value in the padding bits too, to avoid
"Use of uninitialised value of size ###" warning from valgrind*/
for(x = 0; x != diff; ++x) setBitOfReversedStream(&obp, out, 0);
}
}
/*
in: non-interlaced image with size w*h
out: the same pixels, but re-ordered according to PNG's Adam7 interlacing, with
no padding bits between scanlines, but between reduced images so that each
reduced image starts at a byte.
bpp: bits per pixel
there are no padding bits, not between scanlines, not between reduced images
in has the following size in bits: w * h * bpp.
out is possibly bigger due to padding bits between reduced images
NOTE: comments about padding bits are only relevant if bpp < 8
*/
static void Adam7_interlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)
{
unsigned passw[7], passh[7];
size_t filter_passstart[8], padded_passstart[8], passstart[8];
unsigned i;
Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
if(bpp >= 8)
{
for(i = 0; i != 7; ++i)
{
unsigned x, y, b;
size_t bytewidth = bpp / 8;
for(y = 0; y < passh[i]; ++y)
for(x = 0; x < passw[i]; ++x)
{
size_t pixelinstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w + ADAM7_IX[i] + x * ADAM7_DX[i]) * bytewidth;
size_t pixeloutstart = passstart[i] + (y * passw[i] + x) * bytewidth;
for(b = 0; b < bytewidth; ++b)
{
out[pixeloutstart + b] = in[pixelinstart + b];
}
}
}
}
else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/
{
for(i = 0; i != 7; ++i)
{
unsigned x, y, b;
unsigned ilinebits = bpp * passw[i];
unsigned olinebits = bpp * w;
size_t obp, ibp; /*bit pointers (for out and in buffer)*/
for(y = 0; y < passh[i]; ++y)
for(x = 0; x < passw[i]; ++x)
{
ibp = (ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp;
obp = (8 * passstart[i]) + (y * ilinebits + x * bpp);
for(b = 0; b < bpp; ++b)
{
unsigned char bit = readBitFromReversedStream(&ibp, in);
setBitOfReversedStream(&obp, out, bit);
}
}
}
}
}
/*out must be buffer big enough to contain uncompressed IDAT chunk data, and in must contain the full image.
return value is error**/
static unsigned preProcessScanlines(unsigned char** out, size_t* outsize, const unsigned char* in,
unsigned w, unsigned h,
const LodePNGInfo* info_png, const LodePNGEncoderSettings* settings)
{
/*
This function converts the pure 2D image with the PNG's colortype, into filtered-padded-interlaced data. Steps:
*) if no Adam7: 1) add padding bits (= posible extra bits per scanline if bpp < 8) 2) filter
*) if adam7: 1) Adam7_interlace 2) 7x add padding bits 3) 7x filter
*/
unsigned bpp = lodepng_get_bpp(&info_png->color);
unsigned error = 0;
if(info_png->interlace_method == 0)
{
*outsize = h + (h * ((w * bpp + 7) / 8)); /*image size plus an extra byte per scanline + possible padding bits*/
*out = (unsigned char*)lodepng_malloc(*outsize);
if(!(*out) && (*outsize)) error = 83; /*alloc fail*/
if(!error)
{
/*non multiple of 8 bits per scanline, padding bits needed per scanline*/
if(bpp < 8 && w * bpp != ((w * bpp + 7) / 8) * 8)
{
unsigned char* padded = (unsigned char*)lodepng_malloc(h * ((w * bpp + 7) / 8));
if(!padded) error = 83; /*alloc fail*/
if(!error)
{
addPaddingBits(padded, in, ((w * bpp + 7) / 8) * 8, w * bpp, h);
error = filter(*out, padded, w, h, &info_png->color, settings);
}
lodepng_free(padded);
}
else
{
/*we can immediately filter into the out buffer, no other steps needed*/
error = filter(*out, in, w, h, &info_png->color, settings);
}
}
}
else /*interlace_method is 1 (Adam7)*/
{
unsigned passw[7], passh[7];
size_t filter_passstart[8], padded_passstart[8], passstart[8];
unsigned char* adam7;
Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
*outsize = filter_passstart[7]; /*image size plus an extra byte per scanline + possible padding bits*/
*out = (unsigned char*)lodepng_malloc(*outsize);
if(!(*out)) error = 83; /*alloc fail*/
adam7 = (unsigned char*)lodepng_malloc(passstart[7]);
if(!adam7 && passstart[7]) error = 83; /*alloc fail*/
if(!error)
{
unsigned i;
Adam7_interlace(adam7, in, w, h, bpp);
for(i = 0; i != 7; ++i)
{
if(bpp < 8)
{
unsigned char* padded = (unsigned char*)lodepng_malloc(padded_passstart[i + 1] - padded_passstart[i]);
if(!padded) ERROR_BREAK(83); /*alloc fail*/
addPaddingBits(padded, &adam7[passstart[i]],
((passw[i] * bpp + 7) / 8) * 8, passw[i] * bpp, passh[i]);
error = filter(&(*out)[filter_passstart[i]], padded,
passw[i], passh[i], &info_png->color, settings);
lodepng_free(padded);
}
else
{
error = filter(&(*out)[filter_passstart[i]], &adam7[padded_passstart[i]],
passw[i], passh[i], &info_png->color, settings);
}
if(error) break;
}
}
lodepng_free(adam7);
}
return error;
}
/*
palette must have 4 * palettesize bytes allocated, and given in format RGBARGBARGBARGBA...
returns 0 if the palette is opaque,
returns 1 if the palette has a single color with alpha 0 ==> color key
returns 2 if the palette is semi-translucent.
*/
static unsigned getPaletteTranslucency(const unsigned char* palette, size_t palettesize)
{
size_t i;
unsigned key = 0;
unsigned r = 0, g = 0, b = 0; /*the value of the color with alpha 0, so long as color keying is possible*/
for(i = 0; i != palettesize; ++i)
{
if(!key && palette[4 * i + 3] == 0)
{
r = palette[4 * i + 0]; g = palette[4 * i + 1]; b = palette[4 * i + 2];
key = 1;
i = (size_t)(-1); /*restart from beginning, to detect earlier opaque colors with key's value*/
}
else if(palette[4 * i + 3] != 255) return 2;
/*when key, no opaque RGB may have key's RGB*/
else if(key && r == palette[i * 4 + 0] && g == palette[i * 4 + 1] && b == palette[i * 4 + 2]) return 2;
}
return key;
}
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
static unsigned addUnknownChunks(ucvector* out, unsigned char* data, size_t datasize)
{
unsigned char* inchunk = data;
while((size_t)(inchunk - data) < datasize)
{
CERROR_TRY_RETURN(lodepng_chunk_append(&out->data, &out->size, inchunk));
out->allocsize = out->size; /*fix the allocsize again*/
inchunk = lodepng_chunk_next(inchunk);
}
return 0;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
unsigned lodepng_encode(unsigned char** out, size_t* outsize,
const unsigned char* image, unsigned w, unsigned h,
LodePNGState* state)
{
LodePNGInfo info;
ucvector outv;
unsigned char* data = 0; /*uncompressed version of the IDAT chunk data*/
size_t datasize = 0;
/*provide some proper output values if error will happen*/
*out = 0;
*outsize = 0;
state->error = 0;
/*check input values validity*/
if((state->info_png.color.colortype == LCT_PALETTE || state->encoder.force_palette)
&& (state->info_png.color.palettesize == 0 || state->info_png.color.palettesize > 256))
{
CERROR_RETURN_ERROR(state->error, 68); /*invalid palette size, it is only allowed to be 1-256*/
}
if(state->encoder.zlibsettings.btype > 2)
{
CERROR_RETURN_ERROR(state->error, 61); /*error: unexisting btype*/
}
if(state->info_png.interlace_method > 1)
{
CERROR_RETURN_ERROR(state->error, 71); /*error: unexisting interlace mode*/
}
state->error = checkColorValidity(state->info_png.color.colortype, state->info_png.color.bitdepth);
if(state->error) return state->error; /*error: unexisting color type given*/
state->error = checkColorValidity(state->info_raw.colortype, state->info_raw.bitdepth);
if(state->error) return state->error; /*error: unexisting color type given*/
/* color convert and compute scanline filter types */
lodepng_info_init(&info);
lodepng_info_copy(&info, &state->info_png);
if(state->encoder.auto_convert)
{
state->error = lodepng_auto_choose_color(&info.color, image, w, h, &state->info_raw);
}
if (!state->error)
{
if(!lodepng_color_mode_equal(&state->info_raw, &info.color))
{
unsigned char* converted;
size_t size = (w * h * (size_t)lodepng_get_bpp(&info.color) + 7) / 8;
converted = (unsigned char*)lodepng_malloc(size);
if(!converted && size) state->error = 83; /*alloc fail*/
if(!state->error)
{
state->error = lodepng_convert(converted, image, &info.color, &state->info_raw, w, h);
}
if(!state->error) preProcessScanlines(&data, &datasize, converted, w, h, &info, &state->encoder);
lodepng_free(converted);
}
else preProcessScanlines(&data, &datasize, image, w, h, &info, &state->encoder);
}
/* output all PNG chunks */
ucvector_init(&outv);
while(!state->error) /*while only executed once, to break on error*/
{
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
size_t i;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*write signature and chunks*/
writeSignature(&outv);
/*IHDR*/
addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlace_method);
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*unknown chunks between IHDR and PLTE*/
if(info.unknown_chunks_data[0])
{
state->error = addUnknownChunks(&outv, info.unknown_chunks_data[0], info.unknown_chunks_size[0]);
if(state->error) break;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*PLTE*/
if(info.color.colortype == LCT_PALETTE)
{
addChunk_PLTE(&outv, &info.color);
}
if(state->encoder.force_palette && (info.color.colortype == LCT_RGB || info.color.colortype == LCT_RGBA))
{
addChunk_PLTE(&outv, &info.color);
}
/*tRNS*/
if(info.color.colortype == LCT_PALETTE && getPaletteTranslucency(info.color.palette, info.color.palettesize) != 0)
{
addChunk_tRNS(&outv, &info.color);
}
if((info.color.colortype == LCT_GREY || info.color.colortype == LCT_RGB) && info.color.key_defined)
{
addChunk_tRNS(&outv, &info.color);
}
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*bKGD (must come between PLTE and the IDAt chunks*/
if(info.background_defined) addChunk_bKGD(&outv, &info);
/*pHYs (must come before the IDAT chunks)*/
if(info.phys_defined) addChunk_pHYs(&outv, &info);
/*unknown chunks between PLTE and IDAT*/
if(info.unknown_chunks_data[1])
{
state->error = addUnknownChunks(&outv, info.unknown_chunks_data[1], info.unknown_chunks_size[1]);
if(state->error) break;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
/*IDAT (multiple IDAT chunks must be consecutive)*/
state->error = addChunk_IDAT(&outv, data, datasize, &state->encoder.zlibsettings);
if(state->error) break;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
/*tIME*/
if(info.time_defined) addChunk_tIME(&outv, &info.time);
/*tEXt and/or zTXt*/
for(i = 0; i != info.text_num; ++i)
{
if(strlen(info.text_keys[i]) > 79)
{
state->error = 66; /*text chunk too large*/
break;
}
if(strlen(info.text_keys[i]) < 1)
{
state->error = 67; /*text chunk too small*/
break;
}
if(state->encoder.text_compression)
{
addChunk_zTXt(&outv, info.text_keys[i], info.text_strings[i], &state->encoder.zlibsettings);
}
else
{
addChunk_tEXt(&outv, info.text_keys[i], info.text_strings[i]);
}
}
/*LodePNG version id in text chunk*/
if(state->encoder.add_id)
{
unsigned alread_added_id_text = 0;
for(i = 0; i != info.text_num; ++i)
{
if(!strcmp(info.text_keys[i], "LodePNG"))
{
alread_added_id_text = 1;
break;
}
}
if(alread_added_id_text == 0)
{
addChunk_tEXt(&outv, "LodePNG", LODEPNG_VERSION_STRING); /*it's shorter as tEXt than as zTXt chunk*/
}
}
/*iTXt*/
for(i = 0; i != info.itext_num; ++i)
{
if(strlen(info.itext_keys[i]) > 79)
{
state->error = 66; /*text chunk too large*/
break;
}
if(strlen(info.itext_keys[i]) < 1)
{
state->error = 67; /*text chunk too small*/
break;
}
addChunk_iTXt(&outv, state->encoder.text_compression,
info.itext_keys[i], info.itext_langtags[i], info.itext_transkeys[i], info.itext_strings[i],
&state->encoder.zlibsettings);
}
/*unknown chunks between IDAT and IEND*/
if(info.unknown_chunks_data[2])
{
state->error = addUnknownChunks(&outv, info.unknown_chunks_data[2], info.unknown_chunks_size[2]);
if(state->error) break;
}
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
addChunk_IEND(&outv);
break; /*this isn't really a while loop; no error happened so break out now!*/
}
lodepng_info_cleanup(&info);
lodepng_free(data);
/*instead of cleaning the vector up, give it to the output*/
*out = outv.data;
*outsize = outv.size;
return state->error;
}
unsigned lodepng_encode_memory(unsigned char** out, size_t* outsize, const unsigned char* image,
unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
{
unsigned error;
LodePNGState state;
lodepng_state_init(&state);
state.info_raw.colortype = colortype;
state.info_raw.bitdepth = bitdepth;
state.info_png.color.colortype = colortype;
state.info_png.color.bitdepth = bitdepth;
lodepng_encode(out, outsize, image, w, h, &state);
error = state.error;
lodepng_state_cleanup(&state);
return error;
}
unsigned lodepng_encode32(unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h)
{
return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGBA, 8);
}
unsigned lodepng_encode24(unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h)
{
return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGB, 8);
}
#ifdef LODEPNG_COMPILE_DISK
unsigned lodepng_encode_file(const char* filename, const unsigned char* image, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
unsigned char* buffer;
size_t buffersize;
unsigned error = lodepng_encode_memory(&buffer, &buffersize, image, w, h, colortype, bitdepth);
if(!error) error = lodepng_save_file(buffer, buffersize, filename);
lodepng_free(buffer);
return error;
}
unsigned lodepng_encode32_file(const char* filename, const unsigned char* image, unsigned w, unsigned h)
{
return lodepng_encode_file(filename, image, w, h, LCT_RGBA, 8);
}
unsigned lodepng_encode24_file(const char* filename, const unsigned char* image, unsigned w, unsigned h)
{
return lodepng_encode_file(filename, image, w, h, LCT_RGB, 8);
}
#endif /*LODEPNG_COMPILE_DISK*/
void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)
{
lodepng_compress_settings_init(&settings->zlibsettings);
settings->filter_palette_zero = 1;
settings->filter_strategy = LFS_MINSUM;
settings->auto_convert = 1;
settings->force_palette = 0;
settings->predefined_filters = 0;
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
settings->add_id = 0;
settings->text_compression = 1;
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
}
#endif /*LODEPNG_COMPILE_ENCODER*/
#endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ERROR_TEXT
/*
This returns the description of a numerical error code in English. This is also
the documentation of all the error codes.
*/
const char* lodepng_error_text(unsigned code)
{
switch(code)
{
case 0: return "no error, everything went ok";
case 1: return "nothing done yet"; /*the Encoder/Decoder has done nothing yet, error checking makes no sense yet*/
case 10: return "end of input memory reached without huffman end code"; /*while huffman decoding*/
case 11: return "error in code tree made it jump outside of huffman tree"; /*while huffman decoding*/
case 13: return "problem while processing dynamic deflate block";
case 14: return "problem while processing dynamic deflate block";
case 15: return "problem while processing dynamic deflate block";
case 16: return "unexisting code while processing dynamic deflate block";
case 17: return "end of out buffer memory reached while inflating";
case 18: return "invalid distance code while inflating";
case 19: return "end of out buffer memory reached while inflating";
case 20: return "invalid deflate block BTYPE encountered while decoding";
case 21: return "NLEN is not ones complement of LEN in a deflate block";
/*end of out buffer memory reached while inflating:
This can happen if the inflated deflate data is longer than the amount of bytes required to fill up
all the pixels of the image, given the color depth and image dimensions. Something that doesn't
happen in a normal, well encoded, PNG image.*/
case 22: return "end of out buffer memory reached while inflating";
case 23: return "end of in buffer memory reached while inflating";
case 24: return "invalid FCHECK in zlib header";
case 25: return "invalid compression method in zlib header";
case 26: return "FDICT encountered in zlib header while it's not used for PNG";
case 27: return "PNG file is smaller than a PNG header";
/*Checks the magic file header, the first 8 bytes of the PNG file*/
case 28: return "incorrect PNG signature, it's no PNG or corrupted";
case 29: return "first chunk is not the header chunk";
case 30: return "chunk length too large, chunk broken off at end of file";
case 31: return "illegal PNG color type or bpp";
case 32: return "illegal PNG compression method";
case 33: return "illegal PNG filter method";
case 34: return "illegal PNG interlace method";
case 35: return "chunk length of a chunk is too large or the chunk too small";
case 36: return "illegal PNG filter type encountered";
case 37: return "illegal bit depth for this color type given";
case 38: return "the palette is too big"; /*more than 256 colors*/
case 39: return "more palette alpha values given in tRNS chunk than there are colors in the palette";
case 40: return "tRNS chunk has wrong size for greyscale image";
case 41: return "tRNS chunk has wrong size for RGB image";
case 42: return "tRNS chunk appeared while it was not allowed for this color type";
case 43: return "bKGD chunk has wrong size for palette image";
case 44: return "bKGD chunk has wrong size for greyscale image";
case 45: return "bKGD chunk has wrong size for RGB image";
case 48: return "empty input buffer given to decoder. Maybe caused by non-existing file?";
case 49: return "jumped past memory while generating dynamic huffman tree";
case 50: return "jumped past memory while generating dynamic huffman tree";
case 51: return "jumped past memory while inflating huffman block";
case 52: return "jumped past memory while inflating";
case 53: return "size of zlib data too small";
case 54: return "repeat symbol in tree while there was no value symbol yet";
/*jumped past tree while generating huffman tree, this could be when the
tree will have more leaves than symbols after generating it out of the
given lenghts. They call this an oversubscribed dynamic bit lengths tree in zlib.*/
case 55: return "jumped past tree while generating huffman tree";
case 56: return "given output image colortype or bitdepth not supported for color conversion";
case 57: return "invalid CRC encountered (checking CRC can be disabled)";
case 58: return "invalid ADLER32 encountered (checking ADLER32 can be disabled)";
case 59: return "requested color conversion not supported";
case 60: return "invalid window size given in the settings of the encoder (must be 0-32768)";
case 61: return "invalid BTYPE given in the settings of the encoder (only 0, 1 and 2 are allowed)";
/*LodePNG leaves the choice of RGB to greyscale conversion formula to the user.*/
case 62: return "conversion from color to greyscale not supported";
case 63: return "length of a chunk too long, max allowed for PNG is 2147483647 bytes per chunk"; /*(2^31-1)*/
/*this would result in the inability of a deflated block to ever contain an end code. It must be at least 1.*/
case 64: return "the length of the END symbol 256 in the Huffman tree is 0";
case 66: return "the length of a text chunk keyword given to the encoder is longer than the maximum of 79 bytes";
case 67: return "the length of a text chunk keyword given to the encoder is smaller than the minimum of 1 byte";
case 68: return "tried to encode a PLTE chunk with a palette that has less than 1 or more than 256 colors";
case 69: return "unknown chunk type with 'critical' flag encountered by the decoder";
case 71: return "unexisting interlace mode given to encoder (must be 0 or 1)";
case 72: return "while decoding, unexisting compression method encountering in zTXt or iTXt chunk (it must be 0)";
case 73: return "invalid tIME chunk size";
case 74: return "invalid pHYs chunk size";
/*length could be wrong, or data chopped off*/
case 75: return "no null termination char found while decoding text chunk";
case 76: return "iTXt chunk too short to contain required bytes";
case 77: return "integer overflow in buffer size";
case 78: return "failed to open file for reading"; /*file doesn't exist or couldn't be opened for reading*/
case 79: return "failed to open file for writing";
case 80: return "tried creating a tree of 0 symbols";
case 81: return "lazy matching at pos 0 is impossible";
case 82: return "color conversion to palette requested while a color isn't in palette";
case 83: return "memory allocation failed";
case 84: return "given image too small to contain all pixels to be encoded";
case 86: return "impossible offset in lz77 encoding (internal bug)";
case 87: return "must provide custom zlib function pointer if LODEPNG_COMPILE_ZLIB is not defined";
case 88: return "invalid filter strategy given for LodePNGEncoderSettings.filter_strategy";
case 89: return "text chunk keyword too short or long: must have size 1-79";
/*the windowsize in the LodePNGCompressSettings. Requiring POT(==> & instead of %) makes encoding 12% faster.*/
case 90: return "windowsize must be a power of two";
case 91: return "invalid decompressed idat size";
case 92: return "too many pixels, not supported";
case 93: return "zero width or height is invalid";
case 94: return "header chunk must have a size of 13 bytes";
}
return "unknown error code";
}
#endif /*LODEPNG_COMPILE_ERROR_TEXT*/
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
/* // C++ Wrapper // */
/* ////////////////////////////////////////////////////////////////////////// */
/* ////////////////////////////////////////////////////////////////////////// */
#ifdef LODEPNG_COMPILE_CPP
namespace lodepng
{
#ifdef LODEPNG_COMPILE_DISK
unsigned load_file(std::vector<unsigned char>& buffer, const std::string& filename)
{
long size = lodepng_filesize(filename.c_str());
if(size < 0) return 78;
buffer.resize((size_t)size);
return size == 0 ? 0 : lodepng_buffer_file(&buffer[0], (size_t)size, filename.c_str());
}
/*write given buffer to the file, overwriting the file, it doesn't append to it.*/
unsigned save_file(const std::vector<unsigned char>& buffer, const std::string& filename)
{
return lodepng_save_file(buffer.empty() ? 0 : &buffer[0], buffer.size(), filename.c_str());
}
#endif /* LODEPNG_COMPILE_DISK */
#ifdef LODEPNG_COMPILE_ZLIB
#ifdef LODEPNG_COMPILE_DECODER
unsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
const LodePNGDecompressSettings& settings)
{
unsigned char* buffer = 0;
size_t buffersize = 0;
unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
const LodePNGDecompressSettings& settings)
{
return decompress(out, in.empty() ? 0 : &in[0], in.size(), settings);
}
#endif /* LODEPNG_COMPILE_DECODER */
#ifdef LODEPNG_COMPILE_ENCODER
unsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
const LodePNGCompressSettings& settings)
{
unsigned char* buffer = 0;
size_t buffersize = 0;
unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
const LodePNGCompressSettings& settings)
{
return compress(out, in.empty() ? 0 : &in[0], in.size(), settings);
}
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_ZLIB */
#ifdef LODEPNG_COMPILE_PNG
State::State()
{
lodepng_state_init(this);
}
State::State(const State& other)
{
lodepng_state_init(this);
lodepng_state_copy(this, &other);
}
State::~State()
{
lodepng_state_cleanup(this);
}
State& State::operator=(const State& other)
{
lodepng_state_copy(this, &other);
return *this;
}
#ifdef LODEPNG_COMPILE_DECODER
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const unsigned char* in,
size_t insize, LodePNGColorType colortype, unsigned bitdepth)
{
unsigned char* buffer;
unsigned error = lodepng_decode_memory(&buffer, &w, &h, in, insize, colortype, bitdepth);
if(buffer && !error)
{
State state;
state.info_raw.colortype = colortype;
state.info_raw.bitdepth = bitdepth;
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
const std::vector<unsigned char>& in, LodePNGColorType colortype, unsigned bitdepth)
{
return decode(out, w, h, in.empty() ? 0 : &in[0], (unsigned)in.size(), colortype, bitdepth);
}
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
State& state,
const unsigned char* in, size_t insize)
{
unsigned char* buffer = NULL;
unsigned error = lodepng_decode(&buffer, &w, &h, &state, in, insize);
if(buffer && !error)
{
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
}
lodepng_free(buffer);
return error;
}
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
State& state,
const std::vector<unsigned char>& in)
{
return decode(out, w, h, state, in.empty() ? 0 : &in[0], in.size());
}
#ifdef LODEPNG_COMPILE_DISK
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const std::string& filename,
LodePNGColorType colortype, unsigned bitdepth)
{
std::vector<unsigned char> buffer;
unsigned error = load_file(buffer, filename);
if(error) return error;
return decode(out, w, h, buffer, colortype, bitdepth);
}
#endif /* LODEPNG_COMPILE_DECODER */
#endif /* LODEPNG_COMPILE_DISK */
#ifdef LODEPNG_COMPILE_ENCODER
unsigned encode(std::vector<unsigned char>& out, const unsigned char* in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
unsigned char* buffer;
size_t buffersize;
unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned encode(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
return encode(out, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
}
unsigned encode(std::vector<unsigned char>& out,
const unsigned char* in, unsigned w, unsigned h,
State& state)
{
unsigned char* buffer;
size_t buffersize;
unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);
if(buffer)
{
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
lodepng_free(buffer);
}
return error;
}
unsigned encode(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
State& state)
{
if(lodepng_get_raw_size(w, h, &state.info_raw) > in.size()) return 84;
return encode(out, in.empty() ? 0 : &in[0], w, h, state);
}
#ifdef LODEPNG_COMPILE_DISK
unsigned encode(const std::string& filename,
const unsigned char* in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
std::vector<unsigned char> buffer;
unsigned error = encode(buffer, in, w, h, colortype, bitdepth);
if(!error) error = save_file(buffer, filename);
return error;
}
unsigned encode(const std::string& filename,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth)
{
if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;
return encode(filename, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);
}
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_PNG */
} /* namespace lodepng */
#endif /*LODEPNG_COMPILE_CPP*/
| [
"[email protected]"
] | |
9c3feedca7041d4898d86a8eb0b5a9fbe82f2a3c | 23c4109411bb6490d76430d485c19152c56e037a | /llvm-project/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 0028fec51bba3d2b111a8117d42f17f7a227bea4 | [
"NCSA",
"Apache-2.0",
"LLVM-exception"
] | permissive | AlexErf/GPUProject | f9a060e63caec0c07584aa2a2826432dc6cfc0b5 | c2740b6ca052436a73d05564187c473a37f362b9 | refs/heads/main | 2023-02-02T05:41:53.330592 | 2020-12-14T03:04:19 | 2020-12-14T03:04:19 | 310,434,160 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 38,406 | cpp | //===-- PlatformPOSIX.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "PlatformPOSIX.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileCache.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/ScopeExit.h"
using namespace lldb;
using namespace lldb_private;
/// Default Constructor
PlatformPOSIX::PlatformPOSIX(bool is_host)
: RemoteAwarePlatform(is_host), // This is the local host platform
m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
m_option_group_platform_caching(new OptionGroupPlatformCaching()) {}
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
PlatformPOSIX::~PlatformPOSIX() {}
lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
lldb_private::CommandInterpreter &interpreter) {
auto iter = m_options.find(&interpreter), end = m_options.end();
if (iter == end) {
std::unique_ptr<lldb_private::OptionGroupOptions> options(
new OptionGroupOptions());
options->Append(m_option_group_platform_rsync.get());
options->Append(m_option_group_platform_ssh.get());
options->Append(m_option_group_platform_caching.get());
m_options[&interpreter] = std::move(options);
}
return m_options.at(&interpreter).get();
}
static uint32_t chown_file(Platform *platform, const char *path,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) {
if (!platform || !path || *path == 0)
return UINT32_MAX;
if (uid == UINT32_MAX && gid == UINT32_MAX)
return 0; // pretend I did chown correctly - actually I just didn't care
StreamString command;
command.PutCString("chown ");
if (uid != UINT32_MAX)
command.Printf("%d", uid);
if (gid != UINT32_MAX)
command.Printf(":%d", gid);
command.Printf("%s", path);
int status;
platform->RunShellCommand(command.GetData(), FileSpec(), &status, nullptr,
nullptr, std::chrono::seconds(10));
return status;
}
lldb_private::Status
PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination, uint32_t uid,
uint32_t gid) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (IsHost()) {
if (source == destination)
return Status();
// cp src dst
// chown uid:gid dst
std::string src_path(source.GetPath());
if (src_path.empty())
return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
return Status("unable to get file path for destination");
StreamString command;
command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
RunShellCommand(command.GetData(), FileSpec(), &status, nullptr, nullptr,
std::chrono::seconds(10));
if (status != 0)
return Status("unable to perform copy");
if (uid == UINT32_MAX && gid == UINT32_MAX)
return Status();
if (chown_file(this, dst_path.c_str(), uid, gid) != 0)
return Status("unable to perform chown");
return Status();
} else if (m_remote_platform_sp) {
if (GetSupportsRSync()) {
std::string src_path(source.GetPath());
if (src_path.empty())
return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
return Status("unable to get file path for destination");
StreamString command;
if (GetIgnoresRemoteHostname()) {
if (!GetRSyncPrefix())
command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
dst_path.c_str());
else
command.Printf("rsync %s %s %s%s", GetRSyncOpts(), src_path.c_str(),
GetRSyncPrefix(), dst_path.c_str());
} else
command.Printf("rsync %s %s %s:%s", GetRSyncOpts(), src_path.c_str(),
GetHostname(), dst_path.c_str());
LLDB_LOGF(log, "[PutFile] Running command: %s\n", command.GetData());
int retcode;
Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr,
nullptr, std::chrono::minutes(1));
if (retcode == 0) {
// Don't chown a local file for a remote system
// if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
// return Status("unable to perform chown");
return Status();
}
// if we are still here rsync has failed - let's try the slow way before
// giving up
}
}
return Platform::PutFile(source, destination, uid, gid);
}
lldb_private::Status PlatformPOSIX::GetFile(
const lldb_private::FileSpec &source, // remote file path
const lldb_private::FileSpec &destination) // local file path
{
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
// Check the args, first.
std::string src_path(source.GetPath());
if (src_path.empty())
return Status("unable to get file path for source");
std::string dst_path(destination.GetPath());
if (dst_path.empty())
return Status("unable to get file path for destination");
if (IsHost()) {
if (source == destination)
return Status("local scenario->source and destination are the same file "
"path: no operation performed");
// cp src dst
StreamString cp_command;
cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
RunShellCommand(cp_command.GetData(), FileSpec(), &status, nullptr, nullptr,
std::chrono::seconds(10));
if (status != 0)
return Status("unable to perform copy");
return Status();
} else if (m_remote_platform_sp) {
if (GetSupportsRSync()) {
StreamString command;
if (GetIgnoresRemoteHostname()) {
if (!GetRSyncPrefix())
command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
dst_path.c_str());
else
command.Printf("rsync %s %s%s %s", GetRSyncOpts(), GetRSyncPrefix(),
src_path.c_str(), dst_path.c_str());
} else
command.Printf("rsync %s %s:%s %s", GetRSyncOpts(),
m_remote_platform_sp->GetHostname(), src_path.c_str(),
dst_path.c_str());
LLDB_LOGF(log, "[GetFile] Running command: %s\n", command.GetData());
int retcode;
Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr,
nullptr, std::chrono::minutes(1));
if (retcode == 0)
return Status();
// If we are here, rsync has failed - let's try the slow way before
// giving up
}
// open src and dst
// read/write, read/write, read/write, ...
// close src
// close dst
LLDB_LOGF(log, "[GetFile] Using block by block transfer....\n");
Status error;
user_id_t fd_src = OpenFile(source, File::eOpenOptionRead,
lldb::eFilePermissionsFileDefault, error);
if (fd_src == UINT64_MAX)
return Status("unable to open source file");
uint32_t permissions = 0;
error = GetFilePermissions(source, permissions);
if (permissions == 0)
permissions = lldb::eFilePermissionsFileDefault;
user_id_t fd_dst = FileCache::GetInstance().OpenFile(
destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite |
File::eOpenOptionTruncate,
permissions, error);
if (fd_dst == UINT64_MAX) {
if (error.Success())
error.SetErrorString("unable to open destination file");
}
if (error.Success()) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
uint64_t offset = 0;
error.Clear();
while (error.Success()) {
const uint64_t n_read = ReadFile(fd_src, offset, buffer_sp->GetBytes(),
buffer_sp->GetByteSize(), error);
if (error.Fail())
break;
if (n_read == 0)
break;
if (FileCache::GetInstance().WriteFile(fd_dst, offset,
buffer_sp->GetBytes(), n_read,
error) != n_read) {
if (!error.Fail())
error.SetErrorString("unable to write to destination file");
break;
}
offset += n_read;
}
}
// Ignore the close error of src.
if (fd_src != UINT64_MAX)
CloseFile(fd_src, error);
// And close the dst file descriptot.
if (fd_dst != UINT64_MAX &&
!FileCache::GetInstance().CloseFile(fd_dst, error)) {
if (!error.Fail())
error.SetErrorString("unable to close destination file");
}
return error;
}
return Platform::GetFile(source, destination);
}
std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
StreamString stream;
if (GetSupportsRSync()) {
stream.PutCString("rsync");
if ((GetRSyncOpts() && *GetRSyncOpts()) ||
(GetRSyncPrefix() && *GetRSyncPrefix()) || GetIgnoresRemoteHostname()) {
stream.Printf(", options: ");
if (GetRSyncOpts() && *GetRSyncOpts())
stream.Printf("'%s' ", GetRSyncOpts());
stream.Printf(", prefix: ");
if (GetRSyncPrefix() && *GetRSyncPrefix())
stream.Printf("'%s' ", GetRSyncPrefix());
if (GetIgnoresRemoteHostname())
stream.Printf("ignore remote-hostname ");
}
}
if (GetSupportsSSH()) {
stream.PutCString("ssh");
if (GetSSHOpts() && *GetSSHOpts())
stream.Printf(", options: '%s' ", GetSSHOpts());
}
if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
stream.Printf("cache dir: %s", GetLocalCacheDirectory());
if (stream.GetSize())
return std::string(stream.GetString());
else
return "";
}
const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() {
if (IsRemote() && m_remote_platform_sp)
return m_remote_platform_sp->GetRemoteUnixSignals();
return Platform::GetRemoteUnixSignals();
}
Status PlatformPOSIX::ConnectRemote(Args &args) {
Status error;
if (IsHost()) {
error.SetErrorStringWithFormat(
"can't connect to the host platform '%s', always connected",
GetPluginName().GetCString());
} else {
if (!m_remote_platform_sp)
m_remote_platform_sp =
Platform::Create(ConstString("remote-gdb-server"), error);
if (m_remote_platform_sp && error.Success())
error = m_remote_platform_sp->ConnectRemote(args);
else
error.SetErrorString("failed to create a 'remote-gdb-server' platform");
if (error.Fail())
m_remote_platform_sp.reset();
}
if (error.Success() && m_remote_platform_sp) {
if (m_option_group_platform_rsync.get() &&
m_option_group_platform_ssh.get() &&
m_option_group_platform_caching.get()) {
if (m_option_group_platform_rsync->m_rsync) {
SetSupportsRSync(true);
SetRSyncOpts(m_option_group_platform_rsync->m_rsync_opts.c_str());
SetRSyncPrefix(m_option_group_platform_rsync->m_rsync_prefix.c_str());
SetIgnoresRemoteHostname(
m_option_group_platform_rsync->m_ignores_remote_hostname);
}
if (m_option_group_platform_ssh->m_ssh) {
SetSupportsSSH(true);
SetSSHOpts(m_option_group_platform_ssh->m_ssh_opts.c_str());
}
SetLocalCacheDirectory(
m_option_group_platform_caching->m_cache_dir.c_str());
}
}
return error;
}
Status PlatformPOSIX::DisconnectRemote() {
Status error;
if (IsHost()) {
error.SetErrorStringWithFormat(
"can't disconnect from the host platform '%s', always connected",
GetPluginName().GetCString());
} else {
if (m_remote_platform_sp)
error = m_remote_platform_sp->DisconnectRemote();
else
error.SetErrorString("the platform is not currently connected");
}
return error;
}
lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
Debugger &debugger, Target *target,
Status &error) {
lldb::ProcessSP process_sp;
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (IsHost()) {
if (target == nullptr) {
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
target = new_target_sp.get();
LLDB_LOGF(log, "PlatformPOSIX::%s created new target", __FUNCTION__);
} else {
error.Clear();
LLDB_LOGF(log, "PlatformPOSIX::%s target already existed, setting target",
__FUNCTION__);
}
if (target && error.Success()) {
debugger.GetTargetList().SetSelectedTarget(target);
if (log) {
ModuleSP exe_module_sp = target->GetExecutableModule();
LLDB_LOGF(log, "PlatformPOSIX::%s set selected target to %p %s",
__FUNCTION__, (void *)target,
exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
: "<null>");
}
process_sp =
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
attach_info.GetProcessPluginName(), nullptr);
if (process_sp) {
ListenerSP listener_sp = attach_info.GetHijackListener();
if (listener_sp == nullptr) {
listener_sp =
Listener::MakeListener("lldb.PlatformPOSIX.attach.hijack");
attach_info.SetHijackListener(listener_sp);
}
process_sp->HijackProcessEvents(listener_sp);
error = process_sp->Attach(attach_info);
}
}
} else {
if (m_remote_platform_sp)
process_sp =
m_remote_platform_sp->Attach(attach_info, debugger, target, error);
else
error.SetErrorString("the platform is not currently connected");
}
return process_sp;
}
lldb::ProcessSP
PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new
// target, else use existing one
Status &error) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
LLDB_LOG(log, "target {0}", target);
ProcessSP process_sp;
if (!IsHost()) {
if (m_remote_platform_sp)
process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
target, error);
else
error.SetErrorString("the platform is not currently connected");
return process_sp;
}
//
// For local debugging, we'll insist on having ProcessGDBRemote create the
// process.
//
// Make sure we stop at the entry point
launch_info.GetFlags().Set(eLaunchFlagDebug);
// We always launch the process we are going to debug in a separate process
// group, since then we can handle ^C interrupts ourselves w/o having to
// worry about the target getting them as well.
launch_info.SetLaunchInSeparateProcessGroup(true);
// Ensure we have a target.
if (target == nullptr) {
LLDB_LOG(log, "creating new target");
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
if (error.Fail()) {
LLDB_LOG(log, "failed to create new target: {0}", error);
return process_sp;
}
target = new_target_sp.get();
if (!target) {
error.SetErrorString("CreateTarget() returned nullptr");
LLDB_LOG(log, "error: {0}", error);
return process_sp;
}
}
// Mark target as currently selected target.
debugger.GetTargetList().SetSelectedTarget(target);
// Now create the gdb-remote process.
LLDB_LOG(log, "having target create process with gdb-remote plugin");
process_sp =
target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
if (!process_sp) {
error.SetErrorString("CreateProcess() failed for gdb-remote process");
LLDB_LOG(log, "error: {0}", error);
return process_sp;
}
LLDB_LOG(log, "successfully created process");
// Adjust launch for a hijacker.
ListenerSP listener_sp;
if (!launch_info.GetHijackListener()) {
LLDB_LOG(log, "setting up hijacker");
listener_sp =
Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
launch_info.SetHijackListener(listener_sp);
process_sp->HijackProcessEvents(listener_sp);
}
// Log file actions.
if (log) {
LLDB_LOG(log, "launching process with the following file actions:");
StreamString stream;
size_t i = 0;
const FileAction *file_action;
while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
file_action->Dump(stream);
LLDB_LOG(log, "{0}", stream.GetData());
stream.Clear();
}
}
// Do the launch.
error = process_sp->Launch(launch_info);
if (error.Success()) {
// Handle the hijacking of process events.
if (listener_sp) {
const StateType state = process_sp->WaitForProcessToStop(
llvm::None, nullptr, false, listener_sp);
LLDB_LOG(log, "pid {0} state {0}", process_sp->GetID(), state);
}
// Hook up process PTY if we have one (which we should for local debugging
// with llgs).
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
LLDB_LOG(log, "hooked up STDIO pty to process");
} else
LLDB_LOG(log, "not using process STDIO pty");
} else {
LLDB_LOG(log, "{0}", error);
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
// we delete the process? Does our caller do that?
}
return process_sp;
}
void PlatformPOSIX::CalculateTrapHandlerSymbolNames() {
m_trap_handlers.push_back(ConstString("_sigtramp"));
}
Status PlatformPOSIX::EvaluateLibdlExpression(
lldb_private::Process *process, const char *expr_cstr,
llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
DynamicLoader *loader = process->GetDynamicLoader();
if (loader) {
Status error = loader->CanLoadImage();
if (error.Fail())
return error;
}
ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread());
if (!thread_sp)
return Status("Selected thread isn't valid");
StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
if (!frame_sp)
return Status("Frame 0 isn't valid");
ExecutionContext exe_ctx;
frame_sp->CalculateExecutionContext(exe_ctx);
EvaluateExpressionOptions expr_options;
expr_options.SetUnwindOnError(true);
expr_options.SetIgnoreBreakpoints(true);
expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
expr_options.SetLanguage(eLanguageTypeC_plus_plus);
expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
// don't do the work to trap them.
expr_options.SetTimeout(process->GetUtilityExpressionTimeout());
Status expr_error;
ExpressionResults result =
UserExpression::Evaluate(exe_ctx, expr_options, expr_cstr, expr_prefix,
result_valobj_sp, expr_error);
if (result != eExpressionCompleted)
return expr_error;
if (result_valobj_sp->GetError().Fail())
return result_valobj_sp->GetError();
return Status();
}
std::unique_ptr<UtilityFunction>
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
Status &error) {
// Remember to prepend this with the prefix from
// GetLibdlFunctionDeclarations. The returned values are all in
// __lldb_dlopen_result for consistency. The wrapper returns a void * but
// doesn't use it because UtilityFunctions don't work with void returns at
// present.
static const char *dlopen_wrapper_code = R"(
struct __lldb_dlopen_result {
void *image_ptr;
const char *error_str;
};
extern void *memcpy(void *, const void *, size_t size);
extern size_t strlen(const char *);
void * __lldb_dlopen_wrapper (const char *name,
const char *path_strings,
char *buffer,
__lldb_dlopen_result *result_ptr)
{
// This is the case where the name is the full path:
if (!path_strings) {
result_ptr->image_ptr = dlopen(name, 2);
if (result_ptr->image_ptr)
result_ptr->error_str = nullptr;
return nullptr;
}
// This is the case where we have a list of paths:
size_t name_len = strlen(name);
while (path_strings && path_strings[0] != '\0') {
size_t path_len = strlen(path_strings);
memcpy((void *) buffer, (void *) path_strings, path_len);
buffer[path_len] = '/';
char *target_ptr = buffer+path_len+1;
memcpy((void *) target_ptr, (void *) name, name_len + 1);
result_ptr->image_ptr = dlopen(buffer, 2);
if (result_ptr->image_ptr) {
result_ptr->error_str = nullptr;
break;
}
result_ptr->error_str = dlerror();
path_strings = path_strings + path_len + 1;
}
return nullptr;
}
)";
static const char *dlopen_wrapper_name = "__lldb_dlopen_wrapper";
Process *process = exe_ctx.GetProcessSP().get();
// Insert the dlopen shim defines into our generic expression:
std::string expr(std::string(GetLibdlFunctionDeclarations(process)));
expr.append(dlopen_wrapper_code);
Status utility_error;
DiagnosticManager diagnostics;
std::unique_ptr<UtilityFunction> dlopen_utility_func_up(process
->GetTarget().GetUtilityFunctionForLanguage(expr.c_str(),
eLanguageTypeObjC,
dlopen_wrapper_name,
utility_error));
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not make utility"
"function: %s", utility_error.AsCString());
return nullptr;
}
if (!dlopen_utility_func_up->Install(diagnostics, exe_ctx)) {
error.SetErrorStringWithFormat("dlopen error: could not install utility"
"function: %s",
diagnostics.GetString().c_str());
return nullptr;
}
Value value;
ValueList arguments;
FunctionCaller *do_dlopen_function = nullptr;
// Fetch the clang types we will need:
TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast)
return nullptr;
CompilerType clang_void_pointer_type
= ast->GetBasicType(eBasicTypeVoid).GetPointerType();
CompilerType clang_char_pointer_type
= ast->GetBasicType(eBasicTypeChar).GetPointerType();
// We are passing four arguments, the basename, the list of places to look,
// a buffer big enough for all the path + name combos, and
// a pointer to the storage we've made for the result:
value.SetValueType(Value::eValueTypeScalar);
value.SetCompilerType(clang_void_pointer_type);
arguments.PushValue(value);
value.SetCompilerType(clang_char_pointer_type);
arguments.PushValue(value);
arguments.PushValue(value);
arguments.PushValue(value);
do_dlopen_function = dlopen_utility_func_up->MakeFunctionCaller(
clang_void_pointer_type, arguments, exe_ctx.GetThreadSP(), utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not make function"
"caller: %s", utility_error.AsCString());
return nullptr;
}
do_dlopen_function = dlopen_utility_func_up->GetFunctionCaller();
if (!do_dlopen_function) {
error.SetErrorString("dlopen error: could not get function caller.");
return nullptr;
}
// We made a good utility function, so cache it in the process:
return dlopen_utility_func_up;
}
uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &remote_file,
const std::vector<std::string> *paths,
lldb_private::Status &error,
lldb_private::FileSpec *loaded_image) {
if (loaded_image)
loaded_image->Clear();
std::string path;
path = remote_file.GetPath();
ThreadSP thread_sp = process->GetThreadList().GetExpressionExecutionThread();
if (!thread_sp) {
error.SetErrorString("dlopen error: no thread available to call dlopen.");
return LLDB_INVALID_IMAGE_TOKEN;
}
DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
thread_sp->CalculateExecutionContext(exe_ctx);
Status utility_error;
UtilityFunction *dlopen_utility_func;
ValueList arguments;
FunctionCaller *do_dlopen_function = nullptr;
// The UtilityFunction is held in the Process. Platforms don't track the
// lifespan of the Targets that use them, we can't put this in the Platform.
dlopen_utility_func = process->GetLoadImageUtilityFunction(
this, [&]() -> std::unique_ptr<UtilityFunction> {
return MakeLoadImageUtilityFunction(exe_ctx, error);
});
// If we couldn't make it, the error will be in error, so we can exit here.
if (!dlopen_utility_func)
return LLDB_INVALID_IMAGE_TOKEN;
do_dlopen_function = dlopen_utility_func->GetFunctionCaller();
if (!do_dlopen_function) {
error.SetErrorString("dlopen error: could not get function caller.");
return LLDB_INVALID_IMAGE_TOKEN;
}
arguments = do_dlopen_function->GetArgumentValues();
// Now insert the path we are searching for and the result structure into the
// target.
uint32_t permissions = ePermissionsReadable|ePermissionsWritable;
size_t path_len = path.size() + 1;
lldb::addr_t path_addr = process->AllocateMemory(path_len,
permissions,
utility_error);
if (path_addr == LLDB_INVALID_ADDRESS) {
error.SetErrorStringWithFormat("dlopen error: could not allocate memory"
"for path: %s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make sure we deallocate the input string memory:
auto path_cleanup = llvm::make_scope_exit([process, path_addr] {
// Deallocate the buffer.
process->DeallocateMemory(path_addr);
});
process->WriteMemory(path_addr, path.c_str(), path_len, utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not write path string:"
" %s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make space for our return structure. It is two pointers big: the token
// and the error string.
const uint32_t addr_size = process->GetAddressByteSize();
lldb::addr_t return_addr = process->CallocateMemory(2*addr_size,
permissions,
utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not allocate memory"
"for path: %s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make sure we deallocate the result structure memory
auto return_cleanup = llvm::make_scope_exit([process, return_addr] {
// Deallocate the buffer
process->DeallocateMemory(return_addr);
});
// This will be the address of the storage for paths, if we are using them,
// or nullptr to signal we aren't.
lldb::addr_t path_array_addr = 0x0;
llvm::Optional<llvm::detail::scope_exit<std::function<void()>>>
path_array_cleanup;
// This is the address to a buffer large enough to hold the largest path
// conjoined with the library name we're passing in. This is a convenience
// to avoid having to call malloc in the dlopen function.
lldb::addr_t buffer_addr = 0x0;
llvm::Optional<llvm::detail::scope_exit<std::function<void()>>>
buffer_cleanup;
// Set the values into our args and write them to the target:
if (paths != nullptr) {
// First insert the paths into the target. This is expected to be a
// continuous buffer with the strings laid out null terminated and
// end to end with an empty string terminating the buffer.
// We also compute the buffer's required size as we go.
size_t buffer_size = 0;
std::string path_array;
for (auto path : *paths) {
// Don't insert empty paths, they will make us abort the path
// search prematurely.
if (path.empty())
continue;
size_t path_size = path.size();
path_array.append(path);
path_array.push_back('\0');
if (path_size > buffer_size)
buffer_size = path_size;
}
path_array.push_back('\0');
path_array_addr = process->AllocateMemory(path_array.size(),
permissions,
utility_error);
if (path_array_addr == LLDB_INVALID_ADDRESS) {
error.SetErrorStringWithFormat("dlopen error: could not allocate memory"
"for path array: %s",
utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make sure we deallocate the paths array.
path_array_cleanup.emplace([process, path_array_addr]() {
// Deallocate the path array.
process->DeallocateMemory(path_array_addr);
});
process->WriteMemory(path_array_addr, path_array.data(),
path_array.size(), utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not write path array:"
" %s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Now make spaces in the target for the buffer. We need to add one for
// the '/' that the utility function will insert and one for the '\0':
buffer_size += path.size() + 2;
buffer_addr = process->AllocateMemory(buffer_size,
permissions,
utility_error);
if (buffer_addr == LLDB_INVALID_ADDRESS) {
error.SetErrorStringWithFormat("dlopen error: could not allocate memory"
"for buffer: %s",
utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make sure we deallocate the buffer memory:
buffer_cleanup.emplace([process, buffer_addr]() {
// Deallocate the buffer.
process->DeallocateMemory(buffer_addr);
});
}
arguments.GetValueAtIndex(0)->GetScalar() = path_addr;
arguments.GetValueAtIndex(1)->GetScalar() = path_array_addr;
arguments.GetValueAtIndex(2)->GetScalar() = buffer_addr;
arguments.GetValueAtIndex(3)->GetScalar() = return_addr;
lldb::addr_t func_args_addr = LLDB_INVALID_ADDRESS;
diagnostics.Clear();
if (!do_dlopen_function->WriteFunctionArguments(exe_ctx,
func_args_addr,
arguments,
diagnostics)) {
error.SetErrorStringWithFormat("dlopen error: could not write function "
"arguments: %s",
diagnostics.GetString().c_str());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Make sure we clean up the args structure. We can't reuse it because the
// Platform lives longer than the process and the Platforms don't get a
// signal to clean up cached data when a process goes away.
auto args_cleanup =
llvm::make_scope_exit([do_dlopen_function, &exe_ctx, func_args_addr] {
do_dlopen_function->DeallocateFunctionResults(exe_ctx, func_args_addr);
});
// Now run the caller:
EvaluateExpressionOptions options;
options.SetExecutionPolicy(eExecutionPolicyAlways);
options.SetLanguage(eLanguageTypeC_plus_plus);
options.SetIgnoreBreakpoints(true);
options.SetUnwindOnError(true);
options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
// don't do the work to trap them.
options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetIsForUtilityExpr(true);
Value return_value;
// Fetch the clang types we will need:
TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast) {
error.SetErrorString("dlopen error: Unable to get TypeSystemClang");
return LLDB_INVALID_IMAGE_TOKEN;
}
CompilerType clang_void_pointer_type
= ast->GetBasicType(eBasicTypeVoid).GetPointerType();
return_value.SetCompilerType(clang_void_pointer_type);
ExpressionResults results = do_dlopen_function->ExecuteFunction(
exe_ctx, &func_args_addr, options, diagnostics, return_value);
if (results != eExpressionCompleted) {
error.SetErrorStringWithFormat("dlopen error: failed executing "
"dlopen wrapper function: %s",
diagnostics.GetString().c_str());
return LLDB_INVALID_IMAGE_TOKEN;
}
// Read the dlopen token from the return area:
lldb::addr_t token = process->ReadPointerFromMemory(return_addr,
utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not read the return "
"struct: %s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
// The dlopen succeeded!
if (token != 0x0) {
if (loaded_image && buffer_addr != 0x0)
{
// Capture the image which was loaded. We leave it in the buffer on
// exit from the dlopen function, so we can just read it from there:
std::string name_string;
process->ReadCStringFromMemory(buffer_addr, name_string, utility_error);
if (utility_error.Success())
loaded_image->SetFile(name_string, llvm::sys::path::Style::posix);
}
return process->AddImageToken(token);
}
// We got an error, lets read in the error string:
std::string dlopen_error_str;
lldb::addr_t error_addr
= process->ReadPointerFromMemory(return_addr + addr_size, utility_error);
if (utility_error.Fail()) {
error.SetErrorStringWithFormat("dlopen error: could not read error string: "
"%s", utility_error.AsCString());
return LLDB_INVALID_IMAGE_TOKEN;
}
size_t num_chars = process->ReadCStringFromMemory(error_addr + addr_size,
dlopen_error_str,
utility_error);
if (utility_error.Success() && num_chars > 0)
error.SetErrorStringWithFormat("dlopen error: %s",
dlopen_error_str.c_str());
else
error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
return LLDB_INVALID_IMAGE_TOKEN;
}
Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
uint32_t image_token) {
const addr_t image_addr = process->GetImagePtrFromToken(image_token);
if (image_addr == LLDB_INVALID_ADDRESS)
return Status("Invalid image token");
StreamString expr;
expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
llvm::StringRef prefix = GetLibdlFunctionDeclarations(process);
lldb::ValueObjectSP result_valobj_sp;
Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
result_valobj_sp);
if (error.Fail())
return error;
if (result_valobj_sp->GetError().Fail())
return result_valobj_sp->GetError();
Scalar scalar;
if (result_valobj_sp->ResolveValue(scalar)) {
if (scalar.UInt(1))
return Status("expression failed: \"%s\"", expr.GetData());
process->ResetImageToken(image_token);
}
return Status();
}
llvm::StringRef
PlatformPOSIX::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
return R"(
extern "C" void* dlopen(const char*, int);
extern "C" void* dlsym(void*, const char*);
extern "C" int dlclose(void*);
extern "C" char* dlerror(void);
)";
}
size_t PlatformPOSIX::ConnectToWaitingProcesses(Debugger &debugger,
Status &error) {
if (m_remote_platform_sp)
return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
return Platform::ConnectToWaitingProcesses(debugger, error);
}
ConstString PlatformPOSIX::GetFullNameForDylib(ConstString basename) {
if (basename.IsEmpty())
return basename;
StreamString stream;
stream.Printf("lib%s.so", basename.GetCString());
return ConstString(stream.GetString());
}
| [
"[email protected]"
] | |
96b29d43cfb6550a6ea9730833282d8c511dd3d0 | 83e79571a6d4d1778d54de3f13d602d5254adcd1 | /src/dal/core/AccessMode.h | db5a2707d54dcbb79e4ae9bd49db3ce790eff9dd | [] | no_license | jjdmol/DAL | d15d15df36956a2f710170b0f058cf93ea93d604 | f2eb2877d606520b1a660b030532c193ab48cdbb | refs/heads/master | 2021-01-16T21:51:41.112844 | 2011-05-17T11:37:40 | 2011-05-17T11:37:40 | 1,733,529 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 14,465 | h | /***************************************************************************
* Copyright (C) 2010 *
* Lars B"ahren <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef ACCESSMODE_H
#define ACCESSMODE_H
#include "HDF5Object.h"
namespace DAL { // Namespace DAL -- begin
/*!
\class AccessMode
\ingroup DAL
\ingroup core
\brief Book-keeping of access properties
\author Lars Bähren
\date 2010/10/19
\test tAccessMode.cc
<h3>Prerequisite</h3>
<ul type="square">
<li>[start filling in your text here]
</ul>
<h3>Synopsis</h3>
Available file access property flags:
<ul>
<li>\b HDF5 <br>
These are the bits that can be passed to the `flags' argument of
\c H5Fcreate() and \c H5Fopen(). Use the bit-wise OR operator (|) to combine
them as needed. As a side effect, they call H5check_version() to make sure
that the application is compiled with a version of the hdf5 header files
which are compatible with the library to which the application is linked.
We're assuming that these constants are used rather early in the hdf5
session.
\code
//____________________________________________________
// H5Fpublic.h
#define H5F_ACC_RDONLY (H5CHECK 0x0000u) // absence of rdwr => rd-only
#define H5F_ACC_RDWR (H5CHECK 0x0001u) // open for read and write
#define H5F_ACC_TRUNC (H5CHECK 0x0002u) // overwrite existing files
#define H5F_ACC_EXCL (H5CHECK 0x0004u) // fail if file already exists
#define H5F_ACC_DEBUG (H5CHECK 0x0008u) // print debug info
#define H5F_ACC_CREAT (H5CHECK 0x0010u) // create non-existing files
\endcode
Four access modes address these concerns, with H5Fcreate and H5Fopen each
accepting two of them:
<ul>
<li>\c H5Fcreate accepts \c H5F_ACC_TRUNC or \c H5F_ACC_EXCL. All newly
created files are opened for both reading and writing.
<li>\c H5Fopen accepts \c H5F_ACC_RDONLY or \c H5F_ACC_RDWR.
</ul>
For more detailed information see chapter 3 ("The HDF5 File") of the
<i>HDF5 User's Guide</i>.
<li>\b CFITSIO <br>
The iomode parameter defines the read/write access allowed in the file and can
have values of:
\code
#define READONLY 0
#define READWRITE 1
\endcode
<li>\b casacore
<li>\b mirlib
\code
//____________________________________________________
// dio.c
if (!strcmp(status,"read")) flags = O_RDONLY;
else if(!strcmp(status,"write")) flags = O_CREAT|O_TRUNC|O_RDWR;
else if(!strcmp(status,"append")) flags = O_CREAT|O_RDWR;
//____________________________________________________
// hio.c
#define ITEM_READ 0x1
#define ITEM_WRITE 0x2
#define ITEM_SCRATCH 0x4
#define ITEM_APPEND 0x8
#define ACCESS_MODE (ITEM_READ|ITEM_WRITE|ITEM_SCRATCH|ITEM_APPEND)
#define RDWR_UNKNOWN 0
#define RDWR_RDONLY 1
#define RDWR_RDWR
\endcode
<li><b>GNU C Library</b>
The file access modes allow a file descriptor to be used for reading,
writing, or both. (In the GNU system, they can also allow none of these,
and allow execution of the file as a program.) The access modes are chosen
when the file is opened, and never change.
<table border=0 width=95%>
<tr valign=top>
<td class="indexkey" width=20%>File Access Modes</td>
<td class="indexkey" width=75%>Description</td>
</tr>
<tr valign=top>
<td>int O_RDONLY</td>
<td>Open the file for read access.</td>
</tr>
<tr valign=top>
<td>int O_WRONLY</td>
<td>Open the file for write access.</td>
</tr>
<tr valign=top>
<td>int O_RDWR</td>
<td>Open the file for both reading and writing.</td>
</tr>
<tr valign=top>
<td class="indexkey" width=20%>Open-time Flags</td>
<td class="indexkey" width=75%>Description</td>
</tr>
<tr valign=top>
<td>int O_CREAT</td>
<td>If set, the file will be created if it doesn't already exist. </td>
</tr>
<tr valign=top>
<td>int O_EXCL</td>
<td>If both \c O_CREAT and \c O_EXCL are set, then open fails if the
specified file already exists. This is guaranteed to never clobber an
existing file. </td>
</tr>
<tr valign=top>
<td>int O_TRUNC</td>
<td>Truncate the file to zero length. This option is only useful for
regular files, not special files such as directories or FIFOs. POSIX.1
requires that you open the file for writing to use O_TRUNC. In BSD and
GNU you must have permission to write the file to truncate it, but you
need not open for write access. </td>
</tr>
</table>
In the GNU system (and not in other systems), \c O_RDONLY and
\c O_WRONLY are independent bits that can be bitwise-ORed together, and
it is valid for either bit to be set or clear. This means that \c O_RDWR
is the same as \c O_RDONLY|\c O_WRONLY. A file access mode of zero is
permissible; it allows no operations that do input or output to the file,
but does allow other operations such as fchmod. On the GNU system, since
“read-only” or “write-only” is a misnomer, \c fcntl.h defines additional
names for the file access modes. These names are preferred when writing
GNU-specific code. But most programs will want to be portable to other
POSIX.1 systems and should use the POSIX.1 names above instead.
<li><b>.NET Framework</b> (System.IO)
<a href="http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx">FileMode
parameters</a> control whether a file is overwritten, created, or
opened, or some combination thereof. Use Open to open an existing file.
To append to a file, use Append. To truncate a file or to create it if it
does not exist, use Create.
A <a href="http://msdn.microsoft.com/en-us/library/4z36sx0f.aspx">FileAccess
parameter</a> is specified in many of the constructors for File,
FileInfo, FileStream, and other constructors where it is important to
control the kind of access users have to a file. Defines constants for
read, write, or read/write access to a file.
<table border=0 width=95%>
<tr valign=top>
<td class="indexkey" width=20%>FileMode parameter</td>
<td class="indexkey" width=75%>Description</td>
</tr>
<tr valign=top>
<td>\c CreateNew</td>
<td>Specifies that the operating system should create a new file. This
requires FileIOPermissionAccess::Write. If the file already exists, an
IOException is thrown.</td>
</tr>
<tr valign=top>
<td>\c Create</td>
<td>Specifies that the operating system should create a new file. If
the file already exists, it will be overwritten. This requires
FileIOPermissionAccess::Write. System.IO.FileMode.Create is equivalent
to requesting that if the file does not exist, use CreateNew; otherwise,
use Truncate. If the file already exists but is a hidden file, an
UnauthorizedAccessException is thrown.</td>
</tr>
<tr valign=top>
<td>\c Open</td>
<td>Specifies that the operating system should open an existing file.
The ability to open the file is dependent on the value specified by
FileAccess. A System.IO::FileNotFoundException is thrown if the file
does not exist.</td>
</tr>
<tr valign=top>
<td>\c OpenOrCreate</td>
<td>Specifies that the operating system should open a file if it
exists; otherwise, a new file should be created. If the file is
opened with FileAccess.Read, FileIOPermissionAccess::Read is required.
If the file access is FileAccess.Write then FileIOPermissionAccess::Write
is required. If the file is opened with FileAccess.ReadWrite, both
FileIOPermissionAccess::Read and FileIOPermissionAccess::Write are
required. If the file access is FileAccess.Append, then
FileIOPermissionAccess::Append is required.</td>
</tr>
<tr valign=top>
<td>\c Truncate</td>
<td>Specifies that the operating system should open an existing file.
Once opened, the file should be truncated so that its size is zero
bytes. This requires FileIOPermissionAccess::Write. Attempts to read
from a file opened with Truncate cause an exception.</td>
</tr>
<tr valign=top>
<td>\c Append</td>
<td>Opens the file if it exists and seeks to the end of the file, or
creates a new file. FileMode.Append can only be used in conjunction
with FileAccess.Write. Attempting to seek to a position before the
end of the file will throw an IOException and any attempt to read
fails and throws an NotSupportedException.</td>
</tr>
<tr valign=top>
<td class="indexkey" width=20%>FileAccess parameter</td>
<td class="indexkey" width=75%>Description</td>
</tr>
<tr valign=top>
<td>\c Read</td>
<td>Read access to the file. Data can be read from the file. Combine
with \c Write for read/write access.</td>
</tr>
<tr valign=top>
<td>\c Write</td>
<td>Write access to the file. Data can be written to the file. Combine
with \c Read for read/write access.</td>
</tr>
<tr valign=top>
<td>\c ReadWrite</td>
<td>Read and write access to the file. Data can be written to and read
from the file.</td>
</tr>
</table>
<li>\b C#
<table border=0 width=95%>
<tr valign=top>
<td class="indexkey" width=20%>FileMode parameter</td>
<td class="indexkey" width=75%>Description</td>
</tr>
<tr valign=top>
<td>\c Append</td>
<td>Opens the file and adds data. This should be used with the
FileAccess Write Enumeration value.</td>
</tr>
<tr valign=top>
<td>\c Create</td>
<td>Creates a new file. Overwrites any existing file.</td>
</tr>
<tr valign=top>
<td>\c CreateNew</td>
<td>Creates a new file. If the file already exists, IOException is
thrown.</td>
</tr>
<tr valign=top>
<td>\c Open</td>
<td>Opens an existing file</td>
</tr>
<tr valign=top>
<td>\c OpenOrCreate</td>
<td>Opens a new file. If there is no file, it creates a new file.</td>
</tr>
<tr valign=top>
<td>\c Truncate</td>
<td>Truncates an existing file</td>
</tr>
<tr valign=top>
<td class="indexkey" width=15%>FileAccess parameter</td>
<td class="indexkey" width=80%>Description</td>
</tr>
<tr valign=top>
<td>\c Read</td>
<td>Data can be read (retrieved) from the file</td>
</tr>
<tr valign=top>
<td>\c ReadWrite</td>
<td>Data can be added to and retrieved from the file</td>
</tr>
<tr valign=top>
<td>\c Write</td>
<td>Data can be added to the file</td>
</tr>
</table>
</ul>
<h3>Example(s)</h3>
*/
class AccessMode {
public:
//! Object mode parameter
enum Mode {
//! Creates a new object. Overwrites any existing object.
Create,
//! Creates a new object. If the object already exists, an exception is thrown.
CreateNew,
//! Opens an existing object.
Open,
//! Opens a new object. If there is no object, it creates a new object.
OpenOrCreate
};
//! Object access parameter
enum Access {
//! Read access to the object
Read,
//! Read and write access to the object
ReadWrite,
//! Write access to the object
Write
};
// === Construction =========================================================
//! Default constructor
AccessMode ();
//! Copy constructor
AccessMode (AccessMode const &other);
// === Destruction ==========================================================
//! Destructor
~AccessMode ();
// === Operators ============================================================
/*!
\brief Overloading of the copy operator
\param other -- Another AccessMode object from which to make a copy.
*/
AccessMode& operator= (AccessMode const &other);
// === Parameter access =====================================================
/*!
\brief Get the name of the class
\return className -- The name of the class, AccessMode.
*/
inline std::string className () const {
return "AccessMode";
}
//! Provide a summary of the object's internal parameters and status
inline void summary () {
summary (std::cout);
}
//! Provide a summary of the object's internal parameters and status
void summary (std::ostream &os);
// === Public methods =======================================================
private:
AccessMode::Mode itsMode;
AccessMode::Access itsAccess;
//! Unconditional copying
void copy (AccessMode const &other);
//! Unconditional deletion
void destroy(void);
}; // Class AccessMode -- end
} // Namespace DAL -- end
#endif /* ACCESSMODE_H */
| [
"[email protected]"
] | |
8aa67b08761d0c944275976e001753bbbe8e6af5 | 879681c994f1ca9c8d2c905a4e5064997ad25a27 | /root-2.3.0/run/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/1.5/Theta.particles | c8e7f286fabe94dc5cdcea3d9caa9fdd56946c6d | [] | no_license | MizuhaWatanabe/OpenFOAM-2.3.0-with-Ubuntu | 3828272d989d45fb020e83f8426b849e75560c62 | daeb870be81275e8a81f5cbac4ca1906a9bc69c0 | refs/heads/master | 2020-05-17T16:36:41.848261 | 2015-04-18T09:29:48 | 2015-04-18T09:29:48 | 34,159,882 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 68,658 | particles | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "1.5";
object Theta.particles;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
6000
(
0.000477276
0.000261034
0.000206542
0.000144292
0.000148636
0.000254099
0.000308979
0.000212226
0.000217925
0.000326842
0.000435336
0.000464299
0.000365723
0.00032316
0.000249215
0.000146751
0.000131304
0.000124361
0.000158332
0.000167166
0.000175923
0.000219756
0.000327755
0.000436092
0.000427065
6.68886e-05
9.69823e-05
0.000141738
0.000141873
0.000426486
4.71045e-05
3.78189e-05
4.5807e-05
4.9614e-05
4.59884e-05
5.45208e-05
5.18259e-05
2.75955e-05
2.54715e-05
4.27095e-05
6.81498e-05
9.61122e-05
6.50457e-05
4.46739e-05
3.1475e-05
1.5652e-05
4.94142e-06
2.57186e-06
3.02868e-06
4.39375e-06
7.25827e-06
1.04567e-05
1.24797e-05
5.35289e-05
6.04873e-05
1.64751e-05
8.50667e-06
2.43564e-05
3.15324e-05
3.44858e-05
0.000407025
0.000467283
0.000476848
0.000363472
0.000170569
6.85606e-05
3.00396e-05
2.89996e-05
3.55316e-05
3.74925e-05
4.87386e-05
0.000166086
0.000312535
0.000239512
0.000290972
0.000383185
0.000347994
0.000328742
0.000286858
0.000267675
0.00028302
0.00031534
0.000297818
0.000561867
9.62443e-05
0.000151166
4.99227e-05
3.85284e-06
2.9854e-06
1.08391e-06
0.00040063
0.000267269
0.000313822
0.000326057
0.000167833
4.83545e-05
1.11329e-05
4.55203e-06
2.43892e-06
1.80591e-06
2.29128e-05
0.000166062
0.000247269
0.00012143
0.000114387
8.46544e-05
4.28465e-05
3.06093e-05
2.19782e-05
2.25225e-05
3.17826e-05
5.00436e-05
7.61209e-05
0.000226467
0.000137391
8.68851e-05
7.16396e-05
1.32566e-06
7.19862e-07
2.69172e-06
0.000120964
1.09585e-05
3.03369e-05
0.00013552
0.000270887
0.000139366
3.42299e-05
2.12357e-05
2.33671e-05
1.6939e-05
1.7053e-05
0.000110869
8.92881e-05
2.37925e-05
1.82001e-05
5.97097e-06
3.31481e-06
3.12185e-06
2.63607e-06
2.2329e-06
1.58298e-06
2.28234e-06
4.51341e-06
2.40284e-05
7.65285e-05
0.000133896
0.000126829
1.15629e-06
2.85849e-07
3.42272e-06
4.39152e-05
7.09845e-07
1.17413e-06
4.54436e-06
7.55832e-05
0.000211737
9.58373e-05
4.33078e-05
3.89811e-05
9.43858e-06
5.69205e-06
4.27895e-05
6.97963e-06
6.40512e-06
4.24444e-06
2.67924e-06
2.96395e-06
2.59633e-06
1.90707e-06
1.51322e-06
1.43828e-06
2.09332e-06
2.21007e-06
2.74669e-06
1.23027e-05
0.000153691
0.000217777
2.29241e-06
1.27665e-07
5.24137e-06
2.92847e-05
7.51131e-07
9.39752e-07
1.74146e-06
2.79206e-06
7.08013e-05
0.000165489
0.000106424
7.33956e-05
1.91079e-05
4.74475e-06
8.40683e-06
3.7403e-06
8.79507e-06
4.38101e-06
3.74822e-06
3.18661e-06
1.62435e-06
9.89268e-07
8.39444e-07
7.36653e-07
9.91442e-07
2.19238e-06
2.05336e-06
2.285e-06
0.000103334
0.00042644
1.00671e-05
1.0602e-06
4.63902e-06
1.5848e-05
1.15271e-06
1.40167e-06
1.57303e-06
1.61599e-06
7.4069e-06
0.000110806
0.000156572
0.000103077
3.43363e-05
4.78393e-06
3.88802e-06
5.33678e-06
7.99335e-06
5.39128e-06
5.96182e-06
2.33759e-06
1.27486e-06
6.41636e-07
3.62641e-07
4.19203e-07
1.3327e-06
2.21766e-06
1.85582e-06
3.19224e-06
1.08442e-05
0.000418692
0.000117356
4.06244e-06
3.81964e-06
7.83381e-06
1.15765e-06
1.67604e-06
2.2274e-06
2.26915e-06
3.1947e-06
5.32721e-05
0.00017103
0.000148814
3.90659e-05
5.16768e-06
4.31783e-06
6.53039e-06
4.33279e-06
4.05328e-06
7.4007e-06
4.70423e-06
3.37151e-06
1.76189e-06
9.88849e-07
1.39536e-06
1.95246e-06
2.22569e-06
2.57513e-06
4.46935e-06
3.65142e-06
0.000219412
0.000194517
6.62461e-06
4.15358e-06
4.0196e-06
1.39077e-06
2.13193e-06
2.68248e-06
2.98555e-06
3.00746e-06
2.43497e-05
0.000153522
0.000168139
4.50087e-05
3.71045e-06
6.91948e-06
8.63309e-06
5.7542e-06
2.13591e-06
4.74078e-06
6.22351e-06
4.04682e-06
1.61504e-06
7.49305e-07
1.60446e-06
2.44199e-06
1.95968e-06
2.66826e-06
5.67267e-06
4.28926e-06
0.000134677
0.000311291
2.36344e-05
6.95624e-06
3.09372e-06
1.63096e-06
2.55899e-06
3.15166e-06
3.52788e-06
3.54901e-06
1.88654e-05
0.000132716
0.000140607
4.8759e-05
2.89875e-06
9.70306e-06
9.96593e-06
1.18466e-05
1.61528e-06
1.86694e-06
2.07647e-06
1.44392e-06
7.03926e-07
9.83841e-07
3.04954e-06
4.65425e-06
3.02791e-06
2.94052e-06
6.21563e-06
5.35455e-06
1.52152e-05
0.000325333
9.63905e-05
3.80795e-05
3.83207e-06
1.92457e-06
2.66208e-06
3.4463e-06
3.18914e-06
3.69208e-06
1.73215e-05
0.000112553
0.000112478
4.20225e-05
2.60105e-06
1.14823e-05
1.38134e-05
2.27301e-05
1.80096e-06
8.27814e-07
6.83084e-07
5.56531e-07
6.56268e-07
1.94505e-06
4.22134e-06
6.6425e-06
6.56108e-06
3.38976e-06
7.41246e-06
7.91223e-06
4.90984e-06
0.000176123
0.000313263
4.48024e-05
5.59725e-06
2.10721e-06
2.49717e-06
3.25331e-06
2.29339e-06
3.87298e-06
1.87109e-05
9.8392e-05
8.58559e-05
1.81202e-05
1.36764e-06
9.86392e-06
2.62502e-05
2.21158e-05
2.96732e-06
5.1295e-07
2.63922e-07
3.56662e-07
1.14158e-06
3.07804e-06
5.67588e-06
7.60407e-06
9.62889e-06
4.39465e-06
1.0199e-05
1.55695e-05
6.39031e-06
4.82197e-05
0.000218198
4.26781e-05
7.99212e-06
2.11347e-06
2.14099e-06
2.5784e-06
1.6406e-06
6.94156e-06
2.6204e-05
5.22514e-05
6.30751e-05
1.35734e-05
3.83345e-06
1.42745e-05
4.39166e-05
2.58231e-05
1.24934e-05
5.66205e-07
1.28614e-07
3.63194e-07
1.42401e-06
3.50067e-06
6.18484e-06
9.03107e-06
1.05634e-05
7.79617e-06
1.1215e-05
2.89632e-05
1.74229e-05
2.58019e-05
0.00012514
0.000103805
1.05454e-05
1.93569e-06
1.63208e-06
1.80018e-06
1.47141e-06
1.05273e-05
4.20283e-05
4.06296e-05
3.62518e-05
9.44036e-06
1.03719e-05
2.21756e-05
5.10027e-05
3.39949e-05
1.93108e-05
2.93414e-07
8.34272e-08
3.13597e-07
1.34707e-06
3.02851e-06
5.18628e-06
7.66515e-06
1.05284e-05
1.27366e-05
7.90207e-06
2.21642e-05
2.63367e-05
3.44141e-05
7.01313e-05
0.000105743
1.2615e-05
1.6578e-06
1.01428e-06
1.3196e-06
1.77294e-06
9.94317e-06
4.65878e-05
2.8532e-05
2.70401e-05
2.01282e-05
1.39314e-05
2.1904e-05
4.21652e-05
3.83651e-05
1.11746e-05
1.37487e-06
1.6847e-07
1.11919e-06
3.29872e-06
5.25971e-06
5.4121e-06
5.61747e-06
6.5861e-06
1.23476e-05
3.70326e-06
9.34043e-06
1.83227e-05
1.04355e-05
5.37306e-05
5.01515e-05
1.29855e-05
1.15876e-06
6.0403e-07
1.26768e-06
3.8172e-06
2.20973e-05
3.70587e-05
6.37235e-05
0.000114548
2.97356e-05
2.33994e-05
4.1935e-05
5.30013e-05
3.87256e-05
1.54234e-05
4.32394e-06
1.9561e-06
7.53966e-06
1.5149e-05
2.59248e-05
1.99436e-05
7.94138e-06
3.17854e-06
3.70976e-06
2.15391e-05
1.65712e-06
1.16225e-05
1.04237e-05
4.19066e-05
3.34809e-05
8.77284e-06
6.57269e-07
5.70603e-07
1.66766e-06
7.29023e-06
4.29918e-05
9.608e-05
0.000248734
6.55029e-05
3.22397e-05
4.61886e-05
7.12344e-05
5.54084e-05
3.62174e-05
1.5533e-05
5.71016e-06
4.11192e-06
1.46718e-05
4.56283e-05
8.51082e-05
6.41767e-05
9.5976e-06
4.11012e-06
5.2906e-06
4.27411e-05
6.65244e-05
0.000148766
0.000192255
8.46573e-05
7.15528e-05
3.46055e-06
6.45011e-07
7.55741e-07
3.66295e-06
9.36794e-06
5.11253e-05
0.000158884
0.000169297
1.26069e-05
1.76998e-05
3.85471e-05
4.0479e-05
3.55595e-05
2.58056e-05
1.30873e-05
4.42502e-06
3.809e-06
3.30975e-05
8.04217e-05
0.000206859
0.0013014
0.00119322
0.000181864
0.000104267
0.000236686
0.00156335
0.00216356
0.00213836
0.00115137
0.000694602
1.9318e-06
2.7811e-06
3.79299e-06
9.54017e-06
9.58366e-06
2.90088e-05
0.000104842
8.87853e-05
9.38252e-06
8.60366e-06
7.26108e-06
1.70268e-05
2.17063e-05
2.25539e-05
1.40951e-05
3.97671e-06
1.06581e-05
2.77522e-05
0.000791599
0.00134357
0.00124148
0.00274252
0.00322466
0.0025334
0.00251195
0.00294195
0.00266412
0.00250115
0.00232625
0.00190981
6.23636e-06
1.03578e-05
3.07172e-05
1.48285e-05
2.2472e-06
1.34834e-05
3.98986e-05
6.08986e-05
1.10698e-05
9.18687e-06
1.12786e-05
9.21248e-06
9.22797e-06
1.5959e-05
1.68692e-05
6.37519e-06
6.43935e-05
0.000929537
0.000746682
0.00010671
7.62694e-06
7.40094e-05
0.00129591
0.00222124
0.0018724
0.000383584
0.000183905
0.000135358
0.000195322
0.00115828
7.62694e-06
8.56439e-05
3.65837e-05
1.69584e-06
5.25394e-06
2.45134e-05
4.7702e-06
4.23648e-05
1.33883e-05
1.26961e-05
1.30912e-05
1.44397e-05
1.2862e-05
9.45724e-06
1.52293e-05
5.60416e-05
0.000778793
0.000391729
4.86928e-07
1.08793e-06
1.0076e-06
6.34817e-07
8.69838e-07
8.8804e-07
5.03671e-07
6.22618e-07
7.12783e-07
6.1425e-07
1.12925e-06
0.000501659
3.09377e-05
4.53955e-05
2.84018e-05
3.05002e-06
1.11281e-05
4.93166e-05
5.33752e-07
2.72811e-05
2.65439e-05
2.40472e-05
1.71845e-05
1.95816e-05
1.70169e-05
1.31177e-05
2.41467e-05
0.000431616
0.000358835
2.07156e-06
8.9939e-07
6.65445e-07
7.0698e-07
5.32344e-07
1.27931e-06
1.15618e-06
8.37489e-07
9.80798e-07
9.61018e-07
9.77874e-07
1.48991e-06
0.00044531
0.000228856
1.00228e-05
4.1984e-06
3.74627e-06
8.90572e-06
8.35951e-05
2.72321e-05
4.55455e-05
8.37884e-05
2.1735e-05
2.39165e-05
2.34268e-05
2.22593e-05
2.01978e-05
0.000139542
0.000784824
3.86203e-06
1.49864e-06
6.06741e-07
8.20724e-07
6.86916e-07
7.49174e-07
1.30544e-06
9.33061e-07
8.61376e-07
1.43149e-06
1.16858e-06
1.08984e-06
1.41725e-06
0.000368286
0.000366518
1.31735e-05
2.90035e-06
3.2662e-06
5.21838e-06
1.47468e-05
0.00014739
7.50604e-05
5.71198e-05
1.23009e-05
3.14971e-05
3.03419e-05
2.81276e-05
3.5165e-05
0.000595437
0.000249385
1.17357e-06
1.21426e-06
1.05753e-06
9.63518e-07
8.00165e-07
7.80173e-07
1.26853e-06
1.11123e-06
1.40527e-06
1.27122e-06
1.13362e-06
1.26832e-06
1.66506e-06
0.000298102
0.000404307
3.81193e-05
2.87303e-06
1.01672e-05
2.0062e-05
3.17368e-05
6.44547e-05
5.74317e-05
5.51585e-05
4.25746e-05
2.70988e-05
2.90495e-05
3.43029e-05
0.000132783
0.000819766
5.10279e-06
1.84791e-06
1.61426e-06
1.2696e-06
1.2848e-06
7.97321e-07
8.93196e-07
1.36809e-06
1.43404e-06
1.65072e-06
1.48121e-06
1.85779e-06
1.70481e-06
2.02343e-06
0.000229834
0.000262061
0.000107559
8.96111e-06
3.14117e-05
4.28341e-05
5.57952e-05
6.33738e-05
7.69095e-05
4.35332e-05
4.42954e-05
2.05425e-05
3.15719e-05
5.06759e-05
0.000561272
0.00021373
2.57029e-06
2.17279e-06
1.75746e-06
1.54991e-06
1.46071e-06
9.84706e-07
1.28584e-06
1.90092e-06
2.00241e-06
1.97284e-06
2.02353e-06
2.28385e-06
2.38354e-06
2.78061e-06
0.000178956
9.68268e-05
0.000162751
3.49475e-05
5.39994e-05
9.9117e-05
6.80571e-05
6.91963e-05
7.25157e-05
5.466e-05
2.83009e-05
3.07887e-05
3.16132e-05
0.000243912
0.000595004
8.9689e-06
4.09401e-06
2.91424e-06
3.13724e-06
2.40731e-06
1.94254e-06
1.08379e-06
1.94195e-06
2.48938e-06
2.44927e-06
2.56229e-06
3.06106e-06
3.21988e-06
3.81601e-06
3.96955e-06
0.000117501
5.62954e-05
0.000145993
4.58222e-05
9.55581e-05
0.000156202
0.00015942
3.61863e-05
8.21327e-05
6.82008e-05
3.05397e-05
2.45326e-05
0.000144374
0.000694341
6.57045e-05
4.28666e-06
4.90923e-06
3.73355e-06
3.73193e-06
2.96212e-06
2.73662e-06
1.95789e-06
3.01159e-06
3.21592e-06
3.18882e-06
3.30763e-06
3.71356e-06
3.88572e-06
4.45034e-06
4.35015e-06
6.56394e-05
4.51245e-05
8.72661e-05
4.2927e-05
4.04544e-05
0.00021641
0.000416339
0.000380178
3.16091e-05
8.31225e-05
4.66424e-05
8.09623e-05
0.000625749
9.50685e-05
5.42608e-06
3.1349e-06
4.58333e-06
4.51783e-06
4.88553e-06
4.41361e-06
3.67543e-06
2.74857e-06
3.59316e-06
3.43636e-06
3.63121e-06
3.92763e-06
3.95169e-06
4.01952e-06
4.42383e-06
4.42123e-06
2.835e-05
2.86386e-05
3.45039e-05
7.80624e-06
1.16589e-05
9.53721e-05
2.85609e-06
8.06728e-05
0.000413179
7.31012e-05
5.41145e-05
0.000485773
0.000148938
9.57479e-06
3.48006e-06
2.32794e-06
1.95936e-06
4.98471e-06
6.81821e-06
6.4721e-06
4.73893e-06
3.57736e-06
3.78746e-06
2.94577e-06
3.15247e-06
3.2591e-06
3.17536e-06
3.02156e-06
3.06815e-06
2.85629e-06
9.72399e-06
1.10234e-05
4.89409e-06
9.29109e-07
1.11381e-05
9.5034e-05
1.1089e-06
4.65984e-06
5.44781e-05
0.000283446
0.000323216
7.08441e-05
1.00085e-05
1.0563e-05
2.90857e-06
1.49415e-06
1.88206e-06
7.29414e-06
1.74178e-05
1.91319e-05
9.06614e-06
3.20215e-06
2.15831e-06
1.81589e-06
1.78152e-06
1.61411e-06
1.44494e-06
1.27777e-06
1.23015e-06
1.31121e-06
2.77823e-06
4.39145e-05
1.37105e-05
3.40947e-06
4.48533e-06
9.27947e-05
7.98728e-05
1.08905e-05
2.48963e-06
6.89519e-05
0.000174502
3.1152e-05
6.656e-06
6.43133e-06
2.91649e-06
9.50439e-07
1.41635e-06
1.18126e-05
3.70911e-05
3.81779e-05
8.72758e-06
3.0233e-06
1.57738e-06
1.01477e-06
6.64657e-07
3.86287e-07
2.13047e-07
1.7191e-07
6.94069e-07
9.24209e-07
1.37718e-06
0.000123477
0.000136261
1.4269e-05
1.50661e-05
0.000204739
0.00120225
0.000661209
0.000169372
2.12928e-06
1.57907e-05
3.31823e-05
2.00574e-05
4.49851e-06
3.95806e-06
2.32334e-06
1.95013e-06
1.05316e-05
2.0808e-05
1.08546e-05
2.87785e-06
2.08724e-06
1.33202e-06
1.01647e-06
1.01969e-06
1.03291e-06
2.04829e-06
4.84879e-06
4.78126e-06
2.51088e-06
2.90235e-06
0.00210866
0.00226864
0.00196718
0.00152623
0.00242462
0.0022808
0.00187583
0.00203419
0.00116353
0.000299939
6.99943e-05
0.000249062
0.000303902
0.000127605
4.57519e-05
7.59972e-06
6.04377e-06
8.63029e-06
5.67937e-06
2.95677e-06
1.94536e-06
1.9576e-06
2.77932e-06
4.96842e-06
8.08996e-06
1.13218e-05
7.83619e-06
7.21401e-06
5.0979e-06
7.68602e-06
0.00294033
0.0028443
0.00434944
0.00385938
0.0026052
0.00113517
0.00119484
0.00222533
0.00353148
0.0026828
0.00186734
0.0024097
0.00249045
0.000861532
8.01758e-05
1.89726e-05
4.0741e-06
4.24032e-06
5.01401e-06
4.86802e-06
2.83088e-06
5.50551e-06
1.04434e-05
1.27298e-05
1.37427e-05
8.23638e-06
4.26296e-06
4.93269e-06
4.50242e-06
2.02492e-05
0.00102883
4.24973e-06
0.00054025
0.00100311
0.000443007
0.000215103
0.000189155
0.00044563
0.00159756
0.00317941
0.00381533
0.00271675
0.00155118
0.00148814
0.000490574
1.69714e-05
5.84073e-06
4.0951e-06
7.61704e-06
7.05141e-06
7.83988e-06
1.34054e-05
1.09072e-05
1.09838e-05
6.31263e-06
3.17649e-06
2.56105e-06
2.8927e-06
2.65509e-06
2.85586e-05
0.00020233
1.22541e-06
4.42957e-07
0.000155296
0.000228812
6.98955e-05
9.8727e-07
6.94419e-06
5.60159e-05
0.000356951
0.000895826
1.57399e-05
6.86956e-07
0.000322258
0.00104406
8.19995e-05
7.99599e-06
9.56572e-06
1.04955e-05
8.52577e-06
1.4929e-05
7.2822e-06
4.92118e-06
3.23325e-06
2.72835e-06
2.34742e-06
2.33385e-06
2.69296e-06
2.91427e-06
1.99609e-05
0.000119672
2.35841e-06
1.83508e-07
0.000112612
0.000248228
0.000112514
3.37591e-06
2.02953e-06
1.43313e-06
1.79614e-07
6.05026e-08
5.63656e-07
3.05614e-06
1.33458e-06
0.000738718
0.000751878
2.11238e-05
1.07062e-05
1.45724e-05
1.50748e-05
6.31931e-06
3.54047e-06
2.72914e-06
2.44439e-06
2.32545e-06
2.60119e-06
3.58323e-06
3.65146e-06
3.99246e-06
1.19847e-05
9.66848e-05
6.40733e-06
2.49913e-07
0.000103853
0.000250699
0.000148626
1.58187e-05
1.98765e-06
2.2765e-06
7.02273e-07
1.97867e-07
5.24093e-07
2.78193e-06
4.57022e-06
0.000102681
0.00115914
0.000446669
2.66533e-05
1.40458e-05
6.96079e-06
3.54904e-06
3.05154e-06
2.53149e-06
2.77076e-06
3.63583e-06
4.20842e-06
4.08357e-06
4.10819e-06
4.16562e-06
3.93351e-06
0.0001539
2.09837e-05
4.32875e-07
5.08011e-05
0.000216763
0.000196408
5.35319e-05
2.91343e-06
3.04212e-06
1.38238e-06
3.45075e-07
7.23878e-07
1.91436e-06
7.34709e-06
2.21669e-05
0.000271708
0.000595294
0.000132124
1.04468e-05
5.6924e-06
2.68866e-06
2.90937e-06
3.86025e-06
4.01966e-06
4.50068e-06
4.158e-06
3.88527e-06
4.26936e-06
2.50101e-06
1.62468e-06
0.000433819
5.60254e-05
2.18344e-07
1.30931e-05
0.000150304
0.000143139
9.90601e-05
1.39883e-05
3.99871e-06
2.23037e-06
5.34972e-07
9.00722e-07
1.39724e-06
1.57252e-05
2.51664e-05
2.29645e-05
0.000184162
0.000113538
1.54391e-05
3.55014e-06
3.91149e-06
4.20935e-06
4.07637e-06
4.5706e-06
4.71983e-06
3.24807e-06
1.62634e-06
1.65189e-06
4.93733e-06
3.04929e-06
0.000687313
1.73271e-05
1.30719e-08
1.52618e-06
7.95871e-05
8.05326e-05
9.62725e-05
6.54731e-05
4.43136e-06
2.30682e-06
4.82082e-07
6.41472e-07
2.73082e-06
4.08385e-05
1.22309e-05
5.81883e-06
7.02757e-05
8.56051e-05
1.34215e-05
4.56626e-06
4.30323e-06
4.97749e-06
4.74299e-06
2.58695e-06
1.97724e-06
1.99372e-06
1.97545e-06
2.12842e-06
5.25269e-06
1.20853e-05
0.000541274
2.0764e-06
8.44204e-08
7.56198e-07
2.44773e-05
4.41188e-05
5.38744e-05
0.00010137
7.59891e-06
2.92367e-06
6.27379e-07
5.82727e-07
7.01234e-06
2.40509e-05
2.74993e-06
2.16302e-05
5.34753e-05
1.97794e-05
6.55563e-06
5.04077e-06
2.84575e-06
2.00568e-06
1.92524e-06
2.89271e-06
2.29426e-06
4.05585e-06
7.01354e-06
5.53933e-06
3.80911e-06
2.05594e-05
0.000476074
1.77543e-06
2.84881e-07
8.00199e-07
1.14918e-05
1.68769e-05
2.92983e-05
9.03566e-05
2.2088e-05
3.37154e-06
1.0896e-06
1.06273e-06
2.12781e-05
1.10015e-05
1.52458e-06
2.66348e-05
3.86859e-05
7.8593e-06
3.63567e-06
2.36004e-06
2.1403e-06
2.92362e-06
2.64932e-06
3.05754e-06
6.95317e-06
5.95055e-06
5.66517e-06
6.43823e-06
6.17394e-06
1.59645e-05
0.000479268
1.36699e-06
7.79594e-07
7.69832e-07
6.26602e-06
6.32143e-06
1.17664e-05
6.57179e-05
4.7891e-05
3.72912e-06
2.11093e-06
3.50812e-06
3.14914e-05
3.63567e-06
1.63672e-06
2.06834e-05
2.68922e-05
5.46523e-06
2.91104e-06
3.0942e-06
2.98965e-06
2.60725e-06
5.34779e-06
8.49344e-06
6.96455e-06
6.15873e-06
6.45344e-06
7.6497e-06
7.04584e-06
6.67083e-06
0.000464281
9.31652e-07
1.47123e-06
1.17738e-06
4.36563e-06
3.75578e-06
3.43776e-06
5.0721e-05
6.8829e-05
6.33962e-06
3.8346e-06
9.91699e-06
1.81675e-05
1.8355e-06
2.4006e-06
9.59206e-06
1.62351e-05
6.23645e-06
4.62563e-06
4.40077e-06
5.13297e-06
6.58843e-06
6.15203e-06
5.55035e-06
6.40862e-06
6.161e-06
7.23718e-06
9.36082e-06
4.65586e-06
2.87202e-06
0.000435616
1.47967e-06
1.5523e-06
1.31054e-06
3.98689e-06
2.83855e-06
2.03046e-06
3.40602e-05
5.30277e-05
1.45469e-05
4.24707e-06
1.93732e-05
8.48888e-06
1.63356e-06
2.47971e-06
2.51242e-06
3.81209e-06
5.32848e-06
3.89823e-06
3.59165e-06
3.38934e-06
3.48814e-06
3.63122e-06
3.68473e-06
4.41818e-06
6.48077e-06
5.34183e-06
2.88325e-06
2.77019e-06
5.06328e-06
0.000396012
3.25287e-06
1.78322e-06
1.50409e-06
2.57401e-06
2.01027e-06
2.14423e-06
2.83612e-05
3.12096e-05
3.94249e-06
4.18053e-06
3.025e-05
4.17009e-06
1.54152e-06
1.96242e-06
1.48391e-06
9.84612e-07
5.38009e-07
5.52265e-07
7.62771e-07
1.09995e-06
1.70868e-06
2.42067e-06
2.96644e-06
3.22915e-06
2.40683e-06
1.53745e-06
2.01828e-06
3.71003e-06
2.51715e-06
0.000344286
4.87458e-06
2.20121e-06
1.76312e-06
2.52724e-06
2.21912e-06
2.66168e-06
2.18164e-05
2.61393e-05
2.48737e-06
7.85856e-06
2.69881e-05
2.78917e-06
1.90726e-06
1.5371e-06
1.31109e-06
5.70695e-07
4.37088e-07
5.6025e-07
6.89955e-07
8.55377e-07
1.09011e-06
1.24021e-06
1.53242e-06
1.77029e-06
1.68788e-06
1.47383e-06
1.72475e-06
1.17919e-06
3.13142e-06
0.00030752
5.67751e-06
2.39804e-06
2.2425e-06
3.39504e-06
1.55897e-06
1.96664e-06
2.03129e-05
5.14562e-05
3.81173e-06
8.08464e-06
1.41266e-05
2.20568e-06
1.78286e-06
1.38621e-06
9.44536e-07
7.46281e-07
7.06289e-07
6.69501e-07
6.45861e-07
8.3663e-07
1.37474e-06
1.90807e-06
2.17573e-06
2.17164e-06
2.17053e-06
2.24397e-06
2.45543e-06
3.4531e-06
3.01315e-06
0.000267387
6.45801e-06
2.85785e-06
3.05806e-06
2.61579e-06
9.66338e-07
2.1081e-06
2.81118e-05
8.08684e-05
2.98268e-06
3.80586e-06
1.13532e-05
3.2135e-06
2.85567e-06
1.83149e-06
6.26562e-07
4.49819e-07
4.6535e-07
5.55538e-07
8.11089e-07
1.86025e-06
4.23695e-06
3.98074e-06
4.75889e-06
4.2349e-06
3.64163e-06
3.68057e-06
3.65357e-06
3.64375e-06
4.18786e-06
0.000231482
6.87283e-06
3.32377e-06
3.90245e-06
1.70652e-06
1.57932e-06
7.657e-06
3.4865e-05
8.12187e-06
4.3354e-06
5.35344e-06
1.89666e-05
5.01709e-06
2.1072e-06
4.82168e-07
3.99589e-07
3.31077e-07
4.53083e-07
7.92961e-07
1.7911e-06
2.07895e-06
2.78841e-06
7.28691e-06
4.41801e-06
4.20031e-06
4.1252e-06
3.82089e-06
3.75569e-06
3.47285e-06
3.19114e-06
0.000188219
1.10292e-05
3.14606e-06
4.94097e-06
2.6927e-06
5.81158e-06
9.11952e-06
3.78232e-06
1.90584e-06
6.46394e-06
1.6671e-05
2.40611e-05
3.15538e-06
3.83002e-06
1.89645e-06
2.49508e-06
6.23064e-07
4.21361e-07
8.17606e-07
1.06442e-06
4.0013e-06
3.62155e-06
2.44142e-06
3.22382e-06
2.31051e-06
2.00605e-06
2.02991e-06
2.21709e-06
2.20616e-06
2.18456e-06
0.000122748
1.13703e-05
2.13659e-06
6.41263e-06
6.54757e-06
4.88109e-06
1.69451e-06
1.23634e-06
4.70448e-06
2.26808e-05
0.000166563
0.00043335
8.78631e-05
5.18585e-05
7.38176e-05
5.62134e-06
2.78473e-06
6.44166e-08
1.54757e-06
4.05193e-06
2.5081e-06
2.04897e-06
1.06774e-06
8.9368e-07
9.84825e-07
1.23004e-06
1.29005e-06
1.43671e-06
1.46722e-06
1.76094e-06
9.68016e-05
1.74716e-05
1.50424e-06
8.30376e-06
4.18958e-06
4.4752e-07
7.0707e-07
2.13226e-06
8.72639e-06
6.11401e-05
0.00021691
0.000874927
0.00154684
0.00152492
0.00187163
0.00175213
1.20215e-05
7.89724e-07
6.34884e-06
4.22403e-06
2.10764e-06
8.4344e-07
7.78689e-07
8.07827e-07
1.20352e-06
6.95128e-07
8.02439e-07
1.12294e-06
1.30856e-06
1.89908e-06
8.09824e-05
1.90036e-05
2.76152e-06
1.35029e-05
2.31148e-06
2.06608e-06
3.82144e-06
1.16693e-05
2.56301e-05
0.000208447
0.000906083
0.000591489
0.00108654
0.00188492
0.00205533
0.00548913
0.00198598
3.16952e-06
1.52252e-06
4.15522e-06
1.63922e-06
2.04531e-06
2.94224e-06
1.29406e-06
9.1065e-07
2.77005e-06
1.88445e-06
1.45817e-06
1.5781e-06
1.7766e-06
7.65737e-05
5.36585e-05
8.73524e-06
4.50772e-06
5.25195e-06
7.27065e-06
1.62074e-05
4.05466e-05
0.000765468
0.00193299
0.00121251
0.000165538
1.42841e-05
6.75822e-07
1.76954e-07
0.0001671
0.00472241
0.00042829
4.29004e-06
4.51225e-06
3.2604e-06
4.53883e-06
1.57473e-05
2.04562e-05
9.95156e-06
3.82003e-06
2.41407e-06
2.24597e-06
1.43121e-06
1.28905e-06
7.08039e-05
7.89428e-05
1.11006e-05
7.40863e-06
1.00792e-05
0.000455821
0.000798286
0.00195813
0.00286987
0.00139366
0.000247864
2.1394e-05
3.39053e-07
3.13363e-07
4.7049e-07
2.2651e-07
0.0017995
0.00145302
4.1126e-05
4.74845e-06
7.87317e-06
2.12168e-05
1.26115e-05
9.22011e-06
6.30178e-06
3.64537e-06
3.06626e-06
1.95287e-06
8.72638e-07
8.70532e-07
6.95415e-05
0.000121936
5.92298e-06
2.78696e-05
0.000741353
0.00133403
0.00236866
0.00245813
0.0011286
0.000243406
9.53705e-06
8.51422e-07
3.44078e-07
4.49715e-07
4.71045e-07
4.67896e-07
9.28161e-05
0.00273993
0.000353455
7.36677e-06
1.73601e-05
9.0065e-06
1.66608e-05
2.03888e-05
1.04591e-05
3.70596e-06
2.33992e-06
1.03489e-06
5.48153e-07
6.71319e-07
5.48738e-05
0.000134637
4.87486e-06
0.000460023
0.00164351
0.000964162
0.00101864
0.000499791
8.85028e-05
3.34608e-06
5.78196e-07
6.13272e-07
3.66064e-07
4.59197e-07
6.31216e-07
6.95465e-07
2.80021e-07
0.00171358
0.00201434
0.000116234
5.48463e-06
1.35341e-05
2.19533e-05
1.47688e-05
1.65522e-05
6.72116e-06
1.21614e-06
4.24488e-07
3.84149e-07
5.80121e-07
4.34459e-05
0.000119802
4.92833e-05
0.000701324
0.000986809
0.000344102
8.32304e-05
8.4384e-06
8.55555e-07
3.37714e-07
5.40576e-07
5.33505e-07
3.55991e-07
5.34629e-07
8.18068e-07
7.57712e-07
5.96508e-07
8.69172e-07
0.00216216
0.000787581
3.05764e-05
4.6102e-06
1.86506e-06
2.77079e-06
2.65538e-06
3.24223e-06
5.29114e-07
1.79432e-07
2.614e-07
4.94309e-07
0.000225718
0.000144055
0.0022584
0.00208222
0.000520193
2.06217e-05
1.72673e-06
4.64591e-07
4.64913e-07
4.57606e-07
3.92305e-07
4.95804e-07
4.27535e-07
6.79519e-07
9.43934e-07
8.12782e-07
5.09434e-07
1.14312e-06
0.000808861
0.00124093
2.21309e-05
2.68998e-06
1.3003e-06
1.3849e-06
1.59865e-06
5.81335e-07
1.28004e-07
1.16194e-07
1.87865e-07
3.98508e-07
0.000941934
0.00129779
0.00288804
0.00123532
1.90569e-05
1.07224e-06
6.71913e-07
5.32769e-07
3.72055e-07
4.19485e-07
5.01645e-07
5.11992e-07
5.50067e-07
9.4889e-07
8.70653e-07
7.39397e-07
1.14734e-06
1.47077e-06
0.000286652
0.002667
0.00022174
2.11834e-05
1.37994e-05
4.50503e-06
9.84755e-07
2.55571e-07
1.37913e-07
1.18998e-07
1.68224e-07
3.5842e-07
0.000932073
0.00225298
0.000305213
1.87534e-06
9.1738e-07
8.84492e-07
6.2555e-07
5.57797e-07
4.85554e-07
4.45783e-07
5.73391e-07
5.58172e-07
6.76143e-07
1.00481e-06
9.27872e-07
1.2995e-06
1.60198e-06
1.69946e-06
1.2185e-06
0.00168798
0.00119063
9.77957e-05
2.75625e-05
5.83999e-06
4.91853e-07
1.71383e-07
1.18727e-07
1.22252e-07
1.8019e-07
3.01905e-07
0.000513375
0.000256123
3.30067e-07
4.25968e-07
4.03888e-07
5.82876e-07
5.21403e-07
5.03133e-07
4.86984e-07
5.83845e-07
6.59528e-07
5.22112e-07
9.55501e-07
1.20648e-06
1.23533e-06
1.71004e-06
1.73058e-06
1.68577e-06
3.00113e-06
9.62556e-05
0.00102151
0.000287108
7.6473e-06
8.15113e-07
1.52021e-07
1.21292e-07
1.32249e-07
1.57445e-07
2.08494e-07
2.88896e-07
0.000350535
1.7007e-07
1.43467e-07
2.31863e-07
3.89635e-07
4.43362e-07
5.17545e-07
5.62801e-07
4.87441e-07
6.78514e-07
7.00715e-07
6.86146e-07
1.24771e-06
1.27325e-06
1.63833e-06
1.98701e-06
2.02218e-06
2.13781e-06
3.8426e-06
0.000368025
0.000872676
9.23987e-05
6.5886e-07
1.53973e-07
1.35362e-07
1.85313e-07
2.44418e-07
3.14989e-07
4.39627e-07
6.54683e-07
0.000346123
2.52552e-07
2.01798e-07
2.6228e-07
3.60343e-07
4.52856e-07
5.50516e-07
5.37917e-07
5.94702e-07
8.5252e-07
7.29847e-07
9.80701e-07
1.36583e-06
1.56971e-06
1.81321e-06
2.30668e-06
2.56502e-06
2.95192e-06
5.35587e-06
0.000395047
0.00092342
7.95385e-05
2.4633e-07
1.58187e-07
2.7186e-07
4.45009e-07
6.09633e-07
7.68899e-07
8.48365e-07
9.55631e-07
0.000300937
3.15447e-07
3.35772e-07
3.7313e-07
4.83454e-07
5.08985e-07
5.67532e-07
6.74245e-07
7.51072e-07
8.14617e-07
9.34146e-07
1.30226e-06
1.61697e-06
1.57904e-06
2.21367e-06
3.15869e-06
2.9789e-06
3.52835e-06
1.00871e-05
0.000562147
0.000782628
2.09583e-05
1.8955e-07
4.03871e-07
8.09855e-07
1.25205e-06
1.62234e-06
1.78612e-06
1.7429e-06
1.49766e-06
0.000251086
4.02089e-07
4.33253e-07
4.85397e-07
5.61064e-07
6.18832e-07
6.71789e-07
7.72517e-07
9.13294e-07
1.00025e-06
1.26668e-06
1.57501e-06
1.54612e-06
2.07442e-06
3.19084e-06
3.47554e-06
2.87276e-06
4.64311e-06
2.51822e-05
0.00038386
0.000819642
3.96959e-07
6.73901e-07
1.34265e-06
2.18143e-06
3.0484e-06
3.58529e-06
3.69256e-06
3.94752e-06
4.50234e-06
0.00020891
4.91116e-07
5.12534e-07
5.94179e-07
6.72767e-07
7.35387e-07
7.99609e-07
9.5543e-07
1.08367e-06
1.25519e-06
1.50184e-06
1.73683e-06
2.22291e-06
3.10164e-06
3.55798e-06
3.29723e-06
2.83482e-06
8.37665e-06
0.000276747
0.000344969
9.26736e-05
1.17194e-06
2.17282e-06
3.34632e-06
4.67056e-06
6.21326e-06
6.81646e-06
6.75189e-06
7.62369e-06
8.8534e-06
0.000166219
5.37324e-07
6.27251e-07
6.87317e-07
7.48485e-07
9.05939e-07
9.99545e-07
1.09874e-06
1.34489e-06
1.64965e-06
1.72253e-06
2.43048e-06
3.33491e-06
3.66263e-06
3.93232e-06
3.10944e-06
4.52713e-06
3.19904e-05
0.000219086
0.000577369
2.43005e-06
3.64114e-06
4.77177e-06
7.56729e-06
1.1895e-05
1.14983e-05
1.20637e-05
9.77141e-06
1.12834e-05
1.35666e-05
0.000129829
6.18387e-07
6.9288e-07
8.60419e-07
9.08046e-07
1.00716e-06
1.25494e-06
1.3958e-06
1.76506e-06
2.08261e-06
2.33801e-06
3.37581e-06
4.23283e-06
4.41557e-06
3.83226e-06
3.94048e-06
1.15917e-05
0.000134253
0.000238264
2.26815e-05
6.67362e-06
7.47618e-06
9.41359e-06
1.53008e-05
1.47639e-05
2.18142e-05
1.92992e-05
1.17612e-05
1.36077e-05
2.00865e-05
9.58883e-05
7.54826e-07
8.28861e-07
9.54066e-07
1.20983e-06
1.24822e-06
1.45157e-06
1.88862e-06
2.41875e-06
2.8339e-06
3.11654e-06
4.07056e-06
4.7677e-06
4.03325e-06
3.42995e-06
6.99301e-06
5.94878e-05
8.81877e-05
8.21525e-05
1.35043e-05
1.20189e-05
8.07761e-06
1.10058e-05
3.37718e-05
4.64422e-05
3.15046e-05
1.57761e-05
8.10245e-06
1.80324e-05
3.74874e-05
6.64293e-05
9.09662e-07
1.04809e-06
1.22139e-06
1.3631e-06
1.63757e-06
2.03406e-06
2.53744e-06
3.41195e-06
3.46702e-06
3.48478e-06
4.05632e-06
3.84444e-06
2.61898e-06
3.44315e-06
2.45629e-05
3.84096e-05
6.23706e-05
1.42258e-05
1.37852e-05
7.14806e-06
5.78778e-06
1.0027e-05
5.41728e-05
5.67602e-05
1.76517e-05
5.79906e-06
1.58904e-05
3.78989e-05
8.67854e-05
4.14566e-05
1.16594e-06
1.28934e-06
1.53505e-06
1.8275e-06
2.13927e-06
2.75567e-06
3.69912e-06
4.32114e-06
3.93389e-06
3.33161e-06
2.50487e-06
1.94915e-06
1.49437e-06
8.42829e-06
1.9457e-05
2.35371e-05
9.77104e-06
1.05073e-05
6.41235e-06
4.18004e-06
4.01369e-06
3.60603e-05
3.89082e-05
2.82588e-05
1.10068e-05
1.24241e-05
3.63898e-05
0.000384738
0.00225927
2.32014e-05
1.48068e-06
1.66616e-06
2.00496e-06
2.48072e-06
2.9639e-06
3.66493e-06
4.89171e-06
4.98994e-06
3.34892e-06
1.92393e-06
8.96637e-07
7.5371e-07
1.93502e-06
1.01623e-05
1.40356e-05
8.20238e-06
7.16013e-06
5.83703e-06
4.13068e-06
2.20665e-06
5.07039e-06
2.90303e-05
4.81153e-05
1.1019e-05
9.42594e-06
1.58345e-05
7.27112e-06
0.00239151
0.00801203
1.13694e-05
1.97975e-06
2.21328e-06
2.75078e-06
3.4258e-06
3.91253e-06
4.42943e-06
4.72155e-06
3.68769e-06
2.04729e-06
8.4692e-07
2.94396e-07
2.89738e-07
3.32519e-06
9.29525e-06
1.2019e-05
4.96214e-06
4.54622e-06
4.17497e-06
2.5122e-06
1.55651e-06
7.04115e-06
2.78271e-05
9.48158e-05
6.09405e-06
1.43854e-06
1.20557e-07
0.00317162
0.0116986
0.00382766
5.28383e-06
2.70373e-06
3.12074e-06
3.81169e-06
4.50042e-06
4.38573e-06
3.82648e-06
3.05806e-06
2.14052e-06
1.9122e-06
1.72444e-06
5.07432e-07
7.34493e-08
2.75611e-06
9.68989e-06
7.06057e-06
3.66057e-06
3.28266e-06
2.70522e-06
1.71452e-06
1.55029e-06
5.6749e-06
3.25185e-05
0.00016465
1.82268e-05
8.71445e-05
0.00399479
0.0154284
0.00394425
0.00151284
3.61264e-06
3.75935e-06
4.40377e-06
4.99274e-06
4.75816e-06
3.51393e-06
2.06283e-06
1.28247e-06
2.69259e-06
5.63725e-06
5.35129e-06
1.6597e-06
8.2232e-08
2.33771e-06
6.50893e-06
4.64994e-06
2.75033e-06
2.59155e-06
1.85023e-06
1.44475e-06
2.27045e-06
4.97245e-06
2.25621e-05
0.000292862
0.000635582
0.0047311
0.0155154
0.00447344
1.4878e-05
0.00156451
5.27435e-06
5.10665e-06
5.57461e-06
5.11073e-06
3.92842e-06
2.46581e-06
1.96939e-06
2.03314e-06
3.56827e-06
6.71484e-06
6.97495e-06
2.71145e-06
5.64855e-07
2.88472e-06
4.83555e-06
3.59944e-06
2.28648e-06
1.93259e-06
1.42312e-06
1.50061e-06
3.26141e-06
1.41054e-05
0.00022222
0.000605253
0.0035806
0.0121988
0.00389249
7.84297e-06
3.0117e-06
0.00153391
1.05444e-05
5.48733e-06
5.52389e-06
4.18844e-06
3.83392e-06
4.48767e-06
4.27739e-06
3.53036e-06
3.72086e-06
5.14661e-06
6.47148e-06
3.51507e-06
1.61941e-06
4.12589e-06
4.67052e-06
2.96549e-06
1.97565e-06
1.37626e-06
1.12748e-06
2.05288e-06
1.32145e-05
0.000274649
0.000555245
0.00156159
0.0116362
0.00695608
1.19788e-05
6.51959e-06
1.51392e-06
0.00146847
1.74181e-05
4.6319e-06
6.20313e-06
6.90522e-06
9.08239e-06
9.3316e-06
6.71537e-06
5.01849e-06
4.96044e-06
4.99714e-06
5.30284e-06
3.44968e-06
2.34948e-06
5.99807e-06
5.23502e-06
2.37683e-06
1.65425e-06
9.54751e-07
1.141e-06
6.83542e-06
0.000279367
0.00060005
0.00113668
0.0121348
0.0398182
2.12565e-05
1.19731e-05
1.05559e-05
2.46439e-06
0.00145735
2.20781e-05
1.023e-05
2.16129e-05
1.98779e-05
1.84979e-05
1.44172e-05
9.46487e-06
6.55742e-06
5.8122e-06
5.82844e-06
5.23169e-06
2.95385e-06
2.0943e-06
7.70959e-06
5.08659e-06
1.98139e-06
1.22186e-06
8.48975e-07
2.57438e-06
0.0002756
0.000809987
0.00133112
0.0189906
0.035782
9.67462e-05
5.01292e-06
1.11958e-05
1.42582e-05
4.32513e-06
0.00139807
2.65049e-05
4.37399e-05
4.79435e-05
3.5929e-05
2.3897e-05
1.40413e-05
9.19753e-06
7.12941e-06
6.37434e-06
6.55814e-06
6.16823e-06
2.58704e-06
1.21719e-06
7.17435e-06
3.33866e-06
1.16711e-06
8.12527e-07
1.91418e-06
0.000132996
0.000776148
0.00167138
0.0186138
0.0022289
3.29559e-05
3.17536e-06
2.83208e-06
1.01081e-05
1.35104e-05
6.2535e-06
0.00131017
2.32011e-05
4.92038e-05
4.5101e-05
2.57643e-05
1.27264e-05
7.53583e-06
6.12462e-06
6.30091e-06
6.93402e-06
6.8694e-06
6.4876e-06
1.9963e-06
6.29524e-07
3.5035e-06
1.51179e-06
9.71607e-07
9.35422e-07
1.22152e-05
0.00048826
0.000852639
0.00623088
0.0185653
1.70155e-06
1.87813e-06
1.72737e-06
3.66846e-06
6.88019e-06
1.12928e-05
1.20343e-05
0.00117369
7.23911e-06
2.43376e-05
2.17511e-05
1.07486e-05
6.53265e-06
4.93358e-06
4.60846e-06
5.62684e-06
6.66748e-06
6.67639e-06
5.67537e-06
1.4846e-06
3.91585e-07
1.27659e-06
8.42925e-07
8.23592e-07
2.40343e-06
0.00013258
0.000351261
0.000943099
0.03511
0.000101997
7.42788e-07
1.42011e-06
2.23657e-06
4.4072e-06
4.10353e-06
1.20181e-05
3.43615e-05
0.0010509
3.68494e-06
1.55317e-05
1.18232e-05
6.79517e-06
5.25311e-06
4.25916e-06
4.24794e-06
5.50472e-06
6.46115e-06
6.96084e-06
5.16906e-06
1.84582e-06
8.97021e-07
7.62359e-07
5.34974e-07
8.71015e-07
8.84743e-06
0.000300592
0.000543213
0.0020983
0.00557398
1.06447e-07
5.19815e-07
1.53445e-06
2.72996e-06
4.23143e-06
3.27889e-06
2.55015e-05
7.73955e-05
0.000973354
5.76385e-06
2.01299e-05
8.40718e-06
4.79495e-06
4.11713e-06
3.98126e-06
4.47179e-06
6.31994e-06
8.81313e-06
1.10902e-05
6.88418e-06
5.24476e-06
1.29106e-05
3.45391e-06
4.92402e-07
1.32849e-06
0.000167102
0.000861348
0.000562065
0.000123906
4.89853e-07
1.21179e-07
5.55642e-07
9.29762e-07
2.86926e-06
4.77396e-06
4.50439e-06
9.28809e-05
8.55961e-05
0.000927611
1.02264e-05
2.43074e-05
8.10968e-06
4.70057e-06
4.05615e-06
4.88827e-06
9.76807e-06
1.80172e-05
2.53205e-05
2.09721e-05
2.28685e-05
2.69735e-05
2.23881e-05
5.05447e-05
8.5607e-06
0.000242542
0.0017883
0.000564287
1.69252e-05
7.01197e-06
2.87507e-07
1.07966e-07
6.78148e-07
9.70669e-07
3.05069e-06
4.32187e-06
6.69852e-06
8.63553e-05
5.43016e-05
0.000865271
2.17644e-05
4.07424e-05
2.52541e-05
1.44749e-05
1.64054e-05
2.72859e-05
5.42615e-05
4.14495e-05
2.50465e-05
2.78559e-05
2.97803e-05
1.15416e-05
7.53589e-06
7.63525e-05
0.000751437
0.00230356
0.00341256
3.17169e-05
3.78844e-06
3.38931e-05
9.46075e-07
1.26465e-07
3.73068e-07
1.25655e-06
3.30129e-06
5.98402e-06
1.01008e-05
3.94793e-05
3.97119e-05
0.000773252
8.74706e-05
6.45793e-05
4.53949e-05
3.35161e-05
4.38734e-05
4.68165e-05
1.57931e-05
3.84141e-06
6.49558e-06
1.26404e-05
4.76413e-06
1.6892e-06
4.17966e-05
0.000610617
0.00148605
0.000824022
3.79256e-05
0.00270397
0.000465113
2.41221e-05
3.56903e-06
2.84635e-07
2.04684e-07
1.61027e-06
5.15106e-06
1.05117e-05
1.13204e-05
2.27042e-05
5.33926e-05
0.0006858
0.000160241
1.64806e-05
1.20136e-05
1.37808e-05
7.57543e-06
2.63294e-06
1.70718e-06
1.62292e-06
3.65165e-06
4.14973e-06
1.24409e-06
2.05066e-05
0.00047641
0.00084974
6.6304e-05
3.20997e-06
9.13588e-05
0.00113093
0.000970856
0.000116321
7.02172e-05
7.087e-07
4.07589e-07
2.46678e-06
9.80268e-06
1.54466e-05
1.2098e-05
2.35598e-05
8.46538e-05
0.000615966
9.13779e-05
4.73481e-06
7.53292e-06
4.58797e-06
3.18089e-06
1.67893e-06
8.97103e-07
6.3164e-07
7.34329e-07
7.81905e-07
1.06309e-06
0.000213997
0.000924341
0.000161191
4.71297e-07
7.30273e-06
0.000113345
0.000243278
0.000862307
0.000263019
0.000246042
6.74569e-06
8.81257e-07
2.84346e-06
1.63326e-05
2.55305e-05
1.36011e-05
1.98711e-05
7.03665e-05
0.000562612
3.57795e-05
1.0508e-05
1.01172e-05
4.34641e-06
2.03598e-06
1.02108e-06
5.84008e-07
2.84495e-07
1.47659e-07
1.7592e-07
1.00644e-05
0.000547254
0.000600121
1.42629e-07
9.68317e-07
1.26114e-05
0.000187623
0.000510922
0.000230526
0.00028699
0.000100069
7.42235e-05
1.7931e-06
2.25341e-06
1.96252e-05
3.04979e-05
7.07925e-06
9.26306e-06
6.0096e-05
0.000505654
9.4082e-06
7.95919e-06
6.16766e-06
3.09578e-06
1.35486e-06
7.1986e-07
3.98021e-07
1.97526e-07
1.10054e-07
2.21363e-07
8.06998e-05
0.000595273
4.88128e-05
2.01441e-06
1.06893e-06
2.6762e-06
7.24233e-05
0.00102233
0.000116608
0.000217394
7.32724e-05
1.81992e-05
4.41954e-06
2.12707e-06
1.37409e-05
1.09151e-05
3.02582e-06
7.30603e-06
8.16676e-05
0.000450074
1.40448e-06
1.92181e-06
1.32929e-06
1.07695e-06
5.79587e-07
2.90814e-07
1.75497e-07
1.26845e-07
1.49835e-07
2.15945e-06
0.000253755
0.000264494
3.50922e-06
3.51674e-06
2.18409e-06
1.79741e-06
1.36023e-05
0.00046833
0.000106762
2.98937e-05
0.000231381
4.71253e-06
2.69309e-06
2.59687e-06
5.81152e-06
3.14238e-06
3.04048e-06
9.0801e-06
9.80108e-05
0.000411295
2.21255e-06
1.02252e-06
3.06463e-07
3.17483e-07
3.10079e-07
2.41383e-07
1.78281e-07
1.53862e-07
3.34477e-07
4.39138e-05
0.000252604
3.40575e-06
4.46337e-06
3.24533e-06
3.08735e-06
2.37094e-06
1.53987e-05
0.000354761
0.000147012
7.0887e-06
0.00012326
5.47181e-06
1.21259e-06
2.66686e-06
3.69604e-06
3.23575e-06
8.8916e-06
8.16314e-06
0.000116856
0.000374013
6.16789e-06
4.77166e-07
2.86089e-07
2.75234e-07
3.02392e-07
2.65559e-07
2.31528e-07
4.86265e-07
1.10086e-05
0.000162302
1.05902e-05
3.14218e-06
1.57145e-06
1.85839e-06
2.90136e-06
4.08948e-06
2.95612e-05
0.000382521
0.000125662
4.32803e-06
2.1286e-05
9.18204e-07
1.00001e-06
1.97481e-06
3.59634e-06
4.32433e-06
3.548e-06
8.07231e-06
0.000135558
0.000344238
5.82006e-06
8.32043e-07
4.67655e-07
4.0726e-07
4.24414e-07
4.00017e-07
7.24978e-07
2.39348e-05
0.000112676
9.36104e-06
1.4523e-06
1.44744e-06
1.77798e-06
3.61511e-06
6.12465e-06
9.7877e-06
3.34184e-05
0.000188348
3.53128e-05
2.90048e-06
7.00686e-06
2.43192e-07
4.29219e-07
1.03904e-06
1.64951e-06
1.77373e-06
1.42991e-06
1.01855e-05
0.000123471
0.000313888
6.20733e-06
2.02683e-06
9.23944e-07
7.7181e-07
8.05152e-07
1.50232e-06
3.96181e-05
8.16182e-05
4.22141e-06
2.13867e-06
1.59307e-06
3.28253e-06
5.60904e-06
6.90118e-06
9.85293e-06
2.33514e-05
0.000113315
7.14213e-05
8.56817e-06
2.59226e-06
1.55727e-06
2.21305e-07
1.70409e-07
2.53233e-07
5.00453e-07
8.69423e-07
1.77241e-06
1.33129e-05
0.000104586
0.000284091
8.34929e-06
2.75966e-06
1.24334e-06
1.18991e-06
1.91584e-06
4.6385e-05
7.04531e-05
2.50518e-06
2.26826e-06
3.37224e-06
5.88804e-06
4.74892e-06
3.98254e-06
5.16899e-06
1.36594e-05
6.36713e-05
0.000153409
2.87413e-05
7.79824e-06
1.38883e-06
3.28783e-07
2.09679e-07
8.19995e-08
5.18962e-08
3.37389e-07
1.33121e-06
2.91294e-06
1.04549e-05
8.48855e-05
0.000247917
1.06393e-05
2.52875e-06
1.18383e-06
2.18881e-06
3.42188e-05
6.58148e-05
2.11119e-06
2.09374e-06
2.3903e-06
4.05765e-06
3.12865e-06
2.85118e-06
3.93708e-06
7.06718e-06
4.35278e-05
9.71068e-05
1.53539e-05
1.34353e-05
4.30661e-05
8.96799e-07
9.76568e-08
1.8645e-07
7.79924e-08
4.36458e-08
3.59804e-07
3.05744e-06
3.64917e-06
8.54734e-06
7.72115e-05
0.000213056
1.14829e-05
2.34565e-06
2.86596e-06
2.93626e-05
6.19999e-05
1.37635e-06
8.94732e-07
9.71386e-07
1.95705e-06
3.54382e-06
4.0044e-06
7.94059e-06
1.13048e-05
2.06475e-05
9.02993e-05
2.65455e-05
1.28717e-06
3.04753e-06
0.000194438
8.29736e-06
1.64847e-07
1.90093e-07
6.58377e-08
1.77325e-07
3.40367e-07
5.58577e-06
3.52217e-06
7.84876e-06
6.77694e-05
0.000179596
1.09495e-05
2.06519e-05
5.89095e-05
3.91895e-05
2.37774e-07
6.93163e-07
6.99463e-07
6.82673e-07
9.74777e-07
3.03445e-06
9.49971e-06
1.29168e-05
1.92358e-05
5.44011e-05
3.45411e-05
3.71879e-06
1.62538e-06
2.4272e-06
6.92457e-05
0.000419789
3.4525e-07
1.99259e-07
9.00733e-08
3.84432e-07
9.93709e-07
6.69604e-06
2.15442e-06
5.15139e-06
5.49945e-05
0.000147152
4.92454e-05
6.10154e-05
8.94e-06
2.08059e-07
4.96766e-07
4.21757e-07
4.7651e-07
7.08382e-07
1.28682e-06
2.84861e-06
8.67928e-06
2.16188e-05
4.07736e-05
2.3676e-05
9.46081e-06
4.36873e-06
2.67387e-06
2.57101e-06
2.94876e-05
0.000815717
1.3015e-06
1.87362e-07
2.34045e-07
6.63156e-07
2.34909e-06
3.56303e-06
1.07646e-06
2.87625e-06
4.31458e-05
0.000116816
8.77097e-05
1.01459e-06
4.17526e-07
3.54723e-07
3.74118e-07
4.40015e-07
6.62345e-07
1.13516e-06
2.26003e-06
4.31821e-06
5.65733e-06
7.67872e-06
1.2589e-05
1.56092e-05
7.44507e-06
2.4121e-06
2.80955e-06
2.04163e-06
1.49087e-05
0.000278417
4.28198e-06
3.389e-07
5.9969e-08
7.43609e-07
3.17222e-06
2.49683e-06
6.25591e-07
1.54164e-06
3.41742e-05
8.8569e-05
3.43003e-05
6.23864e-07
3.21554e-07
2.91693e-07
3.77811e-07
5.28134e-07
8.23224e-07
1.39344e-06
2.16105e-06
2.90587e-06
3.73811e-06
5.10993e-06
8.70985e-06
9.47183e-06
4.23334e-06
8.51984e-07
1.48311e-06
3.01048e-06
7.97084e-06
0.000109644
3.16287e-05
6.58333e-07
8.52266e-08
5.49938e-07
3.13172e-06
1.64147e-06
4.94133e-07
1.06009e-06
3.12148e-05
6.32671e-05
1.82083e-05
8.022e-07
4.16354e-07
3.62447e-07
4.68594e-07
6.54216e-07
9.52598e-07
1.37815e-06
1.90142e-06
2.42574e-06
3.11677e-06
4.96061e-06
7.55398e-06
5.66446e-06
1.53621e-06
1.20031e-06
4.12139e-06
7.10411e-06
4.45216e-06
1.16803e-05
0.000115012
1.02913e-06
3.01649e-07
6.98811e-07
2.28888e-06
6.4527e-07
6.20712e-07
1.07742e-06
3.37458e-05
4.16884e-05
1.0905e-05
1.11597e-06
6.32942e-07
5.23336e-07
6.46955e-07
8.47497e-07
1.13278e-06
1.50467e-06
1.93993e-06
2.46041e-06
3.32864e-06
4.74908e-06
5.19788e-06
3.76829e-06
3.49306e-06
8.49997e-06
1.20108e-05
5.77922e-06
2.49794e-06
2.50814e-06
4.49425e-05
2.5274e-06
5.53016e-07
9.9999e-07
1.14499e-06
4.97849e-07
7.5929e-07
1.13167e-06
3.98076e-05
2.46492e-05
5.22755e-06
1.41137e-06
9.33343e-07
7.45142e-07
8.39449e-07
9.94646e-07
1.2203e-06
1.53329e-06
1.91707e-06
2.40563e-06
2.98728e-06
3.64579e-06
4.2073e-06
5.38708e-06
1.00247e-05
1.81945e-05
1.55977e-05
5.60719e-06
2.49562e-06
1.86042e-06
1.30033e-05
7.33154e-06
6.58205e-07
1.32959e-06
1.26396e-06
5.86857e-07
8.76255e-07
1.26631e-06
4.80606e-05
1.24548e-05
2.1968e-06
1.21037e-06
1.0529e-06
8.79245e-07
8.89411e-07
9.47328e-07
1.05665e-06
1.21289e-06
1.39248e-06
1.54761e-06
1.82998e-06
2.36131e-06
3.62167e-06
6.46151e-06
1.12539e-05
1.71288e-05
1.99907e-05
1.03411e-05
3.45815e-06
2.17225e-06
5.05299e-06
1.19953e-05
9.2446e-07
1.34871e-06
2.09859e-06
8.08429e-07
1.05712e-06
1.63143e-06
5.903e-05
5.33692e-06
1.03296e-06
6.54451e-07
7.35194e-07
7.04118e-07
6.80245e-07
6.76157e-07
6.88086e-07
7.03449e-07
7.06079e-07
7.32212e-07
8.28964e-07
1.12251e-06
1.94452e-06
3.84754e-06
7.13407e-06
1.05281e-05
1.1932e-05
1.42381e-05
1.06732e-05
3.67012e-06
3.01855e-06
7.92124e-06
1.85253e-06
1.30962e-06
2.4971e-06
1.31387e-06
1.41775e-06
2.47098e-06
7.02709e-05
3.093e-06
5.69481e-07
3.18491e-07
3.77668e-07
4.15034e-07
4.13827e-07
4.05163e-07
3.99053e-07
3.93411e-07
3.86354e-07
3.80275e-07
3.94799e-07
4.66543e-07
6.59052e-07
1.067e-06
1.76641e-06
2.81633e-06
4.53373e-06
9.41334e-06
1.89058e-05
8.82891e-06
2.92282e-06
3.8236e-06
2.7573e-06
1.39352e-06
2.60021e-06
1.89473e-06
2.05068e-06
4.44242e-06
7.75775e-05
4.13098e-06
3.2164e-07
2.02249e-07
2.49156e-07
2.89649e-07
2.98093e-07
2.94544e-07
2.96385e-07
3.16931e-07
3.40096e-07
3.4835e-07
3.49852e-07
3.5133e-07
3.76798e-07
4.3238e-07
5.46884e-07
8.39105e-07
1.6433e-06
4.10082e-06
1.33212e-05
1.49449e-05
4.38259e-06
2.97089e-06
3.05664e-06
1.90202e-06
2.89958e-06
2.4102e-06
2.89943e-06
7.98948e-06
7.06188e-05
7.83862e-06
1.72552e-07
1.74741e-07
2.4177e-07
2.88226e-07
2.98779e-07
2.92866e-07
2.99718e-07
3.51882e-07
4.58325e-07
5.56055e-07
6.68147e-07
6.88142e-07
5.86908e-07
5.73429e-07
5.80233e-07
6.38889e-07
8.91426e-07
1.50404e-06
3.93708e-06
1.3304e-05
7.28844e-06
3.11703e-06
4.46245e-06
3.53706e-06
3.7408e-06
2.92922e-06
3.81597e-06
9.59461e-06
6.78882e-05
2.36382e-05
9.65134e-08
1.86315e-07
2.77509e-07
3.36851e-07
3.53681e-07
3.386e-07
3.21821e-07
3.76507e-07
6.1392e-07
1.09309e-06
1.36761e-06
1.48699e-06
1.57651e-06
1.56734e-06
1.64583e-06
1.75809e-06
1.51045e-06
1.06816e-06
1.03297e-06
5.06499e-06
6.01613e-06
2.96658e-06
6.10006e-06
6.57842e-06
4.79781e-06
3.14072e-06
3.72425e-06
1.04394e-05
8.4651e-05
4.80932e-05
1.48766e-07
2.30911e-07
3.34651e-07
4.11326e-07
4.39273e-07
4.43953e-07
4.35603e-07
3.95562e-07
5.16742e-07
1.30649e-06
2.66414e-06
4.19836e-06
5.54419e-06
6.3366e-06
7.81431e-06
7.66193e-06
5.55676e-06
2.49464e-06
1.25963e-06
1.02312e-06
1.29223e-06
2.04224e-06
7.80177e-06
1.04725e-05
4.96189e-06
2.50143e-06
2.20852e-06
1.73786e-05
8.25439e-05
6.00681e-05
2.18884e-07
3.44926e-07
4.48834e-07
5.31653e-07
6.20891e-07
8.16745e-07
1.29975e-06
8.24805e-07
4.98683e-07
1.3529e-06
3.46696e-06
7.40623e-06
1.3915e-05
1.77692e-05
1.34474e-05
9.11957e-06
6.21048e-06
4.94148e-06
1.56568e-06
6.88798e-07
5.32797e-06
2.70971e-06
1.16377e-05
1.54688e-05
4.78309e-06
2.06212e-06
3.82208e-06
4.10683e-05
5.01009e-05
0.000135762
2.26101e-07
3.43327e-07
6.76225e-07
8.32935e-07
7.78765e-07
8.1499e-07
2.30951e-06
1.26114e-05
5.48088e-06
4.06647e-06
4.21667e-06
6.16256e-06
1.01132e-05
1.89373e-05
2.65627e-05
1.28914e-05
3.40562e-06
1.60011e-06
1.07407e-06
9.15617e-07
3.63537e-06
1.22945e-05
2.21567e-05
3.58687e-05
6.59521e-06
2.83227e-06
1.10435e-05
3.1934e-05
3.50341e-05
0.000130178
1.36094e-07
5.77834e-07
7.53639e-07
9.49384e-07
1.6626e-06
4.00962e-06
5.35806e-05
0.000132256
2.12394e-05
3.69716e-06
1.60213e-06
3.89513e-06
6.18692e-06
7.68836e-06
2.15353e-05
2.43156e-05
4.39668e-06
4.11456e-07
4.70871e-07
7.58456e-07
1.37519e-06
1.77512e-05
4.3047e-05
4.37713e-05
1.07761e-05
4.69943e-06
7.40992e-06
9.26047e-06
1.70509e-05
0.000118606
5.56428e-07
4.66581e-07
4.32726e-07
5.10803e-07
1.63609e-06
6.76879e-06
8.77364e-05
0.000208966
3.92374e-05
1.11136e-06
1.41708e-06
6.80944e-06
1.12817e-05
8.02563e-06
1.81623e-05
2.33398e-05
2.53901e-06
1.67111e-07
2.96254e-07
5.93647e-07
1.04256e-06
1.36434e-05
3.36433e-05
1.71366e-05
1.4314e-05
1.15864e-05
5.76809e-06
4.23172e-06
1.07757e-05
0.000132991
1.12388e-06
7.58358e-07
2.52448e-07
2.22631e-07
3.29054e-06
2.03724e-05
7.88497e-06
0.000205024
0.000133487
4.03953e-06
2.12158e-05
2.98975e-05
1.84818e-05
1.38968e-05
1.99232e-05
9.76364e-06
1.01973e-07
2.73554e-07
2.98019e-07
6.17765e-07
1.14554e-06
9.85303e-06
1.42118e-05
6.72817e-06
1.04058e-05
2.13003e-05
1.07297e-05
8.26107e-06
1.18352e-05
0.000148662
2.53501e-05
5.33079e-05
4.82552e-05
4.07391e-05
2.15797e-05
1.22002e-06
3.03088e-06
0.000141517
0.000330275
7.08715e-05
0.000101081
3.46802e-05
3.60463e-05
2.66507e-05
3.0258e-06
2.73222e-07
4.24767e-07
4.26452e-07
4.22158e-07
9.07025e-07
1.30487e-06
5.73063e-06
5.66702e-06
3.59443e-06
7.50342e-06
2.23413e-05
2.33291e-05
2.15793e-05
1.94399e-05
0.000140468
0.000122515
6.83228e-05
4.82659e-05
2.68028e-05
5.69203e-06
2.34111e-06
1.631e-06
1.26604e-05
0.00036688
0.000187835
0.00034191
0.000558014
0.000321614
2.65464e-05
6.86876e-07
9.12597e-07
6.85785e-07
5.70066e-07
7.15799e-07
1.17417e-06
1.70221e-06
3.50103e-06
4.42906e-06
7.28226e-06
1.79197e-05
2.08004e-05
3.15478e-05
2.75655e-05
1.96862e-05
0.000107088
2.77507e-05
4.06247e-07
6.49321e-07
9.26287e-07
1.26885e-06
1.29361e-06
7.21259e-07
1.6031e-07
4.0532e-05
9.65558e-05
0.000123235
0.000504876
0.00085373
0.000497095
4.74832e-05
1.23266e-06
7.16099e-07
7.3742e-07
1.23994e-06
1.50179e-06
2.23198e-06
4.70795e-06
1.94686e-05
3.52415e-05
4.02168e-05
2.50291e-05
2.54124e-05
2.08752e-05
1.53783e-05
8.07378e-05
9.68904e-06
8.05254e-07
8.10907e-07
6.81571e-07
6.04332e-07
5.22555e-07
3.11452e-07
4.59174e-07
2.04085e-06
1.17532e-05
3.34482e-05
5.84587e-05
0.000176263
0.00061007
0.000519777
6.4288e-05
1.00475e-06
9.83039e-07
2.20797e-06
3.02272e-06
4.91362e-06
2.05451e-05
1.91471e-05
1.66804e-05
1.94818e-05
2.10791e-05
1.65847e-05
1.536e-05
1.63741e-05
5.91266e-05
4.9978e-06
8.45406e-07
6.94549e-07
5.5167e-07
5.28197e-07
6.73874e-07
1.01202e-06
1.84946e-06
2.68156e-06
1.49849e-05
2.23537e-05
6.25121e-06
1.22714e-06
1.59318e-05
0.000312664
0.000584138
0.000174125
1.43393e-05
1.04228e-05
2.46639e-05
3.60141e-05
2.64058e-05
3.13363e-06
1.6113e-06
2.6423e-06
7.17185e-06
1.10105e-05
1.01072e-05
1.62712e-05
3.99249e-05
2.197e-06
7.2414e-07
5.9841e-07
5.81118e-07
6.82506e-07
1.00068e-06
1.57188e-06
2.43929e-06
2.92212e-06
1.46122e-05
3.13856e-05
5.5024e-06
2.87717e-06
1.98796e-06
1.74852e-06
0.000122604
0.000474679
0.000315545
0.000101946
4.11778e-05
2.3796e-05
5.45633e-06
2.82422e-06
2.6395e-06
1.68556e-06
2.02191e-06
6.96646e-06
8.49667e-06
1.09822e-05
2.32577e-05
6.81345e-07
4.39139e-07
4.37876e-07
5.10862e-07
6.72489e-07
9.77109e-07
1.5365e-06
2.11342e-06
4.08894e-06
3.09098e-05
4.01178e-05
1.64269e-06
4.18834e-06
2.2427e-06
1.84792e-06
1.23693e-06
1.38662e-05
0.000101136
8.12763e-05
2.58111e-05
8.24044e-06
3.83656e-06
1.61227e-06
1.72422e-06
2.45797e-06
2.76347e-06
4.43908e-06
6.87681e-06
4.667e-06
6.53804e-06
1.57238e-07
2.42282e-07
2.94923e-07
3.58772e-07
4.69721e-07
6.73685e-07
1.1397e-06
2.07372e-06
6.29748e-06
5.65096e-05
3.77698e-05
2.00373e-06
4.75786e-06
2.56457e-06
2.22109e-06
2.11203e-06
1.28847e-06
4.01365e-06
1.26959e-05
1.29355e-05
9.71062e-06
6.38286e-06
3.51179e-06
1.78289e-06
5.49921e-07
1.11979e-06
1.3445e-06
1.71344e-06
1.87002e-06
4.33627e-06
2.69979e-07
3.72281e-07
3.48759e-07
3.09401e-07
3.15016e-07
4.4664e-07
8.93582e-07
2.36314e-06
1.5694e-05
7.4801e-05
4.9015e-06
4.45953e-06
5.12381e-06
2.61188e-06
2.52829e-06
2.12542e-06
1.62024e-06
1.62714e-06
3.79096e-06
6.65818e-06
6.05888e-06
3.90523e-06
2.42027e-06
1.82308e-06
1.45919e-06
8.3984e-07
3.23506e-07
1.50559e-07
6.49601e-07
1.75864e-05
4.12085e-06
2.25462e-06
8.39211e-07
4.72209e-07
4.3762e-07
5.90224e-07
9.88486e-07
3.32479e-06
4.57144e-05
5.0168e-05
1.27123e-06
7.2991e-06
5.34687e-06
2.82641e-06
2.61973e-06
2.12603e-06
1.59734e-06
1.25497e-06
1.603e-06
2.81605e-06
2.50239e-06
9.19812e-07
5.83481e-07
5.60138e-07
6.08073e-07
6.07405e-07
1.30711e-06
1.76224e-06
5.15548e-06
2.48984e-05
8.18024e-06
4.52434e-06
1.54736e-06
1.29323e-06
2.36035e-06
3.96724e-06
4.10641e-06
1.00667e-05
4.3763e-05
1.36258e-06
4.45922e-06
7.6059e-06
4.75899e-06
3.17216e-06
2.64269e-06
1.94205e-06
1.34816e-06
1.1107e-06
1.19034e-06
1.82396e-06
1.6226e-06
3.92787e-07
3.99755e-07
5.82482e-07
8.22966e-07
3.28719e-06
9.7439e-06
1.46892e-05
1.83212e-05
6.41609e-06
0.000631573
8.32312e-06
2.52329e-07
3.78195e-06
3.19919e-05
5.04906e-05
3.92814e-05
1.51408e-05
3.99173e-06
2.30516e-06
6.33866e-06
6.37013e-06
4.40338e-06
3.00428e-06
2.34951e-06
1.53097e-06
9.69394e-07
8.53621e-07
1.20346e-06
2.44728e-06
2.13499e-06
9.27623e-07
1.86355e-06
3.32173e-06
5.33292e-06
1.15013e-05
1.83713e-05
1.92256e-05
9.9963e-06
1.07203e-06
0.000284092
0.000514533
0.000160455
6.88974e-05
4.48709e-05
3.19482e-05
5.17041e-05
5.72587e-05
2.67866e-05
9.30095e-06
6.02717e-06
4.91169e-06
3.62624e-06
2.41735e-06
2.01896e-06
1.49211e-06
8.99099e-07
6.83088e-07
1.36278e-06
2.72103e-06
2.87424e-06
2.87142e-06
4.71212e-06
7.88126e-06
1.12459e-05
1.38324e-05
1.30877e-05
9.9723e-06
2.99691e-06
1.41836e-06
1.8389e-05
0.000110887
0.000227909
5.89919e-05
2.13198e-05
2.10447e-05
1.40209e-05
4.23682e-05
4.49897e-05
2.12248e-05
6.86463e-06
3.80894e-06
2.81167e-06
1.95978e-06
1.8004e-06
2.18963e-06
1.87759e-06
8.15419e-07
6.28653e-07
1.83539e-06
3.75217e-06
5.48416e-06
6.24428e-06
6.90973e-06
6.67816e-06
6.19763e-06
6.56635e-06
5.35603e-06
3.4151e-06
3.43013e-06
1.03963e-05
8.68542e-06
4.59374e-05
3.62094e-05
1.26892e-05
1.19864e-05
3.50378e-06
6.39798e-06
1.59958e-05
1.58813e-05
8.96093e-06
3.42317e-06
2.37478e-06
1.7502e-06
1.45596e-06
1.79215e-06
1.97518e-06
8.1769e-07
2.64269e-08
8.15022e-07
3.67066e-06
4.49182e-06
3.16276e-06
2.43414e-06
1.78069e-06
1.55199e-06
2.0197e-06
2.87565e-06
2.79444e-06
5.48066e-06
7.0594e-06
7.21764e-06
3.70729e-05
6.00036e-05
1.46521e-05
5.62943e-06
1.7251e-06
2.0367e-06
3.21501e-06
5.62229e-06
5.56789e-06
2.58708e-06
1.67265e-06
1.23171e-06
1.02444e-06
1.19391e-06
1.44521e-06
1.1937e-06
7.6483e-07
8.40528e-07
2.57999e-06
1.8157e-06
1.17484e-06
1.08303e-06
1.00733e-06
9.89587e-07
9.45092e-07
8.86147e-07
1.68747e-06
4.52134e-06
6.4205e-06
7.64164e-06
2.33366e-05
5.98272e-05
2.54003e-05
4.09585e-06
1.46485e-06
1.20806e-06
9.53841e-07
1.43588e-06
2.27009e-06
2.00242e-06
1.26124e-06
8.95773e-07
7.97423e-07
9.53684e-07
1.28315e-06
1.73314e-06
2.3823e-06
1.79144e-06
1.7579e-06
9.971e-07
8.84741e-07
1.03574e-06
1.46965e-06
1.70668e-06
1.76502e-06
1.65485e-06
2.42063e-06
2.99855e-06
8.31768e-06
8.29776e-06
1.45528e-05
3.66696e-05
2.70827e-05
3.60793e-06
1.08918e-06
5.2947e-07
3.51162e-07
3.82459e-07
1.15009e-06
2.1554e-06
1.42136e-06
8.10908e-07
7.18568e-07
8.78255e-07
1.23194e-06
2.00908e-06
3.64742e-06
4.30815e-06
5.39112e-06
1.6542e-06
1.31068e-06
1.18278e-06
1.6249e-06
2.59286e-06
2.86342e-06
2.18793e-06
7.81657e-06
8.09094e-06
1.01084e-05
6.96749e-06
8.42624e-06
1.17188e-05
2.40758e-05
6.69851e-06
4.55582e-07
1.83042e-07
1.85982e-07
2.67183e-07
1.10678e-06
2.60478e-06
1.94513e-06
1.02428e-06
8.82635e-07
1.07357e-06
1.46686e-06
2.2643e-06
6.15398e-06
1.01062e-05
8.40222e-06
1.92928e-06
8.76777e-07
7.22576e-07
1.48349e-06
3.23077e-06
4.4867e-06
4.62667e-06
8.68935e-06
2.60067e-05
6.76615e-06
3.69839e-06
2.95413e-06
3.84119e-06
7.0722e-06
7.02288e-06
1.4405e-06
4.51986e-07
3.16225e-07
4.75438e-07
1.08699e-06
2.26213e-06
2.38378e-06
1.45665e-06
1.38828e-06
1.70695e-06
2.16074e-06
2.69713e-06
6.30791e-06
1.17474e-05
4.67342e-06
9.70003e-07
3.11706e-07
4.89788e-07
8.51986e-07
1.29272e-06
2.73736e-06
2.11585e-05
7.681e-05
2.67496e-05
1.12255e-05
8.20852e-06
3.50433e-06
2.39866e-06
3.50604e-06
2.25911e-06
1.65775e-06
1.3362e-06
1.28396e-06
1.54566e-06
2.01351e-06
2.75019e-06
2.91467e-06
2.41927e-06
2.55164e-06
2.7732e-06
3.2949e-06
5.3411e-06
2.55181e-05
3.19242e-05
8.11933e-06
1.28847e-06
1.81198e-06
5.0752e-06
2.54173e-05
5.84836e-05
0.000125259
0.00027018
0.000336591
0.000755814
3.71061e-05
4.27458e-05
1.17675e-05
5.47994e-06
7.09064e-06
2.93149e-05
9.79065e-05
0.000107508
0.000101765
0.000133158
0.000149867
0.000134846
5.89134e-05
3.34283e-05
2.80959e-05
2.33209e-05
3.36986e-05
0.000107611
0.000268851
0.000481697
0.000339273
0.00017367
0.000177368
0.000234646
0.000219738
0.000344878
0.00048227
0.000489891
0.000291765
0.000997539
0.000461416
0.000184804
0.000308107
0.000240892
0.000237081
0.000542495
0.000672961
0.000576572
0.000464172
0.000199314
0.000174944
0.000138845
5.60949e-05
0.000245929
0.000455706
0.000396364
0.000420824
0.000272122
0.000241048
0.000401012
0.000447132
0.000325788
0.000331657
0.000372149
3.4261e-06
3.96308e-05
0.000553777
0.000423163
0.000441812
0.00329344
0.000244293
0.000100754
0.000602028
0.000705887
0.000503933
0.000910777
0.000832394
0.000825205
0.000522347
1.18561e-05
5.83748e-06
1.90717e-05
0.000313627
0.000297204
0.00141055
0.00165145
0.000938387
3.29481e-06
1.55178e-06
2.80544e-06
3.62396e-06
7.11011e-07
3.10706e-05
1.64481e-05
9.8992e-05
5.419e-05
9.07812e-06
0.00823593
0.0328163
0.0750095
0.00123562
0.000423928
0.000134866
0.00115257
0.00418938
0.00306977
0.000453979
0.000301049
2.20799e-05
2.93862e-05
3.42573e-05
0.000924466
0.0012599
0.000906422
0.000267796
0.00219401
0.00158477
2.50397e-05
7.69565e-06
2.63146e-06
3.11295e-06
1.2152e-05
3.35118e-06
0.000195012
0.00019686
0.000182914
7.31321e-05
0.0147136
0.0618457
0.13801
0.00878782
0.000324316
0.000324416
0.000153766
1.62021e-06
6.08853e-06
1.2999e-05
4.22596e-05
4.55327e-05
4.36122e-05
2.20899e-05
0.00140373
0.00343242
0.00299688
0.00408162
0.000641348
0.000194505
7.53596e-05
9.90361e-07
0.00137895
3.32185e-07
5.96487e-06
5.31417e-05
8.89089e-05
0.229739
0.39206
0.000421814
0.00014161
0.0648266
0.09408
0.0114163
1.21451e-06
100
0.00412256
0.000413911
2.83326e-07
3.33129e-05
0.000118236
5.50578e-05
0.000107927
8.84102e-05
0.000591423
0.833719
5.63411
0.015675
0.00207129
8.29461e-05
0.00970767
0.0306838
0.00618485
2.49718e-06
9.95628e-06
4.65965e-05
7.95517
0.285743
0.775868
3.15476
0.000372318
0.000167205
0.0322917
5.15952
35.6044
47.5735
100
0.000401605
6.67654e-05
0.000103763
8.2112e-05
7.81259e-05
2.41476e-05
4.34872e-05
30.3046
20.0923
45.2682
32.0925
0.00022534
0.000530897
0.044951
0.0436917
0.00775581
1.72778e-05
9.79607e-06
0.0003595
0.0914034
0.863763
1.39148
2.54541
3.32221
0.000889785
9.37205e-05
97.3807
62.6453
20.8598
28.986
100
3.6801e-05
1.22914e-05
0.000535028
0.000403708
1.55849e-05
9.33884e-13
57.7295
100
100
80.6661
4.72213e-05
0.000177936
0.0219388
0.00757644
0.00034146
7.23075e-05
4.01402e-06
0.000236854
0.00107807
1.17945
2.56836
3.74412
4.40806
2.98422
0.296573
100
30.4809
19.8091
8.49765
5.23374
3.20706
4.24421e-06
8.9882e-05
0.0662983
0.00688157
4.01872e-07
21.0021
85.1279
100
100
0.000108644
0.000100434
3.20798e-06
0.000617364
0.00385119
0.000200405
1.96557e-05
3.7247e-06
2.84019e-06
2.65211e-06
2.91613
3.24004
3.26826
3.25492
2.69551
99.8024
21.1875
10.1487
8.15061
10.6146
6.41585e-05
8.08611e-05
0.000339445
0.184179
0.162633
1.45346e-05
0.908878
47.8653
69.4138
59.4116
0.00023173
2.56438e-05
1.15825e-05
0.000176878
0.379074
0.234784
0.000183651
0.000150531
4.23157e-05
9.81662e-06
0.000166751
3.3154
1.54807
1.66531
1.9508
49.0153
12.7602
7.85885
2.42075
8.07784e-05
7.65186e-05
1.77257e-06
0.00180719
0.319125
0.235814
0.0232387
0.000397769
2.36117
18.1472
39.497
0.0005106
3.84899e-05
5.71529e-06
4.57349e-05
0.00425331
0.00735742
0.0426495
0.00174898
3.4918
0.473612
0.000493708
0.000591316
0.846255
0.855198
0.937614
15.2786
10.5206
0.116148
0.00036521
0.00482254
10.2386
4.20535e-06
2.71979e-05
0.051935
0.149164
0.068111
0.000631162
0.22824
2.1923
9.86975
9.0144e-06
2.41576e-05
8.16079e-06
1.22256e-05
0.000273102
0.00252705
3.04474
0.638725
3.37839
3.95993
5.82425
0.00146001
0.00172099
0.190586
0.343889
5.23537
0.149828
0.00104136
17.1086
15.4134
11.0183
5.08057
6.4592e-05
0.000210626
0.00591598
0.0131135
0.00115084
0.000434788
0.284328
0.105667
6.95252e-05
4.69571e-07
3.44792e-06
1.25286e-05
0.00035494
22.0862
0.00184296
0.000239624
0.113418
1.35452
0.482504
1.42677
0.0155576
0.00119345
0.0342626
0.237302
0.228118
30.2323
15.9364
14.3493
13.0693
7.96529
3.55932
0.000348094
5.71469e-06
0.000285601
0.000493014
0.00105638
0.00270625
7.25331e-05
0.00453541
0.00351802
2.58382e-07
9.04351e-06
0.00014111
0.00182256
0.000267211
0.0823024
0.0359261
1.14547
2.23147
1.68226
1.51829
0.12933
0.0622773
0.304442
20.5667
15.3837
10.3509
14.0178
18.1436
21.266
30.3273
100
100
4.36078
0.00196037
0.000780767
0.000521528
0.00253467
0.0100957
0.00106018
5.98898e-07
1.00865e-05
3.67063e-05
0.000275538
0.000797941
0.892422
0.0486192
0.012666
2.49488
2.84168
1.65386
1.10645
0.438283
15.9994
15.2599
7.45769
8.63648
15.7166
20.3537
29.3757
78.7404
100
100
38.1769
0.00408526
0.000443992
0.000111252
0.0106189
0.00846818
1.39369e-05
1.09258e-06
9.23666e-06
2.52355e-05
2.7366e-05
0.00192639
0.836505
3.3739
0.0493726
0.00784245
2.54062
1.85889
1.18186
0.809287
12.5997
6.99055
5.62591
8.08962
10.8918
17.114
23.6053
72.618
100
43.2039
0.00313777
0.00107959
9.67498e-05
0.000155861
0.0111405
0.00291055
1.96443e-06
7.74688e-05
2.67096e-05
4.68427e-05
0.000124982
0.00133325
0.358881
2.83224
6.08979
0.00818981
0.00193797
3.24126
1.2088
0.775388
3.75767
3.44682
4.43776
6.61631
8.18421
11.7417
9.39852
14.7576
0.464309
0.000394177
0.000973207
0.000465839
0.00394121
0.00254614
0.00718497
3.08374e-05
0.00219226
0.000989289
3.35791e-05
8.6472e-05
0.000112412
0.000886294
0.390522
1.16753
1.49813
19.9702
0.000824302
0.00198029
1.65065
0.814163
2.08425
2.78928
3.34513
7.76128
22.0571
0.0359224
0.000215375
0.000353096
0.0010747
0.0137994
6.23243e-05
6.67605e-06
0.0219741
0.0125856
0.00170438
0.00236118
0.00364098
100
0.0917381
0.376346
0.000188998
0.000172885
1.15838
2.09885
1.12539
4.08896
9.31534
0.000338317
0.000683968
0.600276
2.46722
3.12594
8.02227
10.8519
2.55623e-05
1.77479e-05
8.56617e-06
1.02435e-05
0.000160273
0.00321299
0.015655
0.000740585
0.000746279
4.02259e-05
0.000966391
0.000919999
100
100
26.4018
10.7252
2.96229
0.000808947
0.00245594
4.02258
1.87133
1.89525
2.83446
0.68389
4.82174e-05
0.0194333
2.76469
2.00724
5.10427
3.02326e-05
1.05369e-05
4.58011e-07
1.00628e-06
1.12746e-06
4.07009e-06
0.00351395
0.0026937
1.83795e-07
1.34244e-06
0.000388196
0.000451663
100
100
100
89.4881
29.1276
15.7718
0.00195654
0.00269982
4.31475
1.8786
1.36603
1.84975
0.84548
0.0779929
0.0615528
0.5089
0.122567
1.65165e-05
1.04344e-05
5.25354e-06
3.70299e-08
2.50833e-06
6.84071e-06
3.9927e-06
8.73539e-07
6.62196e-08
3.12627e-07
0.000303265
0.00014017
72.2577
100
100
100
100
67.6025
34.9411
0.00132601
0.000813407
8.18374
5.3788
0.566691
0.794631
0.841426
0.350491
0.241562
7.72943e-07
0.0013226
4.75288e-05
9.69412e-06
0.0114698
0.172481
0.000663535
8.73466e-06
1.06824e-05
4.46015e-07
1.31368e-07
3.41122e-06
0.000387132
0.000588121
100
100
100
100
100
100
0.000711106
0.00108947
0.160753
5.45848
5.42786
3.7417
0.393621
0.730182
0.503669
0.412721
0.0127332
0.0229182
0.00018617
0.0436145
0.212066
0.113187
0.357945
2.22314e-05
1.09821e-05
2.43699e-06
5.15587e-07
3.03572e-05
0.000584196
0.014031
100
100
100
100
100
49.1793
0.000628433
9.58696e-05
0.963148
2.55092
2.90184
2.01318
0.465929
0.840224
0.732686
0.512417
0.184998
0.087655
0.160384
0.243672
0.0456245
0.115176
0.0107251
0.53702
7.26113e-06
3.03609e-06
3.30322e-07
0.000135163
8.77845e-05
12.7217
100
100
100
100
100
0.000222667
8.14481e-05
3.87137e-05
0.12738
1.25979
1.10553
0.983429
0.197601
0.0320048
0.555397
0.358955
0.291792
0.221721
0.302433
0.297571
0.180502
2.10078e-05
1.02882e-05
0.7514
6.47733e-06
1.41863e-06
3.87851e-07
1.42428e-06
0.000324761
0.00334575
100
100
100
100
11.8183
0.000336346
4.51673e-05
0.00166952
4.95575e-05
0.0629333
0.790902
0.848054
0.534719
0.00180155
0.00895509
0.0456037
0.323034
0.34367
0.361964
0.305692
0.0222726
1.76599e-05
0.279251
0.917046
3.31611e-06
1.367e-06
1.44289e-06
1.45219e-06
9.27257e-06
2.09302e-05
96.6412
100
100
84.4512
4.71176
0.00563919
0.0353157
0.311251
0.0158516
4.15157e-05
0.000676011
0.581994
0.604604
0.470677
0.00726469
0.0267679
0.390083
0.392437
0.327871
0.191129
0.00275252
9.09549e-05
0.914575
8.92691e-05
1.2296e-06
9.79179e-07
9.66942e-06
4.43238e-06
1.01319e-05
1.4781e-05
96.2204
100
100
36.2013
4.06175
0.331146
0.210905
0.255713
0.380252
0.069854
3.41529e-05
9.22261e-05
0.508934
0.442724
0.237503
0.243208
0.417329
0.378204
0.30177
0.12799
0.0283557
0.101528
0.803266
2.14791e-06
1.01362e-06
5.00843e-07
0.000231129
2.23417e-06
0.000186228
0.000123102
100
100
80.5381
26.4367
4.63342
1.28001
0.461749
0.203711
0.333262
0.398907
0.251927
4.34469e-05
0.000100429
0.355332
0.846726
0.558336
0.428038
0.414582
0.314058
0.238913
0.0861848
1.07313e-05
1.32363
0.0177126
1.52362e-06
9.18762e-07
0.000209279
6.46339e-05
7.14922e-05
3.09593
18.1842
100
49.2566
16.2438
4.75898
1.43592
0.678226
0.291445
0.26041
0.339857
0.447714
0.678827
0.0354462
0.00346275
0.428746
0.733414
0.497095
0.432735
0.427987
0.402794
0.336758
0.01131
1.99825e-06
2.24098e-06
1.23565e-06
3.64017e-06
5.16497e-06
8.18305e-06
0.000299563
0.00012128
42.3587
100
38.8062
8.90085
3.20676
1.15086
0.684379
0.441072
0.330476
0.384677
0.47211
0.702547
0.889411
0.642885
0.25261
0.921324
0.595994
0.430384
0.488168
0.507196
0.0106074
1.47489e-05
2.53951e-05
0.000108254
8.15131e-06
2.54298e-05
8.46288e-05
1.06241e-05
2.37444e-05
0.000220807
0.00011984
83.9383
37.3641
4.87158
1.48733
0.724328
0.481946
0.457291
0.467732
0.554024
0.636855
0.741397
0.832687
0.972244
0.74877
1.1562
0.609028
0.508508
0.471179
0.0247236
2.67952e-05
9.88734e-05
0.301456
6.60189
24.2047
7.14329e-08
0.000130997
0.000113769
8.5888e-06
4.8227e-06
0.00010284
5.18253e-05
0.00140963
0.00053451
0.00015255
0.0843781
0.261829
0.389472
0.501049
0.615652
0.733402
0.866481
0.963441
1.08208
1.11154
1.56094
0.489871
0.421866
0.108637
6.70118e-05
0.000234023
4.93274
13.1809
7.44536
3.70518
1.65508
0.308341
0.000104787
6.15149e-05
0.000532089
1.81679e-07
1.96729e-05
5.52362e-06
1.1618e-06
0.0109705
0.112734
0.223014
0.363128
0.497511
0.63089
0.771952
0.92838
1.10897
1.28195
1.44603
1.95646
0.342492
0.207356
0.00372717
0.00031654
4.32368
10.7658
7.20671
5.45384
6.14567
3.75243
3.29332
0.000138845
6.65684e-05
3.74278e-05
5.66235e-06
1.00783e-07
1.30392e-06
1.45958e-06
0.150213
0.134605
0.172337
0.326884
0.481672
0.663759
0.816675
0.982914
1.21209
1.46771
1.72622
2.23593
0.277414
0.157656
0.0754536
0.89282
5.01734
6.03165
3.5786
4.4516
6.60744
9.387
8.22153
0.000155109
4.77703e-05
2.31041e-06
4.83941e-06
0.000475816
1.02763e-05
5.60024e-06
0.00737838
0.168661
0.0483451
0.383414
0.548457
0.716101
0.892904
1.03361
1.29053
1.59408
1.91093
2.40877
0.288641
0.248443
0.369565
1.4733
3.1567
1.42247
1.61389
5.12234
9.24281
13.6722
24.448
9.84259e-05
3.27028e-05
8.03183e-05
7.16787e-07
0.00220457
0.0161928
3.66729e-05
2.3331e-05
0.126835
5.76507e-05
0.000138294
0.303212
1.06306
1.1102
1.12112
1.34094
1.67548
2.02347
2.46772
0.313385
0.325836
0.547927
1.52406
1.29024
0.0370255
2.98049
14.9691
17.1228
20.4728
19.9966
0.000149023
1.74459e-05
0.000111361
2.56824e-05
0.0177889
0.0418625
4.62245e-05
2.85295e-06
1.42445
1.28863
0.00156788
1.63521e-05
0.000395099
1.59116
1.32756
1.37472
1.6976
2.06184
2.43087
0.320763
0.335132
0.552307
0.92828
0.0201423
0.153827
18.3439
21.6992
20.9867
18.4009
9.03701
0.00014272
7.95134e-06
0.142629
0.000594008
0.00663455
0.0632747
0.000131223
4.57784e-06
3.00107
3.84118
2.4377
0.725882
1.67038e-05
4.31429e-05
1.86108
1.50893
1.65699
2.0145
2.30691
0.307807
0.282507
0.42557
0.186912
0.0156522
2.67025
10.8519
18.4162
14.2897
8.00567
4.99159
1.83256e-05
5.45323e-06
0.0426405
1.60694
0.0177171
0.05896
9.98098e-05
1.92783e-05
1.1742
3.10399
3.17543
2.25357
1.5171
1.85253e-05
4.00807e-05
2.01841
1.69658
1.87237
2.12609
0.322098
0.220031
0.271217
0.0121455
0.0606559
3.98181
9.74958
10.652
6.29431
10.6719
0.489254
5.62595e-06
0.0308936
0.225247
1.97294
6.50579
0.00204601
0.120161
3.17427e-05
2.10791e-05
2.45118
2.73196
2.39024
2.09812
1.81064
2.07426e-05
4.56865e-05
1.96133
1.84317
1.94325
0.501983
0.267936
0.210433
0.0209242
0.230243
2.89386
4.40326
3.32379
12.0315
0.00149227
4.0867e-05
0.499011
0.409535
0.487424
3.40008
5.62556
0.00227993
0.111608
0.0125278
4.2747e-05
0.136949
2.39467
2.06636
2.07415
2.33607
2.59284
2.17958e-05
5.36056e-05
0.20604
1.96
0.67084
0.404443
0.319343
0.154005
0.291286
1.66922
2.62049
4.49704
3.02127e-05
2.03402e-05
3.57981
1.86062
0.96279
0.72008
4.94899
5.60547
0.000205564
0.0502784
0.370607
6.07699e-05
2.61478e-05
2.93217
2.17703
1.89413
2.30995
3.32211
4.16064
0.000324693
2.43874e-05
0.000117844
0.572382
0.391258
0.354859
0.289385
0.434618
1.53148
2.84243
0.00589288
4.80822e-05
2.07574
4.07873
4.15881
1.80767
1.12763
5.8513
2.65283
0.00176664
0.0295995
0.221244
0.187521
1.48477e-05
0.0649254
2.81942
1.94829
2.10123
3.07986
4.55835
5.35719
2.31049
4.50257e-05
0.446752
0.350535
0.345546
0.36227
0.508115
1.18616
0.40463
5.03321e-05
0.00022416
5.73953
8.41151
6.22686
2.98089
1.89769
4.88672
1.43546
0.0172386
0.0377311
0.217781
0.406756
4.19473e-05
0.000163582
2.65097
2.31933
2.09356
2.42201
3.36425
4.3173
4.25764
3.35383
0.359304
0.2969
0.309498
0.33579
0.436206
0.58365
4.0615e-05
3.37762e-05
3.57138
10.8496
12.8592
7.28946
3.42469
2.67171
3.58994
0.990634
0.0434916
0.042673
0.201524
0.518675
0.000171505
2.46927e-05
2.12734
2.56695
2.26875
2.15882
2.42934
3.10735
3.46559
4.07979
0.319815
0.259328
0.249626
0.275921
0.29843
0.236046
3.15452e-05
7.40301e-05
9.11375
26.7796
14.6835
5.53551
3.23299
2.68043
2.49566
0.821236
0.0795157
0.0556708
0.165062
0.342185
0.359438
3.05433e-05
0.00016091
2.81495
2.42228
2.13907
2.03565
2.30836
2.65319
4.34506
0.309644
0.244694
0.189195
0.229589
0.224828
0.156035
2.25873e-05
0.000145769
15.1904
28.0417
9.96541
3.88548
2.77801
2.10505
1.65032
0.668921
0.122801
0.0836163
0.170081
0.267546
0.431054
7.98009e-06
0.000118833
2.18554
2.48257
2.05813
1.91628
1.95732
2.13703
3.8752
0.319092
0.238428
0.146286
0.18171
0.190775
0.139719
1.58697e-05
0.000128906
14.939
22.6726
3.8506
3.8077
2.15273
1.51418
1.04478
0.503971
0.166217
0.125792
0.194554
0.259948
0.347905
0.338915
1.54601e-05
0.000269794
2.91786
1.99066
1.75197
1.85331
2.02322
3.65944
0.316398
0.206952
0.14645
0.124222
0.162624
0.134312
1.69016e-06
5.32909e-05
0.000429758
6.32377
2.5595
2.19394
1.51517
1.07477
0.673688
0.364196
0.190099
0.17115
0.22098
0.259533
0.27837
0.275638
0.0272295
0.00220566
0.38253
1.97953
1.4298
1.57726
1.98656
3.83653
0.294361
0.15287
0.129224
0.0476281
0.126464
0.11301
1.6654e-06
1.41429e-06
0.420305
0.599053
0.996103
1.03539
0.869341
0.750242
0.439555
0.262515
0.18898
0.189669
0.221666
0.245709
0.258666
0.248193
0.193442
2.78496e-06
0.0133272
1.59513
1.26947
1.19044
1.65223
3.82903
0.314349
0.111658
0.140078
0.0193476
0.0279683
0.0775826
0.00361217
0.0509445
4.04412e-05
1.06822e-05
0.724424
0.702032
0.792346
0.543066
0.277974
0.187556
0.16841
0.181052
0.200519
0.212311
0.219314
0.212808
0.200706
0.0320757
6.78732e-05
0.230761
1.29043
0.996674
1.27386
3.33375
0.376702
0.115803
0.125439
0.137555
7.46275e-05
0.0381094
0.103159
5.39365e-06
2.50167e-05
1.57777
0.58623
0.585984
0.688286
0.417715
0.187246
0.132687
0.1387
0.15801
0.171369
0.177917
0.181389
0.176178
0.164102
0.101116
1.27664e-05
0.0495748
0.7339
1.07696
1.22261
2.93686
0.490466
0.168365
0.098935
0.156086
0.0637178
0.00470162
1.89079e-07
1.36987e-06
1.98686
0.00312184
2.3879e-05
0.648912
0.643234
0.364874
0.143352
0.090324
0.0991392
0.119565
0.132481
0.140378
0.145372
0.138917
0.120389
0.103124
0.00442933
0.0149732
0.254997
0.87901
1.3385
2.96163
0.00447182
0.321298
0.125826
0.0787339
0.0303022
7.44296e-05
2.09669e-06
0.71087
1.20263e-05
0.00010169
0.609688
0.213628
0.4098
0.315853
0.125759
0.0702694
0.0724534
0.0881278
0.103137
0.115483
0.122284
0.111569
0.0775165
0.0586621
0.0148963
0.00111737
0.148384
0.627264
1.15641
2.57446
5.09674e-07
1.26524e-06
1.99305e-06
2.57133e-06
4.28868e-06
5.71337e-06
7.56343e-06
5.11675e-06
2.72082e-06
2.97939e-06
1.08527e-05
2.74979e-06
0.258165
0.213994
0.0671556
0.0114681
0.00276119
0.00323744
0.00603409
0.0108832
0.0159433
0.0161132
0.00643741
2.57844e-05
2.8889e-06
2.88617e-07
2.15098e-07
8.26081e-07
0.00611115
0.175495
)
;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.0002;
}
outlet
{
type zeroGradient;
}
walls
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | |
1afb7806915f337e9799a176224c11a0ec6bcffd | c121a3df58a0b1b5665439f94f7c7f83c1b0492b | /code/partition-comparison/src/partition_comparison.cpp | 4b952850aed11c6951d9f8ba035078a16c02c75a | [
"MIT"
] | permissive | Rhoana/icon | a73d100336ae3845e7b326357c9598fbeabefbd8 | 1666ed2651c7ca81e0343ace3641d862684509a7 | refs/heads/master | 2022-10-11T21:28:38.579729 | 2022-09-30T13:58:36 | 2022-09-30T13:58:36 | 91,745,495 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | true | 1,068,291 | cpp | /* Generated by Cython 0.23.4 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
#error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_23_4"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyClass_Type
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
#define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
#define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
#else
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
#else
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#define PyNumber_Int PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
#ifndef PyUnicode_InternFromString
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
#endif
#endif
#if PY_VERSION_HEX < 0x030200A4
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
#if defined(__GNUC__)
#define CYTHON_RESTRICT __restrict__
#elif defined(_MSC_VER) && _MSC_VER >= 1400
#define CYTHON_RESTRICT __restrict
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_RESTRICT restrict
#else
#define CYTHON_RESTRICT
#endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifndef __cplusplus
#error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
#define CYTHON_INLINE inline
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
x.~T();
}
template<typename T>
class __Pyx_FakeReference {
public:
__Pyx_FakeReference() : ptr(NULL) { }
__Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
T *operator->() { return ptr; }
operator T&() { return *ptr; }
private:
T *ptr;
};
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
float value;
memset(&value, 0xFF, sizeof(value));
return value;
}
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#define __PYX_HAVE__partition_comparison
#define __PYX_HAVE_API__partition_comparison
#include "stdint.h"
#include "andres/partition-comparison.hxx"
#include "pythread.h"
#include "string.h"
#include "stdlib.h"
#include "stdio.h"
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
# define CYTHON_NCP_UNUSED
# else
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
(sizeof(type) < sizeof(Py_ssize_t)) ||\
(sizeof(type) > sizeof(Py_ssize_t) &&\
likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX) &&\
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
v == (type)PY_SSIZE_T_MIN))) ||\
(sizeof(type) == sizeof(Py_ssize_t) &&\
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX))) )
#if defined (__cplusplus) && __cplusplus >= 201103L
#include <cstdlib>
#define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
#define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
#define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
const Py_UNICODE *u_end = u;
while (*u_end++) ;
return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
PyObject* ascii_chars_u = NULL;
PyObject* ascii_chars_b = NULL;
const char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
if (strcmp(default_encoding_c, "ascii") == 0) {
__Pyx_sys_getdefaultencoding_not_ascii = 0;
} else {
char ascii_chars[128];
int c;
for (c = 0; c < 128; c++) {
ascii_chars[c] = c;
}
__Pyx_sys_getdefaultencoding_not_ascii = 1;
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
if (!ascii_chars_u) goto bad;
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format(
PyExc_ValueError,
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
default_encoding_c);
goto bad;
}
Py_DECREF(ascii_chars_u);
Py_DECREF(ascii_chars_b);
}
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
Py_XDECREF(ascii_chars_u);
Py_XDECREF(ascii_chars_b);
return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
return -1;
}
#endif
#endif
/* Test for GCC > 2.95 */
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char *__pyx_f[] = {
"src/partition_comparison.pyx",
"stringsource",
};
struct __pyx_memoryview_obj;
typedef struct {
struct __pyx_memoryview_obj *memview;
char *data;
Py_ssize_t shape[8];
Py_ssize_t strides[8];
Py_ssize_t suboffsets[8];
} __Pyx_memviewslice;
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
const char* name;
struct __Pyx_StructField_* fields;
size_t size;
size_t arraysize[8];
int ndim;
char typegroup;
char is_unsigned;
int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
__Pyx_TypeInfo* type;
const char* name;
size_t offset;
} __Pyx_StructField;
typedef struct {
__Pyx_StructField* field;
size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
size_t new_count, enc_count;
size_t struct_alignment;
int is_complex;
char enc_type;
char new_packmode;
char enc_packmode;
char is_valid_array;
} __Pyx_BufFmt_Context;
#include <pythread.h>
#ifndef CYTHON_ATOMICS
#define CYTHON_ATOMICS 1
#endif
#define __pyx_atomic_int_type int
#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
(__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
!defined(__i386__)
#define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
#define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
#ifdef __PYX_DEBUG_ATOMICS
#warning "Using GNU atomics"
#endif
#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
#include <Windows.h>
#undef __pyx_atomic_int_type
#define __pyx_atomic_int_type LONG
#define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
#define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
#ifdef __PYX_DEBUG_ATOMICS
#pragma message ("Using MSVC atomics")
#endif
#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
#define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
#define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
#ifdef __PYX_DEBUG_ATOMICS
#warning "Using Intel atomics"
#endif
#else
#undef CYTHON_ATOMICS
#define CYTHON_ATOMICS 0
#ifdef __PYX_DEBUG_ATOMICS
#warning "Not using atomics"
#endif
#endif
typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
#if CYTHON_ATOMICS
#define __pyx_add_acquisition_count(memview)\
__pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#define __pyx_sub_acquisition_count(memview)\
__pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#else
#define __pyx_add_acquisition_count(memview)\
__pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#define __pyx_sub_acquisition_count(memview)\
__pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#endif
/*--- Type declarations ---*/
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;
/* "View.MemoryView":101
*
* @cname("__pyx_array")
* cdef class array: # <<<<<<<<<<<<<<
*
* cdef:
*/
struct __pyx_array_obj {
PyObject_HEAD
char *data;
Py_ssize_t len;
char *format;
int ndim;
Py_ssize_t *_shape;
Py_ssize_t *_strides;
Py_ssize_t itemsize;
PyObject *mode;
PyObject *_format;
void (*callback_free_data)(void *);
int free_data;
int dtype_is_object;
};
/* "View.MemoryView":271
*
* @cname('__pyx_MemviewEnum')
* cdef class Enum(object): # <<<<<<<<<<<<<<
* cdef object name
* def __init__(self, name):
*/
struct __pyx_MemviewEnum_obj {
PyObject_HEAD
PyObject *name;
};
/* "View.MemoryView":304
*
* @cname('__pyx_memoryview')
* cdef class memoryview(object): # <<<<<<<<<<<<<<
*
* cdef object obj
*/
struct __pyx_memoryview_obj {
PyObject_HEAD
struct __pyx_vtabstruct_memoryview *__pyx_vtab;
PyObject *obj;
PyObject *_size;
PyObject *_array_interface;
PyThread_type_lock lock;
__pyx_atomic_int acquisition_count[2];
__pyx_atomic_int *acquisition_count_aligned_p;
Py_buffer view;
int flags;
int dtype_is_object;
__Pyx_TypeInfo *typeinfo;
};
/* "View.MemoryView":923
*
* @cname('__pyx_memoryviewslice')
* cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
* "Internal class for passing memoryview slices to Python"
*
*/
struct __pyx_memoryviewslice_obj {
struct __pyx_memoryview_obj __pyx_base;
__Pyx_memviewslice from_slice;
PyObject *from_object;
PyObject *(*to_object_func)(char *);
int (*to_dtype_func)(char *, PyObject *);
};
/* "View.MemoryView":304
*
* @cname('__pyx_memoryview')
* cdef class memoryview(object): # <<<<<<<<<<<<<<
*
* cdef object obj
*/
struct __pyx_vtabstruct_memoryview {
char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
};
static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
/* "View.MemoryView":923
*
* @cname('__pyx_memoryviewslice')
* cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
* "Internal class for passing memoryview slices to Python"
*
*/
struct __pyx_vtabstruct__memoryviewslice {
struct __pyx_vtabstruct_memoryview __pyx_base;
};
static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
/* --- Runtime support code (head) --- */
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
if (acquire_gil) {\
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
PyGILState_Release(__pyx_gilstate_save);\
} else {\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext()\
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_XDECREF(tmp);\
} while (0)
#define __Pyx_DECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_DECREF(tmp);\
} while (0)
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
PyTypeObject* tp = Py_TYPE(obj);
if (likely(tp->tp_getattro))
return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
if (likely(tp->tp_getattr))
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
const char* function_name);
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb);
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
int is_list, int wraparound, int boundscheck);
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
int result = PyDict_Contains(dict, item);
return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
PyObject *value;
value = PyDict_GetItemWithError(d, key);
if (unlikely(!value)) {
if (!PyErr_Occurred()) {
PyObject* args = PyTuple_Pack(1, key);
if (likely(args))
PyErr_SetObject(PyExc_KeyError, args);
Py_XDECREF(args);
}
return NULL;
}
Py_INCREF(value);
return value;
}
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyObject_Ord(c)\
(likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
#else
#define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
#endif
static long __Pyx__PyObject_Ord(PyObject* c);
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
(is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
int is_list, int wraparound, int boundscheck);
static CYTHON_INLINE int __Pyx_IterFinish(void);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
int is_tuple, int has_known_size, int decref_tuple);
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
PyListObject* L = (PyListObject*) list;
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
Py_INCREF(x);
PyList_SET_ITEM(list, len, x);
Py_SIZE(list) = len+1;
return 0;
}
return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif
static void __Pyx_RaiseBufferIndexError(int axis);
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
__Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
#define __Pyx_MEMVIEW_DIRECT 1
#define __Pyx_MEMVIEW_PTR 2
#define __Pyx_MEMVIEW_FULL 4
#define __Pyx_MEMVIEW_CONTIG 8
#define __Pyx_MEMVIEW_STRIDED 16
#define __Pyx_MEMVIEW_FOLLOW 32
#define __Pyx_IS_C_CONTIG 1
#define __Pyx_IS_F_CONTIG 2
static int __Pyx_init_memviewslice(
struct __pyx_memoryview_obj *memview,
int ndim,
__Pyx_memviewslice *memviewslice,
int memview_is_new_reference);
static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
__pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
__pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact);
#include <string.h>
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
#define UNARY_NEG_WOULD_OVERFLOW(x)\
(((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
const char* cstring, Py_ssize_t start, Py_ssize_t stop,
const char* encoding, const char* errors,
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
PyListObject* L = (PyListObject*) list;
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len)) {
Py_INCREF(x);
PyList_SET_ITEM(list, len, x);
Py_SIZE(list) = len+1;
return 0;
}
return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
(inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject* none = _PyList_Extend((PyListObject*)L, v);
if (unlikely(!none))
return -1;
Py_DECREF(none);
return 0;
#else
return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#endif
static CYTHON_INLINE long __Pyx_div_long(long, long);
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self); /*proto*/
static void __Pyx_WriteUnraisable(const char *name, int clineno,
int lineno, const char *filename,
int full_traceback, int nogil);
static int __Pyx_SetVtable(PyObject *dict, void *vtable);
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
#define __Pyx_CYFUNCTION_CCLASS 0x04
#define __Pyx_CyFunction_GetClosure(f)\
(((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
(((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
PyObject *func_weakreflist;
#endif
PyObject *func_dict;
PyObject *func_name;
PyObject *func_qualname;
PyObject *func_doc;
PyObject *func_globals;
PyObject *func_code;
PyObject *func_closure;
PyObject *func_classobj;
void *defaults;
int defaults_pyobjects;
int flags;
PyObject *defaults_tuple;
PyObject *defaults_kwdict;
PyObject *(*defaults_getter)(PyObject *);
PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
__Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
int flags, PyObject* qualname,
PyObject *self,
PyObject *module, PyObject *globals,
PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
size_t size,
int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
PyObject *dict);
static int __pyx_CyFunction_init(void);
typedef struct {
__pyx_CyFunctionObject func;
PyObject *__signatures__;
PyObject *type;
PyObject *self;
} __pyx_FusedFunctionObject;
#define __pyx_FusedFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
__pyx_FusedFunction_New(__pyx_FusedFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__pyx_FusedFunction_New(PyTypeObject *type,
PyMethodDef *ml, int flags,
PyObject *qualname, PyObject *self,
PyObject *module, PyObject *globals,
PyObject *code);
static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self);
static PyTypeObject *__pyx_FusedFunctionType = NULL;
static int __pyx_FusedFunction_init(void);
#define __Pyx_FusedFunction_USED
typedef struct {
int code_line;
PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename);
static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
static int __Pyx_ValidateAndInit_memviewslice(
int *axes_specs,
int c_or_f_flag,
int buf_flags,
int ndim,
__Pyx_TypeInfo *dtype,
__Pyx_BufFmt_StackElem stack[],
__Pyx_memviewslice *memviewslice,
PyObject *original_obj);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(PyObject *);
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(PyObject *);
typedef struct {
Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
size_t refcount;
Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
__Pyx_Buffer *rcbuffer;
char *data;
__Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value);
static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *);
static PyObject *__pyx_memview_get_nn_int8_t(const char *itemp);
static int __pyx_memview_set_nn_int8_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value);
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *);
static PyObject *__pyx_memview_get_nn_int16_t(const char *itemp);
static int __pyx_memview_set_nn_int16_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);
static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);
static PyObject *__pyx_memview_get_nn_int32_t(const char *itemp);
static int __pyx_memview_set_nn_int32_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);
static PyObject *__pyx_memview_get_nn_int64_t(const char *itemp);
static int __pyx_memview_set_nn_int64_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);
static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *);
static PyObject *__pyx_memview_get_nn_uint8_t(const char *itemp);
static int __pyx_memview_set_nn_uint8_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value);
static CYTHON_INLINE uint16_t __Pyx_PyInt_As_uint16_t(PyObject *);
static PyObject *__pyx_memview_get_nn_uint16_t(const char *itemp);
static int __pyx_memview_set_nn_uint16_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);
static PyObject *__pyx_memview_get_nn_uint32_t(const char *itemp);
static int __pyx_memview_set_nn_uint32_t(const char *itemp, PyObject *obj);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);
static PyObject *__pyx_memview_get_nn_uint64_t(const char *itemp);
static int __pyx_memview_set_nn_uint64_t(const char *itemp, PyObject *obj);
static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
char order, int ndim);
static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
__Pyx_memviewslice *slice2,
int ndim, size_t itemsize);
static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
const char *mode, int ndim,
size_t sizeof_dtype, int contig_flag,
int dtype_is_object);
static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
static int __Pyx_check_binary_version(void);
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
/* Module declarations from 'cython.view' */
/* Module declarations from 'cython' */
/* Module declarations from 'libc.stdint' */
/* Module declarations from 'partition_comparison' */
static PyTypeObject *__pyx_array_type = 0;
static PyTypeObject *__pyx_MemviewEnum_type = 0;
static PyTypeObject *__pyx_memoryview_type = 0;
static PyTypeObject *__pyx_memoryviewslice_type = 0;
static PyObject *generic = 0;
static PyObject *strided = 0;
static PyObject *indirect = 0;
static PyObject *contiguous = 0;
static PyObject *indirect_contiguous = 0;
static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
static void *__pyx_align_pointer(void *, size_t); /*proto*/
static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
static PyObject *_unellipsify(PyObject *, int); /*proto*/
static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_int8_t = { "int8_t", NULL, sizeof(int8_t), { 0 }, 0, IS_UNSIGNED(int8_t) ? 'U' : 'I', IS_UNSIGNED(int8_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_int16_t = { "int16_t", NULL, sizeof(int16_t), { 0 }, 0, IS_UNSIGNED(int16_t) ? 'U' : 'I', IS_UNSIGNED(int16_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_int32_t = { "int32_t", NULL, sizeof(int32_t), { 0 }, 0, IS_UNSIGNED(int32_t) ? 'U' : 'I', IS_UNSIGNED(int32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_int64_t = { "int64_t", NULL, sizeof(int64_t), { 0 }, 0, IS_UNSIGNED(int64_t) ? 'U' : 'I', IS_UNSIGNED(int64_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_uint8_t = { "uint8_t", NULL, sizeof(uint8_t), { 0 }, 0, IS_UNSIGNED(uint8_t) ? 'U' : 'I', IS_UNSIGNED(uint8_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_uint16_t = { "uint16_t", NULL, sizeof(uint16_t), { 0 }, 0, IS_UNSIGNED(uint16_t) ? 'U' : 'I', IS_UNSIGNED(uint16_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_uint32_t = { "uint32_t", NULL, sizeof(uint32_t), { 0 }, 0, IS_UNSIGNED(uint32_t) ? 'U' : 'I', IS_UNSIGNED(uint32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn_uint64_t = { "uint64_t", NULL, sizeof(uint64_t), { 0 }, 0, IS_UNSIGNED(uint64_t) ? 'U' : 'I', IS_UNSIGNED(uint64_t), 0 };
#define __Pyx_MODULE_NAME "partition_comparison"
int __pyx_module_is_main_partition_comparison = 0;
/* Implementation of 'partition_comparison' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_IndexError;
static char __pyx_k_[] = "()";
static char __pyx_k_O[] = "O";
static char __pyx_k_c[] = "c";
static char __pyx_k_x[] = "x";
static char __pyx_k_y[] = "y";
static char __pyx_k__3[] = "|";
static char __pyx_k_id[] = "id";
static char __pyx_k_obj[] = "obj";
static char __pyx_k_zip[] = "zip";
static char __pyx_k_args[] = "args";
static char __pyx_k_base[] = "base";
static char __pyx_k_kind[] = "kind";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_mode[] = "mode";
static char __pyx_k_name[] = "name";
static char __pyx_k_ndim[] = "ndim";
static char __pyx_k_pack[] = "pack";
static char __pyx_k_size[] = "size";
static char __pyx_k_step[] = "step";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_ASCII[] = "ASCII";
static char __pyx_k_class[] = "__class__";
static char __pyx_k_dtype[] = "dtype";
static char __pyx_k_error[] = "error";
static char __pyx_k_flags[] = "flags";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_range[] = "range";
static char __pyx_k_shape[] = "shape";
static char __pyx_k_split[] = "split";
static char __pyx_k_start[] = "start";
static char __pyx_k_strip[] = "strip";
static char __pyx_k_encode[] = "encode";
static char __pyx_k_format[] = "format";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_int8_t[] = "int8_t";
static char __pyx_k_kwargs[] = "kwargs";
static char __pyx_k_name_2[] = "__name__";
static char __pyx_k_struct[] = "struct";
static char __pyx_k_unpack[] = "unpack";
static char __pyx_k_fortran[] = "fortran";
static char __pyx_k_int16_t[] = "int16_t";
static char __pyx_k_int32_t[] = "int32_t";
static char __pyx_k_int64_t[] = "int64_t";
static char __pyx_k_memview[] = "memview";
static char __pyx_k_ndarray[] = "ndarray";
static char __pyx_k_uint8_t[] = "uint8_t";
static char __pyx_k_Ellipsis[] = "Ellipsis";
static char __pyx_k_defaults[] = "defaults";
static char __pyx_k_itemsize[] = "itemsize";
static char __pyx_k_uint16_t[] = "uint16_t";
static char __pyx_k_uint32_t[] = "uint32_t";
static char __pyx_k_uint64_t[] = "uint64_t";
static char __pyx_k_TypeError[] = "TypeError";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_rand_index[] = "rand_index";
static char __pyx_k_signatures[] = "signatures";
static char __pyx_k_ImportError[] = "ImportError";
static char __pyx_k_MemoryError[] = "MemoryError";
static char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static char __pyx_k_AttributeError[] = "AttributeError";
static char __pyx_k_allocate_buffer[] = "allocate_buffer";
static char __pyx_k_dtype_is_object[] = "dtype_is_object";
static char __pyx_k_strided_and_direct[] = "<strided and direct>";
static char __pyx_k_partition_comparison[] = "partition_comparison";
static char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static char __pyx_k_getbuffer_obj_view_flags[] = "getbuffer(obj, view, flags)";
static char __pyx_k_variation_of_information[] = "variation_of_information";
static char __pyx_k_Dimension_d_is_not_direct[] = "Dimension %d is not direct";
static char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static char __pyx_k_Index_out_of_bounds_axis_d[] = "Index out of bounds (axis %d)";
static char __pyx_k_No_matching_signature_found[] = "No matching signature found";
static char __pyx_k_Step_may_not_be_zero_axis_d[] = "Step may not be zero (axis %d)";
static char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static char __pyx_k_Expected_at_least_d_arguments[] = "Expected at least %d arguments";
static char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
static char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
static char __pyx_k_home_fgonda_results_partition_c[] = "/home/fgonda/results/partition-comparison/src/partition_comparison.pyx";
static char __pyx_k_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced";
static char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
static char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
static char __pyx_k_Cannot_transpose_memoryview_with[] = "Cannot transpose memoryview with indirect dimensions";
static char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
static char __pyx_k_Function_call_with_ambiguous_arg[] = "Function call with ambiguous argument types";
static char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
static char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
static char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
static char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
static char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
static char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_n_s_ASCII;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
static PyObject *__pyx_n_s_Ellipsis;
static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
static PyObject *__pyx_kp_s_Expected_at_least_d_arguments;
static PyObject *__pyx_kp_s_Function_call_with_ambiguous_arg;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
static PyObject *__pyx_kp_s_MemoryView_of_r_object;
static PyObject *__pyx_kp_s_No_matching_signature_found;
static PyObject *__pyx_n_b_O;
static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_n_s_allocate_buffer;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_kp_s_contiguous_and_direct;
static PyObject *__pyx_kp_s_contiguous_and_indirect;
static PyObject *__pyx_n_s_defaults;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dtype_is_object;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_fortran;
static PyObject *__pyx_n_u_fortran;
static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
static PyObject *__pyx_kp_s_home_fgonda_results_partition_c;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_int16_t;
static PyObject *__pyx_n_s_int32_t;
static PyObject *__pyx_n_s_int64_t;
static PyObject *__pyx_n_s_int8_t;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
static PyObject *__pyx_n_s_kind;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_memview;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_ndarray;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_pack;
static PyObject *__pyx_n_s_partition_comparison;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_rand_index;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_signatures;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_kp_s_strided_and_direct;
static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
static PyObject *__pyx_kp_s_strided_and_indirect;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_uint16_t;
static PyObject *__pyx_n_s_uint32_t;
static PyObject *__pyx_n_s_uint64_t;
static PyObject *__pyx_n_s_uint8_t;
static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
static PyObject *__pyx_n_s_unpack;
static PyObject *__pyx_n_s_variation_of_information;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_20partition_comparison_rand_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
static PyObject *__pyx_pf_20partition_comparison_4rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_6rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_8rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_10rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_12rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_14rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_16rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_18rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_2variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
static PyObject *__pyx_pf_20partition_comparison_22variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_24variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_26variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_28variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_30variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_32variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_34variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static PyObject *__pyx_pf_20partition_comparison_36variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__20;
static PyObject *__pyx_slice__21;
static PyObject *__pyx_slice__22;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_codeobj__25;
static PyObject *__pyx_codeobj__27;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* Python wrapper */
static PyObject *__pyx_pw_20partition_comparison_1rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_20partition_comparison_1rand_index = {"rand_index", (PyCFunction)__pyx_pw_20partition_comparison_1rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_20partition_comparison_1rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_signatures = 0;
PyObject *__pyx_v_args = 0;
PyObject *__pyx_v_kwargs = 0;
CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
PyObject* values[4] = {0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 3:
if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
}
__pyx_v_signatures = values[0];
__pyx_v_args = values[1];
__pyx_v_kwargs = values[2];
__pyx_v_defaults = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_rand_index(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_rand_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
PyObject *__pyx_v_dest_sig = NULL;
PyTypeObject *__pyx_v_ndarray = 0;
PyObject *__pyx_v_numpy = NULL;
__Pyx_memviewslice __pyx_v_memslice;
Py_ssize_t __pyx_v_itemsize;
int __pyx_v_dtype_signed;
char __pyx_v_kind;
int __pyx_v____pyx_int16_t_is_signed;
int __pyx_v____pyx_uint8_t_is_signed;
int __pyx_v____pyx_int32_t_is_signed;
int __pyx_v____pyx_uint64_t_is_signed;
int __pyx_v____pyx_uint32_t_is_signed;
int __pyx_v____pyx_int8_t_is_signed;
int __pyx_v____pyx_uint16_t_is_signed;
int __pyx_v____pyx_int64_t_is_signed;
PyObject *__pyx_v_arg = NULL;
PyObject *__pyx_v_dtype = NULL;
PyObject *__pyx_v_arg_base = NULL;
PyObject *__pyx_v_candidates = NULL;
PyObject *__pyx_v_sig = NULL;
int __pyx_v_match_found;
PyObject *__pyx_v_src_type = NULL;
PyObject *__pyx_v_dst_type = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
Py_ssize_t __pyx_t_10;
long __pyx_t_11;
Py_ssize_t __pyx_t_12;
int __pyx_t_13;
Py_ssize_t __pyx_t_14;
PyObject *(*__pyx_t_15)(PyObject *);
PyObject *__pyx_t_16 = NULL;
PyObject *__pyx_t_17 = NULL;
PyObject *__pyx_t_18 = NULL;
PyObject *(*__pyx_t_19)(PyObject *);
int __pyx_t_20;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("rand_index", 0);
__Pyx_INCREF(__pyx_v_kwargs);
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
__pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_2 = (__pyx_v_kwargs == Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF_SET(__pyx_v_kwargs, __pyx_t_1);
__pyx_t_1 = 0;
}
{
__Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
__Pyx_XGOTREF(__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_5);
__Pyx_XGOTREF(__pyx_t_6);
/*try:*/ {
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_numpy = __pyx_t_1;
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_numpy, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(PyType_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "type", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
__pyx_t_1 = 0;
}
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
goto __pyx_L11_try_end;
__pyx_L4_error:;
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_ImportError) || PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || PyErr_ExceptionMatches(__pyx_builtin_TypeError);
if (__pyx_t_7) {
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GOTREF(__pyx_t_9);
__Pyx_INCREF(Py_None);
__Pyx_XDECREF_SET(__pyx_v_ndarray, ((PyTypeObject*)Py_None));
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L5_exception_handled;
}
goto __pyx_L6_except_error;
__pyx_L6_except_error:;
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_XGIVEREF(__pyx_t_6);
__Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
goto __pyx_L1_error;
__pyx_L5_exception_handled:;
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_XGIVEREF(__pyx_t_6);
__Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
__pyx_L11_try_end:;
}
__pyx_v_itemsize = -1L;
__pyx_v____pyx_int16_t_is_signed = (((int16_t)-1L) < 0);
__pyx_v____pyx_uint8_t_is_signed = (((uint8_t)-1L) < 0);
__pyx_v____pyx_int32_t_is_signed = (((int32_t)-1L) < 0);
__pyx_v____pyx_uint64_t_is_signed = (((uint64_t)-1L) < 0);
__pyx_v____pyx_uint32_t_is_signed = (((uint32_t)-1L) < 0);
__pyx_v____pyx_int8_t_is_signed = (((int8_t)-1L) < 0);
__pyx_v____pyx_uint16_t_is_signed = (((uint16_t)-1L) < 0);
__pyx_v____pyx_int64_t_is_signed = (((int64_t)-1L) < 0);
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((0 < __pyx_t_10) != 0);
if (__pyx_t_3) {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_GetItemInt_Tuple(((PyObject*)__pyx_v_args), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__pyx_v_arg = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L14;
}
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_x, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_x); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__pyx_v_arg = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L14;
}
/*else*/ {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_9 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_arguments, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_8);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
__pyx_t_8 = 0;
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L14:;
while (1) {
__pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_dtype = __pyx_t_8;
__pyx_t_8 = 0;
goto __pyx_L18;
}
__pyx_t_2 = (__pyx_memoryview_check(__pyx_v_arg) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_arg_base = __pyx_t_8;
__pyx_t_8 = 0;
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_dtype = __pyx_t_8;
__pyx_t_8 = 0;
goto __pyx_L19;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L19:;
goto __pyx_L18;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L18:;
__pyx_v_itemsize = -1L;
__pyx_t_3 = (__pyx_v_dtype != Py_None);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_v_itemsize = __pyx_t_10;
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_11 = __Pyx_PyObject_Ord(__pyx_t_8); if (unlikely(__pyx_t_11 == (long)(Py_UCS4)-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_v_kind = __pyx_t_11;
__pyx_v_dtype_signed = (__pyx_v_kind == 'i');
switch (__pyx_v_kind) {
case 'i':
case 'u':
__pyx_t_3 = (((sizeof(int8_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L22_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L22_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int8_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L22_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int16_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L26_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L26_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int16_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L26_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int32_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L30_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L30_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int32_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L30_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int64_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L34_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L34_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int64_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L34_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint8_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L38_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L38_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint8_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L38_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint16_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L42_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L42_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint16_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L42_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint32_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L46_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L46_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint32_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L46_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint64_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L50_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L50_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint64_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L50_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
break;
case 'f':
break;
case 'c':
break;
case 'O':
break;
default: break;
}
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L54_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int8_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L54_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L58_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int16_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L58_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L62_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int32_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L62_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L66_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int64_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L66_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L70_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint8_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L70_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L74_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint16_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L74_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L78_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint32_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L78_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L82_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint64_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L82_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_L16_break:;
__pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_candidates = ((PyObject*)__pyx_t_8);
__pyx_t_8 = 0;
__pyx_t_10 = 0;
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_12), (&__pyx_t_7)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_8);
__pyx_t_8 = __pyx_t_9;
__pyx_t_9 = 0;
while (1) {
__pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_8, __pyx_t_12, &__pyx_t_10, &__pyx_t_9, NULL, NULL, __pyx_t_7);
if (unlikely(__pyx_t_13 == 0)) break;
if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_9);
__pyx_t_9 = 0;
__pyx_v_match_found = 0;
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
__Pyx_INCREF(__pyx_v_dest_sig);
__Pyx_GIVEREF(__pyx_v_dest_sig);
PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_dest_sig);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
__pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9); __pyx_t_14 = 0;
__pyx_t_15 = NULL;
} else {
__pyx_t_14 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_15 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
for (;;) {
if (likely(!__pyx_t_15)) {
if (likely(PyList_CheckExact(__pyx_t_9))) {
if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_9)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
#endif
} else {
if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
#endif
}
} else {
__pyx_t_1 = __pyx_t_15(__pyx_t_9);
if (unlikely(!__pyx_t_1)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_1);
}
if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
PyObject* sequence = __pyx_t_1;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
__pyx_t_16 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_17 = PyTuple_GET_ITEM(sequence, 1);
} else {
__pyx_t_16 = PyList_GET_ITEM(sequence, 0);
__pyx_t_17 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_16);
__Pyx_INCREF(__pyx_t_17);
#else
__pyx_t_16 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_16);
__pyx_t_17 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_17);
#endif
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_18 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_18);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_19 = Py_TYPE(__pyx_t_18)->tp_iternext;
index = 0; __pyx_t_16 = __pyx_t_19(__pyx_t_18); if (unlikely(!__pyx_t_16)) goto __pyx_L89_unpacking_failed;
__Pyx_GOTREF(__pyx_t_16);
index = 1; __pyx_t_17 = __pyx_t_19(__pyx_t_18); if (unlikely(!__pyx_t_17)) goto __pyx_L89_unpacking_failed;
__Pyx_GOTREF(__pyx_t_17);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_19(__pyx_t_18), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_19 = NULL;
__Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
goto __pyx_L90_unpacking_done;
__pyx_L89_unpacking_failed:;
__Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
__pyx_t_19 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L90_unpacking_done:;
}
__Pyx_XDECREF_SET(__pyx_v_src_type, __pyx_t_16);
__pyx_t_16 = 0;
__Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_17);
__pyx_t_17 = 0;
__pyx_t_2 = (__pyx_v_dst_type != Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_1 = PyObject_RichCompare(__pyx_v_src_type, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_3) {
__pyx_v_match_found = 1;
goto __pyx_L92;
}
/*else*/ {
__pyx_v_match_found = 0;
goto __pyx_L88_break;
}
__pyx_L92:;
}
}
__pyx_L88_break:;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_3 = (__pyx_v_match_found != 0);
if (__pyx_t_3) {
__pyx_t_20 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = (__pyx_v_candidates != Py_None) && (PyList_GET_SIZE(__pyx_v_candidates) != 0);
__pyx_t_2 = ((!__pyx_t_3) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_12 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = ((__pyx_t_12 > 1) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
/*else*/ {
__Pyx_XDECREF(__pyx_r);
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_candidates, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), __pyx_t_8); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_r = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L0;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_16);
__Pyx_XDECREF(__pyx_t_17);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_dest_sig);
__Pyx_XDECREF(__pyx_v_ndarray);
__Pyx_XDECREF(__pyx_v_numpy);
__Pyx_XDECREF(__pyx_v_arg);
__Pyx_XDECREF(__pyx_v_dtype);
__Pyx_XDECREF(__pyx_v_arg_base);
__Pyx_XDECREF(__pyx_v_candidates);
__Pyx_XDECREF(__pyx_v_sig);
__Pyx_XDECREF(__pyx_v_src_type);
__Pyx_XDECREF(__pyx_v_dst_type);
__Pyx_XDECREF(__pyx_v_kwargs);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_0__pyx_pw_20partition_comparison_5rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_0__pyx_mdef_20partition_comparison_5rand_index = {"__pyx_fuse_0rand_index", (PyCFunction)__pyx_fuse_0__pyx_pw_20partition_comparison_5rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_0__pyx_pw_20partition_comparison_5rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_4rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_4rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_0rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_1__pyx_pw_20partition_comparison_7rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_1__pyx_mdef_20partition_comparison_7rand_index = {"__pyx_fuse_1rand_index", (PyCFunction)__pyx_fuse_1__pyx_pw_20partition_comparison_7rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_1__pyx_pw_20partition_comparison_7rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_6rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_6rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_1rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_2__pyx_pw_20partition_comparison_9rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_2__pyx_mdef_20partition_comparison_9rand_index = {"__pyx_fuse_2rand_index", (PyCFunction)__pyx_fuse_2__pyx_pw_20partition_comparison_9rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_2__pyx_pw_20partition_comparison_9rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_8rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_8rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_2rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_3__pyx_pw_20partition_comparison_11rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_3__pyx_mdef_20partition_comparison_11rand_index = {"__pyx_fuse_3rand_index", (PyCFunction)__pyx_fuse_3__pyx_pw_20partition_comparison_11rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_3__pyx_pw_20partition_comparison_11rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_10rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_10rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_3rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_4__pyx_pw_20partition_comparison_13rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_4__pyx_mdef_20partition_comparison_13rand_index = {"__pyx_fuse_4rand_index", (PyCFunction)__pyx_fuse_4__pyx_pw_20partition_comparison_13rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_4__pyx_pw_20partition_comparison_13rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_12rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_12rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_4rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_5__pyx_pw_20partition_comparison_15rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_5__pyx_mdef_20partition_comparison_15rand_index = {"__pyx_fuse_5rand_index", (PyCFunction)__pyx_fuse_5__pyx_pw_20partition_comparison_15rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_5__pyx_pw_20partition_comparison_15rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_14rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_14rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_5rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_6__pyx_pw_20partition_comparison_17rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_6__pyx_mdef_20partition_comparison_17rand_index = {"__pyx_fuse_6rand_index", (PyCFunction)__pyx_fuse_6__pyx_pw_20partition_comparison_17rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_6__pyx_pw_20partition_comparison_17rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_16rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_16rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_6rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_7__pyx_pw_20partition_comparison_19rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_7__pyx_mdef_20partition_comparison_19rand_index = {"__pyx_fuse_7rand_index", (PyCFunction)__pyx_fuse_7__pyx_pw_20partition_comparison_19rand_index, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_7__pyx_pw_20partition_comparison_19rand_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("rand_index (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rand_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("rand_index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_18rand_index(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_18rand_index(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_7rand_index", 0);
/* "partition_comparison.pyx":21
*
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":22
* def rand_index(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*
* def variation_of_information(Label[::1] x, Label[::1] y):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::randIndex((&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.rand_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* Python wrapper */
static PyObject *__pyx_pw_20partition_comparison_3variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_20partition_comparison_3variation_of_information = {"variation_of_information", (PyCFunction)__pyx_pw_20partition_comparison_3variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_20partition_comparison_3variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_signatures = 0;
PyObject *__pyx_v_args = 0;
PyObject *__pyx_v_kwargs = 0;
CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
PyObject* values[4] = {0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 3:
if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
}
__pyx_v_signatures = values[0];
__pyx_v_args = values[1];
__pyx_v_kwargs = values[2];
__pyx_v_defaults = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_2variation_of_information(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_2variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
PyObject *__pyx_v_dest_sig = NULL;
PyTypeObject *__pyx_v_ndarray = 0;
PyObject *__pyx_v_numpy = NULL;
__Pyx_memviewslice __pyx_v_memslice;
Py_ssize_t __pyx_v_itemsize;
int __pyx_v_dtype_signed;
char __pyx_v_kind;
int __pyx_v____pyx_int16_t_is_signed;
int __pyx_v____pyx_uint8_t_is_signed;
int __pyx_v____pyx_int32_t_is_signed;
int __pyx_v____pyx_uint64_t_is_signed;
int __pyx_v____pyx_uint32_t_is_signed;
int __pyx_v____pyx_int8_t_is_signed;
int __pyx_v____pyx_uint16_t_is_signed;
int __pyx_v____pyx_int64_t_is_signed;
PyObject *__pyx_v_arg = NULL;
PyObject *__pyx_v_dtype = NULL;
PyObject *__pyx_v_arg_base = NULL;
PyObject *__pyx_v_candidates = NULL;
PyObject *__pyx_v_sig = NULL;
int __pyx_v_match_found;
PyObject *__pyx_v_src_type = NULL;
PyObject *__pyx_v_dst_type = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
Py_ssize_t __pyx_t_10;
long __pyx_t_11;
Py_ssize_t __pyx_t_12;
int __pyx_t_13;
Py_ssize_t __pyx_t_14;
PyObject *(*__pyx_t_15)(PyObject *);
PyObject *__pyx_t_16 = NULL;
PyObject *__pyx_t_17 = NULL;
PyObject *__pyx_t_18 = NULL;
PyObject *(*__pyx_t_19)(PyObject *);
int __pyx_t_20;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("variation_of_information", 0);
__Pyx_INCREF(__pyx_v_kwargs);
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
__pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_2 = (__pyx_v_kwargs == Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF_SET(__pyx_v_kwargs, __pyx_t_1);
__pyx_t_1 = 0;
}
{
__Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
__Pyx_XGOTREF(__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_5);
__Pyx_XGOTREF(__pyx_t_6);
/*try:*/ {
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_numpy = __pyx_t_1;
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_numpy, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(PyType_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "type", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
__pyx_t_1 = 0;
}
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
goto __pyx_L11_try_end;
__pyx_L4_error:;
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_ImportError) || PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || PyErr_ExceptionMatches(__pyx_builtin_TypeError);
if (__pyx_t_7) {
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GOTREF(__pyx_t_9);
__Pyx_INCREF(Py_None);
__Pyx_XDECREF_SET(__pyx_v_ndarray, ((PyTypeObject*)Py_None));
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L5_exception_handled;
}
goto __pyx_L6_except_error;
__pyx_L6_except_error:;
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_XGIVEREF(__pyx_t_6);
__Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
goto __pyx_L1_error;
__pyx_L5_exception_handled:;
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_XGIVEREF(__pyx_t_6);
__Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
__pyx_L11_try_end:;
}
__pyx_v_itemsize = -1L;
__pyx_v____pyx_int16_t_is_signed = (((int16_t)-1L) < 0);
__pyx_v____pyx_uint8_t_is_signed = (((uint8_t)-1L) < 0);
__pyx_v____pyx_int32_t_is_signed = (((int32_t)-1L) < 0);
__pyx_v____pyx_uint64_t_is_signed = (((uint64_t)-1L) < 0);
__pyx_v____pyx_uint32_t_is_signed = (((uint32_t)-1L) < 0);
__pyx_v____pyx_int8_t_is_signed = (((int8_t)-1L) < 0);
__pyx_v____pyx_uint16_t_is_signed = (((uint16_t)-1L) < 0);
__pyx_v____pyx_int64_t_is_signed = (((int64_t)-1L) < 0);
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((0 < __pyx_t_10) != 0);
if (__pyx_t_3) {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_GetItemInt_Tuple(((PyObject*)__pyx_v_args), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__pyx_v_arg = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L14;
}
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_x, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_x); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__pyx_v_arg = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L14;
}
/*else*/ {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_10 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_9 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_arguments, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_8);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
__pyx_t_8 = 0;
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L14:;
while (1) {
__pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_dtype = __pyx_t_8;
__pyx_t_8 = 0;
goto __pyx_L18;
}
__pyx_t_2 = (__pyx_memoryview_check(__pyx_v_arg) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_arg_base = __pyx_t_8;
__pyx_t_8 = 0;
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_dtype = __pyx_t_8;
__pyx_t_8 = 0;
goto __pyx_L19;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L19:;
goto __pyx_L18;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L18:;
__pyx_v_itemsize = -1L;
__pyx_t_3 = (__pyx_v_dtype != Py_None);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_v_itemsize = __pyx_t_10;
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_11 = __Pyx_PyObject_Ord(__pyx_t_8); if (unlikely(__pyx_t_11 == (long)(Py_UCS4)-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_v_kind = __pyx_t_11;
__pyx_v_dtype_signed = (__pyx_v_kind == 'i');
switch (__pyx_v_kind) {
case 'i':
case 'u':
__pyx_t_3 = (((sizeof(int8_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L22_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L22_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int8_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L22_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int16_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L26_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L26_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int16_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L26_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int32_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L30_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L30_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int32_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L30_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(int64_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L34_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L34_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_int64_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L34_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint8_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L38_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L38_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint8_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L38_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint16_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L42_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L42_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint16_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L42_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint32_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L46_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L46_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint32_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L46_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_t_3 = (((sizeof(uint64_t)) == __pyx_v_itemsize) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L50_bool_binop_done;
}
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = ((((Py_ssize_t)__pyx_t_10) == 1) != 0);
if (__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L50_bool_binop_done;
}
__pyx_t_3 = ((!((__pyx_v____pyx_uint64_t_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L50_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
break;
case 'f':
break;
case 'c':
break;
case 'O':
break;
default: break;
}
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L54_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int8_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L54_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L58_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int16_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L58_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L62_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int32_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L62_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L66_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(int64_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L66_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L70_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint8_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L70_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint8_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L74_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint16_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L74_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint16_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L78_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint32_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L78_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint32_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_3 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_2 = __pyx_t_3;
goto __pyx_L82_bool_binop_done;
}
__pyx_t_3 = ((__pyx_v_itemsize == (sizeof(uint64_t))) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L82_bool_binop_done:;
if (__pyx_t_2) {
__pyx_v_memslice = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(__pyx_v_arg);
__pyx_t_2 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_2) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_uint64_t, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
/*else*/ {
PyErr_Clear();
}
}
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L16_break;
}
__pyx_L16_break:;
__pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_v_candidates = ((PyObject*)__pyx_t_8);
__pyx_t_8 = 0;
__pyx_t_10 = 0;
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_9 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_12), (&__pyx_t_7)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_8);
__pyx_t_8 = __pyx_t_9;
__pyx_t_9 = 0;
while (1) {
__pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_8, __pyx_t_12, &__pyx_t_10, &__pyx_t_9, NULL, NULL, __pyx_t_7);
if (unlikely(__pyx_t_13 == 0)) break;
if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_9);
__pyx_t_9 = 0;
__pyx_v_match_found = 0;
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
__Pyx_INCREF(__pyx_v_dest_sig);
__Pyx_GIVEREF(__pyx_v_dest_sig);
PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_dest_sig);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
__pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9); __pyx_t_14 = 0;
__pyx_t_15 = NULL;
} else {
__pyx_t_14 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_15 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
for (;;) {
if (likely(!__pyx_t_15)) {
if (likely(PyList_CheckExact(__pyx_t_9))) {
if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_9)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
#endif
} else {
if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
#endif
}
} else {
__pyx_t_1 = __pyx_t_15(__pyx_t_9);
if (unlikely(!__pyx_t_1)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_1);
}
if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
PyObject* sequence = __pyx_t_1;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
__pyx_t_16 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_17 = PyTuple_GET_ITEM(sequence, 1);
} else {
__pyx_t_16 = PyList_GET_ITEM(sequence, 0);
__pyx_t_17 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_16);
__Pyx_INCREF(__pyx_t_17);
#else
__pyx_t_16 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_16);
__pyx_t_17 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_17);
#endif
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else {
Py_ssize_t index = -1;
__pyx_t_18 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_18);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_19 = Py_TYPE(__pyx_t_18)->tp_iternext;
index = 0; __pyx_t_16 = __pyx_t_19(__pyx_t_18); if (unlikely(!__pyx_t_16)) goto __pyx_L89_unpacking_failed;
__Pyx_GOTREF(__pyx_t_16);
index = 1; __pyx_t_17 = __pyx_t_19(__pyx_t_18); if (unlikely(!__pyx_t_17)) goto __pyx_L89_unpacking_failed;
__Pyx_GOTREF(__pyx_t_17);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_19(__pyx_t_18), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_19 = NULL;
__Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
goto __pyx_L90_unpacking_done;
__pyx_L89_unpacking_failed:;
__Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
__pyx_t_19 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L90_unpacking_done:;
}
__Pyx_XDECREF_SET(__pyx_v_src_type, __pyx_t_16);
__pyx_t_16 = 0;
__Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_17);
__pyx_t_17 = 0;
__pyx_t_2 = (__pyx_v_dst_type != Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_1 = PyObject_RichCompare(__pyx_v_src_type, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_3) {
__pyx_v_match_found = 1;
goto __pyx_L92;
}
/*else*/ {
__pyx_v_match_found = 0;
goto __pyx_L88_break;
}
__pyx_L92:;
}
}
__pyx_L88_break:;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_3 = (__pyx_v_match_found != 0);
if (__pyx_t_3) {
__pyx_t_20 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_t_3 = (__pyx_v_candidates != Py_None) && (PyList_GET_SIZE(__pyx_v_candidates) != 0);
__pyx_t_2 = ((!__pyx_t_3) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_12 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = ((__pyx_t_12 > 1) != 0);
if (__pyx_t_2) {
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_Raise(__pyx_t_8, 0, 0, 0);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
/*else*/ {
__Pyx_XDECREF(__pyx_r);
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_candidates, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_9 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), __pyx_t_8); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__pyx_r = __pyx_t_9;
__pyx_t_9 = 0;
goto __pyx_L0;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_16);
__Pyx_XDECREF(__pyx_t_17);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_AddTraceback("partition_comparison.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_dest_sig);
__Pyx_XDECREF(__pyx_v_ndarray);
__Pyx_XDECREF(__pyx_v_numpy);
__Pyx_XDECREF(__pyx_v_arg);
__Pyx_XDECREF(__pyx_v_dtype);
__Pyx_XDECREF(__pyx_v_arg_base);
__Pyx_XDECREF(__pyx_v_candidates);
__Pyx_XDECREF(__pyx_v_sig);
__Pyx_XDECREF(__pyx_v_src_type);
__Pyx_XDECREF(__pyx_v_dst_type);
__Pyx_XDECREF(__pyx_v_kwargs);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_0__pyx_pw_20partition_comparison_23variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_0__pyx_mdef_20partition_comparison_23variation_of_information = {"__pyx_fuse_0variation_of_information", (PyCFunction)__pyx_fuse_0__pyx_pw_20partition_comparison_23variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_0__pyx_pw_20partition_comparison_23variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_22variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_22variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_0variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int8_t *) ( /* dim=0 */ ((char *) (((int8_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_1__pyx_pw_20partition_comparison_25variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_1__pyx_mdef_20partition_comparison_25variation_of_information = {"__pyx_fuse_1variation_of_information", (PyCFunction)__pyx_fuse_1__pyx_pw_20partition_comparison_25variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_1__pyx_pw_20partition_comparison_25variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_24variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_24variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_1variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int16_t *) ( /* dim=0 */ ((char *) (((int16_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_2__pyx_pw_20partition_comparison_27variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_2__pyx_mdef_20partition_comparison_27variation_of_information = {"__pyx_fuse_2variation_of_information", (PyCFunction)__pyx_fuse_2__pyx_pw_20partition_comparison_27variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_2__pyx_pw_20partition_comparison_27variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_26variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_26variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_2variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int32_t *) ( /* dim=0 */ ((char *) (((int32_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_3__pyx_pw_20partition_comparison_29variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_3__pyx_mdef_20partition_comparison_29variation_of_information = {"__pyx_fuse_3variation_of_information", (PyCFunction)__pyx_fuse_3__pyx_pw_20partition_comparison_29variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_3__pyx_pw_20partition_comparison_29variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_28variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_28variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_3variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_int64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_int64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((int64_t *) ( /* dim=0 */ ((char *) (((int64_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_4__pyx_pw_20partition_comparison_31variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_4__pyx_mdef_20partition_comparison_31variation_of_information = {"__pyx_fuse_4variation_of_information", (PyCFunction)__pyx_fuse_4__pyx_pw_20partition_comparison_31variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_4__pyx_pw_20partition_comparison_31variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_30variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_30variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_4variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint8_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint8_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint8_t *) ( /* dim=0 */ ((char *) (((uint8_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_5__pyx_pw_20partition_comparison_33variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_5__pyx_mdef_20partition_comparison_33variation_of_information = {"__pyx_fuse_5variation_of_information", (PyCFunction)__pyx_fuse_5__pyx_pw_20partition_comparison_33variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_5__pyx_pw_20partition_comparison_33variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_32variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_32variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_5variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint16_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint16_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint16_t *) ( /* dim=0 */ ((char *) (((uint16_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_6__pyx_pw_20partition_comparison_35variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_6__pyx_mdef_20partition_comparison_35variation_of_information = {"__pyx_fuse_6variation_of_information", (PyCFunction)__pyx_fuse_6__pyx_pw_20partition_comparison_35variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_6__pyx_pw_20partition_comparison_35variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_34variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_34variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_6variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint32_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint32_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint32_t *) ( /* dim=0 */ ((char *) (((uint32_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_fuse_7__pyx_pw_20partition_comparison_37variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_7__pyx_mdef_20partition_comparison_37variation_of_information = {"__pyx_fuse_7variation_of_information", (PyCFunction)__pyx_fuse_7__pyx_pw_20partition_comparison_37variation_of_information, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_fuse_7__pyx_pw_20partition_comparison_37variation_of_information(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_x = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_y = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("variation_of_information (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "variation_of_information") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_x = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(values[0]); if (unlikely(!__pyx_v_x.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_y = __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(values[1]); if (unlikely(!__pyx_v_y.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("variation_of_information", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_20partition_comparison_36variation_of_information(__pyx_self, __pyx_v_x, __pyx_v_y);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_20partition_comparison_36variation_of_information(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_x, __Pyx_memviewslice __pyx_v_y) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_7variation_of_information", 0);
/* "partition_comparison.pyx":25
*
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size # <<<<<<<<<<<<<<
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_y, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (unlikely(!__pyx_t_4)) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "partition_comparison.pyx":26
* def variation_of_information(Label[::1] x, Label[::1] y):
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_5 = 0;
__pyx_t_6 = -1;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_5 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = 0;
__pyx_t_6 = -1;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_x.shape[0];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_6 = 0;
} else if (unlikely(__pyx_t_7 >= __pyx_v_x.shape[0])) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_6);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_x, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn_uint64_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn_uint64_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = -1;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_v_y.shape[0];
if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 0;
} else if (unlikely(__pyx_t_8 >= __pyx_v_y.shape[0])) __pyx_t_9 = 0;
if (unlikely(__pyx_t_9 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_9);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = PyFloat_FromDouble(andres::variationOfInformation((&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_x.data) + __pyx_t_5)) )))), ((&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_x.data) + __pyx_t_7)) )))) + ((int)__pyx_t_6)), (&(*((uint64_t *) ( /* dim=0 */ ((char *) (((uint64_t *) __pyx_v_y.data) + __pyx_t_8)) )))), 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("partition_comparison.variation_of_information", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_x, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_y, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":118
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* Python wrapper */
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_shape = 0;
Py_ssize_t __pyx_v_itemsize;
PyObject *__pyx_v_format = 0;
PyObject *__pyx_v_mode = 0;
int __pyx_v_allocate_buffer;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
PyObject* values[5] = {0,0,0,0,0};
values[3] = ((PyObject *)__pyx_n_s_c);
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 3:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode);
if (value) { values[3] = value; kw_args--; }
}
case 4:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer);
if (value) { values[4] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_shape = ((PyObject*)values[0]);
__pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_format = values[2];
__pyx_v_mode = values[3];
if (values[4]) {
__pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else {
/* "View.MemoryView":119
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
* mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<<
*
* cdef int idx
*/
__pyx_v_allocate_buffer = ((int)1);
}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);
/* "View.MemoryView":118
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
int __pyx_v_idx;
Py_ssize_t __pyx_v_i;
Py_ssize_t __pyx_v_dim;
PyObject **__pyx_v_p;
char __pyx_v_order;
int __pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
char *__pyx_t_6;
int __pyx_t_7;
Py_ssize_t __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
PyObject *__pyx_t_10 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
__Pyx_INCREF(__pyx_v_format);
/* "View.MemoryView":125
* cdef PyObject **p
*
* self.ndim = <int> len(shape) # <<<<<<<<<<<<<<
* self.itemsize = itemsize
*
*/
if (unlikely(__pyx_v_shape == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->ndim = ((int)__pyx_t_1);
/* "View.MemoryView":126
*
* self.ndim = <int> len(shape)
* self.itemsize = itemsize # <<<<<<<<<<<<<<
*
* if not self.ndim:
*/
__pyx_v_self->itemsize = __pyx_v_itemsize;
/* "View.MemoryView":128
* self.itemsize = itemsize
*
* if not self.ndim: # <<<<<<<<<<<<<<
* raise ValueError("Empty shape tuple for cython.array")
*
*/
__pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":129
*
* if not self.ndim:
* raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
*
* if itemsize <= 0:
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":128
* self.itemsize = itemsize
*
* if not self.ndim: # <<<<<<<<<<<<<<
* raise ValueError("Empty shape tuple for cython.array")
*
*/
}
/* "View.MemoryView":131
* raise ValueError("Empty shape tuple for cython.array")
*
* if itemsize <= 0: # <<<<<<<<<<<<<<
* raise ValueError("itemsize <= 0 for cython.array")
*
*/
__pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":132
*
* if itemsize <= 0:
* raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
*
* if not isinstance(format, bytes):
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":131
* raise ValueError("Empty shape tuple for cython.array")
*
* if itemsize <= 0: # <<<<<<<<<<<<<<
* raise ValueError("itemsize <= 0 for cython.array")
*
*/
}
/* "View.MemoryView":134
* raise ValueError("itemsize <= 0 for cython.array")
*
* if not isinstance(format, bytes): # <<<<<<<<<<<<<<
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
*/
__pyx_t_2 = PyBytes_Check(__pyx_v_format);
__pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":135
*
* if not isinstance(format, bytes):
* format = format.encode('ASCII') # <<<<<<<<<<<<<<
* self._format = format # keep a reference to the byte string
* self.format = self._format
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":134
* raise ValueError("itemsize <= 0 for cython.array")
*
* if not isinstance(format, bytes): # <<<<<<<<<<<<<<
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
*/
}
/* "View.MemoryView":136
* if not isinstance(format, bytes):
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<<
* self.format = self._format
*
*/
if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_5 = __pyx_v_format;
__Pyx_INCREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__Pyx_GOTREF(__pyx_v_self->_format);
__Pyx_DECREF(__pyx_v_self->_format);
__pyx_v_self->_format = ((PyObject*)__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":137
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
* self.format = self._format # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->format = __pyx_t_6;
/* "View.MemoryView":140
*
*
* self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<<
* self._strides = self._shape + self.ndim
*
*/
__pyx_v_self->_shape = ((Py_ssize_t *)PyMem_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
/* "View.MemoryView":141
*
* self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
* self._strides = self._shape + self.ndim # <<<<<<<<<<<<<<
*
* if not self._shape:
*/
__pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
/* "View.MemoryView":143
* self._strides = self._shape + self.ndim
*
* if not self._shape: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate shape and strides.")
*
*/
__pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":144
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":143
* self._strides = self._shape + self.ndim
*
* if not self._shape: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate shape and strides.")
*
*/
}
/* "View.MemoryView":147
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
__pyx_t_7 = 0;
__pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
for (;;) {
if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
#endif
__pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_dim = __pyx_t_8;
__pyx_v_idx = __pyx_t_7;
__pyx_t_7 = (__pyx_t_7 + 1);
/* "View.MemoryView":148
*
* for idx, dim in enumerate(shape):
* if dim <= 0: # <<<<<<<<<<<<<<
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim
*/
__pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":149
* for idx, dim in enumerate(shape):
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<<
* self._shape[idx] = dim
*
*/
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_10);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_9);
PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
__pyx_t_3 = 0;
__pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_10);
__Pyx_GIVEREF(__pyx_t_9);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
__pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__Pyx_Raise(__pyx_t_9, 0, 0, 0);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":148
*
* for idx, dim in enumerate(shape):
* if dim <= 0: # <<<<<<<<<<<<<<
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim
*/
}
/* "View.MemoryView":150
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim # <<<<<<<<<<<<<<
*
* cdef char order
*/
(__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
/* "View.MemoryView":147
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
/* "View.MemoryView":153
*
* cdef char order
* if mode == 'fortran': # <<<<<<<<<<<<<<
* order = b'F'
* self.mode = u'fortran'
*/
__pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_4) {
/* "View.MemoryView":154
* cdef char order
* if mode == 'fortran':
* order = b'F' # <<<<<<<<<<<<<<
* self.mode = u'fortran'
* elif mode == 'c':
*/
__pyx_v_order = 'F';
/* "View.MemoryView":155
* if mode == 'fortran':
* order = b'F'
* self.mode = u'fortran' # <<<<<<<<<<<<<<
* elif mode == 'c':
* order = b'C'
*/
__Pyx_INCREF(__pyx_n_u_fortran);
__Pyx_GIVEREF(__pyx_n_u_fortran);
__Pyx_GOTREF(__pyx_v_self->mode);
__Pyx_DECREF(__pyx_v_self->mode);
__pyx_v_self->mode = __pyx_n_u_fortran;
/* "View.MemoryView":153
*
* cdef char order
* if mode == 'fortran': # <<<<<<<<<<<<<<
* order = b'F'
* self.mode = u'fortran'
*/
goto __pyx_L10;
}
/* "View.MemoryView":156
* order = b'F'
* self.mode = u'fortran'
* elif mode == 'c': # <<<<<<<<<<<<<<
* order = b'C'
* self.mode = u'c'
*/
__pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_4) {
/* "View.MemoryView":157
* self.mode = u'fortran'
* elif mode == 'c':
* order = b'C' # <<<<<<<<<<<<<<
* self.mode = u'c'
* else:
*/
__pyx_v_order = 'C';
/* "View.MemoryView":158
* elif mode == 'c':
* order = b'C'
* self.mode = u'c' # <<<<<<<<<<<<<<
* else:
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
*/
__Pyx_INCREF(__pyx_n_u_c);
__Pyx_GIVEREF(__pyx_n_u_c);
__Pyx_GOTREF(__pyx_v_self->mode);
__Pyx_DECREF(__pyx_v_self->mode);
__pyx_v_self->mode = __pyx_n_u_c;
/* "View.MemoryView":156
* order = b'F'
* self.mode = u'fortran'
* elif mode == 'c': # <<<<<<<<<<<<<<
* order = b'C'
* self.mode = u'c'
*/
goto __pyx_L10;
}
/* "View.MemoryView":160
* self.mode = u'c'
* else:
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<<
*
* self.len = fill_contig_strides_array(self._shape, self._strides,
*/
/*else*/ {
__pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5);
__pyx_t_5 = 0;
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L10:;
/* "View.MemoryView":162
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
*
* self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<<
* itemsize, self.ndim, order)
*
*/
__pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);
/* "View.MemoryView":165
* itemsize, self.ndim, order)
*
* self.free_data = allocate_buffer # <<<<<<<<<<<<<<
* self.dtype_is_object = format == b'O'
* if allocate_buffer:
*/
__pyx_v_self->free_data = __pyx_v_allocate_buffer;
/* "View.MemoryView":166
*
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<<
* if allocate_buffer:
*
*/
__pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_self->dtype_is_object = __pyx_t_4;
/* "View.MemoryView":167
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O'
* if allocate_buffer: # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_4 = (__pyx_v_allocate_buffer != 0);
if (__pyx_t_4) {
/* "View.MemoryView":170
*
*
* self.data = <char *>malloc(self.len) # <<<<<<<<<<<<<<
* if not self.data:
* raise MemoryError("unable to allocate array data.")
*/
__pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
/* "View.MemoryView":171
*
* self.data = <char *>malloc(self.len)
* if not self.data: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate array data.")
*
*/
__pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":172
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":171
*
* self.data = <char *>malloc(self.len)
* if not self.data: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate array data.")
*
*/
}
/* "View.MemoryView":174
* raise MemoryError("unable to allocate array data.")
*
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
*/
__pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_4) {
/* "View.MemoryView":175
*
* if self.dtype_is_object:
* p = <PyObject **> self.data # <<<<<<<<<<<<<<
* for i in range(self.len / itemsize):
* p[i] = Py_None
*/
__pyx_v_p = ((PyObject **)__pyx_v_self->data);
/* "View.MemoryView":176
* if self.dtype_is_object:
* p = <PyObject **> self.data
* for i in range(self.len / itemsize): # <<<<<<<<<<<<<<
* p[i] = Py_None
* Py_INCREF(Py_None)
*/
if (unlikely(__pyx_v_itemsize == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
__pyx_v_i = __pyx_t_8;
/* "View.MemoryView":177
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
* p[i] = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
(__pyx_v_p[__pyx_v_i]) = Py_None;
/* "View.MemoryView":178
* for i in range(self.len / itemsize):
* p[i] = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
Py_INCREF(Py_None);
}
/* "View.MemoryView":174
* raise MemoryError("unable to allocate array data.")
*
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
*/
}
/* "View.MemoryView":167
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O'
* if allocate_buffer: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":118
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_format);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":181
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* cdef int bufmode = -1
* if self.mode == u"c":
*/
/* Python wrapper */
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_v_bufmode;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
char *__pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t *__pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getbuffer__", 0);
if (__pyx_v_info != NULL) {
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
}
/* "View.MemoryView":182
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1 # <<<<<<<<<<<<<<
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
*/
__pyx_v_bufmode = -1;
/* "View.MemoryView":183
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1
* if self.mode == u"c": # <<<<<<<<<<<<<<
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
*/
__pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":184
* cdef int bufmode = -1
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
*/
__pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
/* "View.MemoryView":183
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1
* if self.mode == u"c": # <<<<<<<<<<<<<<
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
*/
goto __pyx_L3;
}
/* "View.MemoryView":185
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran": # <<<<<<<<<<<<<<
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
*/
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":186
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.")
*/
__pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
/* "View.MemoryView":185
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran": # <<<<<<<<<<<<<<
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
*/
}
__pyx_L3:;
/* "View.MemoryView":187
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode): # <<<<<<<<<<<<<<
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
*/
__pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":188
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
* info.buf = self.data
* info.len = self.len
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":187
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode): # <<<<<<<<<<<<<<
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
*/
}
/* "View.MemoryView":189
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data # <<<<<<<<<<<<<<
* info.len = self.len
* info.ndim = self.ndim
*/
__pyx_t_4 = __pyx_v_self->data;
__pyx_v_info->buf = __pyx_t_4;
/* "View.MemoryView":190
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
* info.len = self.len # <<<<<<<<<<<<<<
* info.ndim = self.ndim
* info.shape = self._shape
*/
__pyx_t_5 = __pyx_v_self->len;
__pyx_v_info->len = __pyx_t_5;
/* "View.MemoryView":191
* info.buf = self.data
* info.len = self.len
* info.ndim = self.ndim # <<<<<<<<<<<<<<
* info.shape = self._shape
* info.strides = self._strides
*/
__pyx_t_6 = __pyx_v_self->ndim;
__pyx_v_info->ndim = __pyx_t_6;
/* "View.MemoryView":192
* info.len = self.len
* info.ndim = self.ndim
* info.shape = self._shape # <<<<<<<<<<<<<<
* info.strides = self._strides
* info.suboffsets = NULL
*/
__pyx_t_7 = __pyx_v_self->_shape;
__pyx_v_info->shape = __pyx_t_7;
/* "View.MemoryView":193
* info.ndim = self.ndim
* info.shape = self._shape
* info.strides = self._strides # <<<<<<<<<<<<<<
* info.suboffsets = NULL
* info.itemsize = self.itemsize
*/
__pyx_t_7 = __pyx_v_self->_strides;
__pyx_v_info->strides = __pyx_t_7;
/* "View.MemoryView":194
* info.shape = self._shape
* info.strides = self._strides
* info.suboffsets = NULL # <<<<<<<<<<<<<<
* info.itemsize = self.itemsize
* info.readonly = 0
*/
__pyx_v_info->suboffsets = NULL;
/* "View.MemoryView":195
* info.strides = self._strides
* info.suboffsets = NULL
* info.itemsize = self.itemsize # <<<<<<<<<<<<<<
* info.readonly = 0
*
*/
__pyx_t_5 = __pyx_v_self->itemsize;
__pyx_v_info->itemsize = __pyx_t_5;
/* "View.MemoryView":196
* info.suboffsets = NULL
* info.itemsize = self.itemsize
* info.readonly = 0 # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
__pyx_v_info->readonly = 0;
/* "View.MemoryView":198
* info.readonly = 0
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.format
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":199
*
* if flags & PyBUF_FORMAT:
* info.format = self.format # <<<<<<<<<<<<<<
* else:
* info.format = NULL
*/
__pyx_t_4 = __pyx_v_self->format;
__pyx_v_info->format = __pyx_t_4;
/* "View.MemoryView":198
* info.readonly = 0
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.format
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":201
* info.format = self.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.obj = self
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L5:;
/* "View.MemoryView":203
* info.format = NULL
*
* info.obj = self # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = ((PyObject *)__pyx_v_self);
/* "View.MemoryView":181
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* cdef int bufmode = -1
* if self.mode == u"c":
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(Py_None);
__Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
}
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":207
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*
* def __dealloc__(array self): # <<<<<<<<<<<<<<
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
*/
/* Python wrapper */
static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":208
*
* def __dealloc__(array self):
* if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
* self.callback_free_data(self.data)
* elif self.free_data:
*/
__pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":209
* def __dealloc__(array self):
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data) # <<<<<<<<<<<<<<
* elif self.free_data:
* if self.dtype_is_object:
*/
__pyx_v_self->callback_free_data(__pyx_v_self->data);
/* "View.MemoryView":208
*
* def __dealloc__(array self):
* if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
* self.callback_free_data(self.data)
* elif self.free_data:
*/
goto __pyx_L3;
}
/* "View.MemoryView":210
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
* elif self.free_data: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape,
*/
__pyx_t_1 = (__pyx_v_self->free_data != 0);
if (__pyx_t_1) {
/* "View.MemoryView":211
* self.callback_free_data(self.data)
* elif self.free_data:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
*/
__pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_1) {
/* "View.MemoryView":212
* elif self.free_data:
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<<
* self._strides, self.ndim, False)
* free(self.data)
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
/* "View.MemoryView":211
* self.callback_free_data(self.data)
* elif self.free_data:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
*/
}
/* "View.MemoryView":214
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
* free(self.data) # <<<<<<<<<<<<<<
* PyMem_Free(self._shape)
*
*/
free(__pyx_v_self->data);
/* "View.MemoryView":210
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
* elif self.free_data: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape,
*/
}
__pyx_L3:;
/* "View.MemoryView":215
* self._strides, self.ndim, False)
* free(self.data)
* PyMem_Free(self._shape) # <<<<<<<<<<<<<<
*
* property memview:
*/
PyMem_Free(__pyx_v_self->_shape);
/* "View.MemoryView":207
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*
* def __dealloc__(array self): # <<<<<<<<<<<<<<
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":219
* property memview:
* @cname('get_memview')
* def __get__(self): # <<<<<<<<<<<<<<
*
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
*/
/* Python wrapper */
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":221
* def __get__(self):
*
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<<
* return memoryview(self, flags, self.dtype_is_object)
*
*/
__pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
/* "View.MemoryView":222
*
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":219
* property memview:
* @cname('get_memview')
* def __get__(self): # <<<<<<<<<<<<<<
*
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":225
*
*
* def __getattr__(self, attr): # <<<<<<<<<<<<<<
* return getattr(self.memview, attr)
*
*/
/* Python wrapper */
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getattr__", 0);
/* "View.MemoryView":226
*
* def __getattr__(self, attr):
* return getattr(self.memview, attr) # <<<<<<<<<<<<<<
*
* def __getitem__(self, item):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":225
*
*
* def __getattr__(self, attr): # <<<<<<<<<<<<<<
* return getattr(self.memview, attr)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":228
* return getattr(self.memview, attr)
*
* def __getitem__(self, item): # <<<<<<<<<<<<<<
* return self.memview[item]
*
*/
/* Python wrapper */
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":229
*
* def __getitem__(self, item):
* return self.memview[item] # <<<<<<<<<<<<<<
*
* def __setitem__(self, item, value):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":228
* return getattr(self.memview, attr)
*
* def __getitem__(self, item): # <<<<<<<<<<<<<<
* return self.memview[item]
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":231
* return self.memview[item]
*
* def __setitem__(self, item, value): # <<<<<<<<<<<<<<
* self.memview[item] = value
*
*/
/* Python wrapper */
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
/* "View.MemoryView":232
*
* def __setitem__(self, item, value):
* self.memview[item] = value # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":231
* return self.memview[item]
*
* def __setitem__(self, item, value): # <<<<<<<<<<<<<<
* self.memview[item] = value
*
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":236
*
* @cname("__pyx_array_new")
* cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
* char *mode, char *buf):
* cdef array result
*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
struct __pyx_array_obj *__pyx_v_result = 0;
struct __pyx_array_obj *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("array_cwrapper", 0);
/* "View.MemoryView":240
* cdef array result
*
* if buf == NULL: # <<<<<<<<<<<<<<
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
*/
__pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":241
*
* if buf == NULL:
* result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<<
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'),
*/
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_INCREF(__pyx_v_shape);
__Pyx_GIVEREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
__pyx_t_2 = 0;
__pyx_t_3 = 0;
__pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":240
* cdef array result
*
* if buf == NULL: # <<<<<<<<<<<<<<
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":243
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
* allocate_buffer=False)
* result.data = buf
*/
/*else*/ {
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_shape);
__Pyx_GIVEREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
__pyx_t_4 = 0;
__pyx_t_5 = 0;
__pyx_t_3 = 0;
/* "View.MemoryView":244
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'),
* allocate_buffer=False) # <<<<<<<<<<<<<<
* result.data = buf
*
*/
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":243
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
* allocate_buffer=False)
* result.data = buf
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":245
* result = array(shape, itemsize, format, mode.decode('ASCII'),
* allocate_buffer=False)
* result.data = buf # <<<<<<<<<<<<<<
*
* return result
*/
__pyx_v_result->data = __pyx_v_buf;
}
__pyx_L3:;
/* "View.MemoryView":247
* result.data = buf
*
* return result # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = __pyx_v_result;
goto __pyx_L0;
/* "View.MemoryView":236
*
* @cname("__pyx_array_new")
* cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
* char *mode, char *buf):
* cdef array result
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":273
* cdef class Enum(object):
* cdef object name
* def __init__(self, name): # <<<<<<<<<<<<<<
* self.name = name
* def __repr__(self):
*/
/* Python wrapper */
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_name = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
}
__pyx_v_name = values[0];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__", 0);
/* "View.MemoryView":274
* cdef object name
* def __init__(self, name):
* self.name = name # <<<<<<<<<<<<<<
* def __repr__(self):
* return self.name
*/
__Pyx_INCREF(__pyx_v_name);
__Pyx_GIVEREF(__pyx_v_name);
__Pyx_GOTREF(__pyx_v_self->name);
__Pyx_DECREF(__pyx_v_self->name);
__pyx_v_self->name = __pyx_v_name;
/* "View.MemoryView":273
* cdef class Enum(object):
* cdef object name
* def __init__(self, name): # <<<<<<<<<<<<<<
* self.name = name
* def __repr__(self):
*/
/* function exit code */
__pyx_r = 0;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":275
* def __init__(self, name):
* self.name = name
* def __repr__(self): # <<<<<<<<<<<<<<
* return self.name
*
*/
/* Python wrapper */
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
__pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__", 0);
/* "View.MemoryView":276
* self.name = name
* def __repr__(self):
* return self.name # <<<<<<<<<<<<<<
*
* cdef generic = Enum("<strided and direct or indirect>")
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->name);
__pyx_r = __pyx_v_self->name;
goto __pyx_L0;
/* "View.MemoryView":275
* def __init__(self, name):
* self.name = name
* def __repr__(self): # <<<<<<<<<<<<<<
* return self.name
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":290
*
* @cname('__pyx_align_pointer')
* cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
*/
static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
Py_intptr_t __pyx_v_aligned_p;
size_t __pyx_v_offset;
void *__pyx_r;
int __pyx_t_1;
/* "View.MemoryView":292
* cdef void *align_pointer(void *memory, size_t alignment) nogil:
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory # <<<<<<<<<<<<<<
* cdef size_t offset
*
*/
__pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
/* "View.MemoryView":296
*
* with cython.cdivision(True):
* offset = aligned_p % alignment # <<<<<<<<<<<<<<
*
* if offset > 0:
*/
__pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
/* "View.MemoryView":298
* offset = aligned_p % alignment
*
* if offset > 0: # <<<<<<<<<<<<<<
* aligned_p += alignment - offset
*
*/
__pyx_t_1 = ((__pyx_v_offset > 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":299
*
* if offset > 0:
* aligned_p += alignment - offset # <<<<<<<<<<<<<<
*
* return <void *> aligned_p
*/
__pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
/* "View.MemoryView":298
* offset = aligned_p % alignment
*
* if offset > 0: # <<<<<<<<<<<<<<
* aligned_p += alignment - offset
*
*/
}
/* "View.MemoryView":301
* aligned_p += alignment - offset
*
* return <void *> aligned_p # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview')
*/
__pyx_r = ((void *)__pyx_v_aligned_p);
goto __pyx_L0;
/* "View.MemoryView":290
*
* @cname('__pyx_align_pointer')
* cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":319
* cdef __Pyx_TypeInfo *typeinfo
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
* self.obj = obj
* self.flags = flags
*/
/* Python wrapper */
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_obj = 0;
int __pyx_v_flags;
int __pyx_v_dtype_is_object;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object);
if (value) { values[2] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_obj = values[0];
__pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
if (values[2]) {
__pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else {
__pyx_v_dtype_is_object = ((int)0);
}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
/* "View.MemoryView":320
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
* self.obj = obj # <<<<<<<<<<<<<<
* self.flags = flags
* if type(self) is memoryview or obj is not None:
*/
__Pyx_INCREF(__pyx_v_obj);
__Pyx_GIVEREF(__pyx_v_obj);
__Pyx_GOTREF(__pyx_v_self->obj);
__Pyx_DECREF(__pyx_v_self->obj);
__pyx_v_self->obj = __pyx_v_obj;
/* "View.MemoryView":321
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
* self.obj = obj
* self.flags = flags # <<<<<<<<<<<<<<
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
*/
__pyx_v_self->flags = __pyx_v_flags;
/* "View.MemoryView":322
* self.obj = obj
* self.flags = flags
* if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
*/
__pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
__pyx_t_3 = (__pyx_t_2 != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_1 = __pyx_t_3;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_3 = (__pyx_v_obj != Py_None);
__pyx_t_2 = (__pyx_t_3 != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
/* "View.MemoryView":323
* self.flags = flags
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<<
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None
*/
__pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":324
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL: # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None)
*/
__pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":325
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
/* "View.MemoryView":326
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* self.lock = PyThread_allocate_lock()
*/
Py_INCREF(Py_None);
/* "View.MemoryView":324
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL: # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None)
*/
}
/* "View.MemoryView":322
* self.obj = obj
* self.flags = flags
* if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
*/
}
/* "View.MemoryView":328
* Py_INCREF(Py_None)
*
* self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<<
* if self.lock == NULL:
* raise MemoryError
*/
__pyx_v_self->lock = PyThread_allocate_lock();
/* "View.MemoryView":329
*
* self.lock = PyThread_allocate_lock()
* if self.lock == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
__pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":330
* self.lock = PyThread_allocate_lock()
* if self.lock == NULL:
* raise MemoryError # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
PyErr_NoMemory(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":329
*
* self.lock = PyThread_allocate_lock()
* if self.lock == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
}
/* "View.MemoryView":332
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = self.view.format == b'O'
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":333
*
* if flags & PyBUF_FORMAT:
* self.dtype_is_object = self.view.format == b'O' # <<<<<<<<<<<<<<
* else:
* self.dtype_is_object = dtype_is_object
*/
__pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_v_self->dtype_is_object = __pyx_t_1;
/* "View.MemoryView":332
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = self.view.format == b'O'
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":335
* self.dtype_is_object = self.view.format == b'O'
* else:
* self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<<
*
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
*/
/*else*/ {
__pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
}
__pyx_L8:;
/* "View.MemoryView":337
* self.dtype_is_object = dtype_is_object
*
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<<
* <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
* self.typeinfo = NULL
*/
__pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
/* "View.MemoryView":339
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
* <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
* self.typeinfo = NULL # <<<<<<<<<<<<<<
*
* def __dealloc__(memoryview self):
*/
__pyx_v_self->typeinfo = NULL;
/* "View.MemoryView":319
* cdef __Pyx_TypeInfo *typeinfo
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
* self.obj = obj
* self.flags = flags
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":341
* self.typeinfo = NULL
*
* def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
*/
/* Python wrapper */
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":342
*
* def __dealloc__(memoryview self):
* if self.obj is not None: # <<<<<<<<<<<<<<
* __Pyx_ReleaseBuffer(&self.view)
*
*/
__pyx_t_1 = (__pyx_v_self->obj != Py_None);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":343
* def __dealloc__(memoryview self):
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<<
*
* if self.lock != NULL:
*/
__Pyx_ReleaseBuffer((&__pyx_v_self->view));
/* "View.MemoryView":342
*
* def __dealloc__(memoryview self):
* if self.obj is not None: # <<<<<<<<<<<<<<
* __Pyx_ReleaseBuffer(&self.view)
*
*/
}
/* "View.MemoryView":345
* __Pyx_ReleaseBuffer(&self.view)
*
* if self.lock != NULL: # <<<<<<<<<<<<<<
* PyThread_free_lock(self.lock)
*
*/
__pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":346
*
* if self.lock != NULL:
* PyThread_free_lock(self.lock) # <<<<<<<<<<<<<<
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL:
*/
PyThread_free_lock(__pyx_v_self->lock);
/* "View.MemoryView":345
* __Pyx_ReleaseBuffer(&self.view)
*
* if self.lock != NULL: # <<<<<<<<<<<<<<
* PyThread_free_lock(self.lock)
*
*/
}
/* "View.MemoryView":341
* self.typeinfo = NULL
*
* def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":348
* PyThread_free_lock(self.lock)
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf
*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
Py_ssize_t __pyx_v_dim;
char *__pyx_v_itemp;
PyObject *__pyx_v_idx = NULL;
char *__pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
Py_ssize_t __pyx_t_3;
PyObject *(*__pyx_t_4)(PyObject *);
PyObject *__pyx_t_5 = NULL;
Py_ssize_t __pyx_t_6;
char *__pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("get_item_pointer", 0);
/* "View.MemoryView":350
* cdef char *get_item_pointer(memoryview self, object index) except NULL:
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf # <<<<<<<<<<<<<<
*
* for dim, idx in enumerate(index):
*/
__pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
/* "View.MemoryView":352
* cdef char *itemp = <char *> self.view.buf
*
* for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
*/
__pyx_t_1 = 0;
if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
__pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
__pyx_t_4 = NULL;
} else {
__pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
for (;;) {
if (likely(!__pyx_t_4)) {
if (likely(PyList_CheckExact(__pyx_t_2))) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
#endif
} else {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
#endif
}
} else {
__pyx_t_5 = __pyx_t_4(__pyx_t_2);
if (unlikely(!__pyx_t_5)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_5);
}
__Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
__pyx_t_5 = 0;
__pyx_v_dim = __pyx_t_1;
__pyx_t_1 = (__pyx_t_1 + 1);
/* "View.MemoryView":353
*
* for dim, idx in enumerate(index):
* itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<<
*
* return itemp
*/
__pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_itemp = __pyx_t_7;
/* "View.MemoryView":352
* cdef char *itemp = <char *> self.view.buf
*
* for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
*/
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":355
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
* return itemp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_itemp;
goto __pyx_L0;
/* "View.MemoryView":348
* PyThread_free_lock(self.lock)
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_idx);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":358
*
*
* def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
* if index is Ellipsis:
* return self
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
PyObject *__pyx_v_have_slices = NULL;
PyObject *__pyx_v_indices = NULL;
char *__pyx_v_itemp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
char *__pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":359
*
* def __getitem__(memoryview self, object index):
* if index is Ellipsis: # <<<<<<<<<<<<<<
* return self
*
*/
__pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":360
* def __getitem__(memoryview self, object index):
* if index is Ellipsis:
* return self # <<<<<<<<<<<<<<
*
* have_slices, indices = _unellipsify(index, self.view.ndim)
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__pyx_r = ((PyObject *)__pyx_v_self);
goto __pyx_L0;
/* "View.MemoryView":359
*
* def __getitem__(memoryview self, object index):
* if index is Ellipsis: # <<<<<<<<<<<<<<
* return self
*
*/
}
/* "View.MemoryView":362
* return self
*
* have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
*
* cdef char *itemp
*/
__pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (likely(__pyx_t_3 != Py_None)) {
PyObject* sequence = __pyx_t_3;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
#else
__pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
#endif
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_have_slices = __pyx_t_4;
__pyx_t_4 = 0;
__pyx_v_indices = __pyx_t_5;
__pyx_t_5 = 0;
/* "View.MemoryView":365
*
* cdef char *itemp
* if have_slices: # <<<<<<<<<<<<<<
* return memview_slice(self, indices)
* else:
*/
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_2) {
/* "View.MemoryView":366
* cdef char *itemp
* if have_slices:
* return memview_slice(self, indices) # <<<<<<<<<<<<<<
* else:
* itemp = self.get_item_pointer(indices)
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":365
*
* cdef char *itemp
* if have_slices: # <<<<<<<<<<<<<<
* return memview_slice(self, indices)
* else:
*/
}
/* "View.MemoryView":368
* return memview_slice(self, indices)
* else:
* itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<<
* return self.convert_item_to_object(itemp)
*
*/
/*else*/ {
__pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_itemp = __pyx_t_6;
/* "View.MemoryView":369
* else:
* itemp = self.get_item_pointer(indices)
* return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<<
*
* def __setitem__(memoryview self, object index, object value):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":358
*
*
* def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
* if index is Ellipsis:
* return self
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_have_slices);
__Pyx_XDECREF(__pyx_v_indices);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":371
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* have_slices, index = _unellipsify(index, self.view.ndim)
*
*/
/* Python wrapper */
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
PyObject *__pyx_v_have_slices = NULL;
PyObject *__pyx_v_obj = NULL;
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
__Pyx_INCREF(__pyx_v_index);
/* "View.MemoryView":372
*
* def __setitem__(memoryview self, object index, object value):
* have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
*
* if have_slices:
*/
__pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (likely(__pyx_t_1 != Py_None)) {
PyObject* sequence = __pyx_t_1;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(__pyx_t_3);
#else
__pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_have_slices = __pyx_t_2;
__pyx_t_2 = 0;
__Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":374
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_4) {
/* "View.MemoryView":375
*
* if have_slices:
* obj = self.is_slice(value) # <<<<<<<<<<<<<<
* if obj:
* self.setitem_slice_assignment(self[index], obj)
*/
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_obj = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":376
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_4) {
/* "View.MemoryView":377
* obj = self.is_slice(value)
* if obj:
* self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<<
* else:
* self.setitem_slice_assign_scalar(self[index], value)
*/
__pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":376
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
goto __pyx_L4;
}
/* "View.MemoryView":379
* self.setitem_slice_assignment(self[index], obj)
* else:
* self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<<
* else:
* self.setitem_indexed(index, value)
*/
/*else*/ {
__pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_3);
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
__pyx_L4:;
/* "View.MemoryView":374
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
goto __pyx_L3;
}
/* "View.MemoryView":381
* self.setitem_slice_assign_scalar(self[index], value)
* else:
* self.setitem_indexed(index, value) # <<<<<<<<<<<<<<
*
* cdef is_slice(self, obj):
*/
/*else*/ {
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
__pyx_L3:;
/* "View.MemoryView":371
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* have_slices, index = _unellipsify(index, self.view.ndim)
*
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_have_slices);
__Pyx_XDECREF(__pyx_v_obj);
__Pyx_XDECREF(__pyx_v_index);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":383
* self.setitem_indexed(index, value)
*
* cdef is_slice(self, obj): # <<<<<<<<<<<<<<
* if not isinstance(obj, memoryview):
* try:
*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_slice", 0);
__Pyx_INCREF(__pyx_v_obj);
/* "View.MemoryView":384
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
*/
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":385
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
{
__Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
__Pyx_XGOTREF(__pyx_t_3);
__Pyx_XGOTREF(__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_5);
/*try:*/ {
/* "View.MemoryView":386
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":387
* try:
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object) # <<<<<<<<<<<<<<
* except TypeError:
* return None
*/
__pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_7);
/* "View.MemoryView":386
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_INCREF(__pyx_v_obj);
__Pyx_GIVEREF(__pyx_v_obj);
PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
__pyx_t_6 = 0;
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
__pyx_t_7 = 0;
/* "View.MemoryView":385
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
}
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
goto __pyx_L11_try_end;
__pyx_L4_error:;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
/* "View.MemoryView":388
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
* except TypeError: # <<<<<<<<<<<<<<
* return None
*
*/
__pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
if (__pyx_t_9) {
__Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":389
* self.dtype_is_object)
* except TypeError:
* return None # <<<<<<<<<<<<<<
*
* return obj
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_None);
__pyx_r = Py_None;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
goto __pyx_L7_except_return;
}
goto __pyx_L6_except_error;
__pyx_L6_except_error:;
/* "View.MemoryView":385
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
goto __pyx_L1_error;
__pyx_L7_except_return:;
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
goto __pyx_L0;
__pyx_L11_try_end:;
}
/* "View.MemoryView":384
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
*/
}
/* "View.MemoryView":391
* return None
*
* return obj # <<<<<<<<<<<<<<
*
* cdef setitem_slice_assignment(self, dst, src):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_obj);
__pyx_r = __pyx_v_obj;
goto __pyx_L0;
/* "View.MemoryView":383
* self.setitem_indexed(index, value)
*
* cdef is_slice(self, obj): # <<<<<<<<<<<<<<
* if not isinstance(obj, memoryview):
* try:
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_obj);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":393
* return obj
*
* cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice dst_slice
* cdef __Pyx_memviewslice src_slice
*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
__Pyx_memviewslice __pyx_v_dst_slice;
__Pyx_memviewslice __pyx_v_src_slice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
/* "View.MemoryView":397
* cdef __Pyx_memviewslice src_slice
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object)
*/
if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":398
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
* get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<<
* src.ndim, dst.ndim, self.dtype_is_object)
*
*/
if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":399
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<<
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value):
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":397
* cdef __Pyx_memviewslice src_slice
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object)
*/
__pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":393
* return obj
*
* cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice dst_slice
* cdef __Pyx_memviewslice src_slice
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":401
* src.ndim, dst.ndim, self.dtype_is_object)
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
* cdef int array[128]
* cdef void *tmp = NULL
*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
int __pyx_v_array[0x80];
void *__pyx_v_tmp;
void *__pyx_v_item;
__Pyx_memviewslice *__pyx_v_dst_slice;
__Pyx_memviewslice __pyx_v_tmp_slice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_t_3;
int __pyx_t_4;
char const *__pyx_t_5;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
PyObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
/* "View.MemoryView":403
* cdef setitem_slice_assign_scalar(self, memoryview dst, value):
* cdef int array[128]
* cdef void *tmp = NULL # <<<<<<<<<<<<<<
* cdef void *item
*
*/
__pyx_v_tmp = NULL;
/* "View.MemoryView":408
* cdef __Pyx_memviewslice *dst_slice
* cdef __Pyx_memviewslice tmp_slice
* dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<<
*
* if <size_t>self.view.itemsize > sizeof(array):
*/
__pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice));
/* "View.MemoryView":410
* dst_slice = get_slice_from_memview(dst, &tmp_slice)
*
* if <size_t>self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
*/
__pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":411
*
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<<
* if tmp == NULL:
* raise MemoryError
*/
__pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
/* "View.MemoryView":412
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
* item = tmp
*/
__pyx_t_1 = ((__pyx_v_tmp == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":413
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
* raise MemoryError # <<<<<<<<<<<<<<
* item = tmp
* else:
*/
PyErr_NoMemory(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":412
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
* item = tmp
*/
}
/* "View.MemoryView":414
* if tmp == NULL:
* raise MemoryError
* item = tmp # <<<<<<<<<<<<<<
* else:
* item = <void *> array
*/
__pyx_v_item = __pyx_v_tmp;
/* "View.MemoryView":410
* dst_slice = get_slice_from_memview(dst, &tmp_slice)
*
* if <size_t>self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
*/
goto __pyx_L3;
}
/* "View.MemoryView":416
* item = tmp
* else:
* item = <void *> array # <<<<<<<<<<<<<<
*
* try:
*/
/*else*/ {
__pyx_v_item = ((void *)__pyx_v_array);
}
__pyx_L3:;
/* "View.MemoryView":418
* item = <void *> array
*
* try: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* (<PyObject **> item)[0] = <PyObject *> value
*/
/*try:*/ {
/* "View.MemoryView":419
*
* try:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* (<PyObject **> item)[0] = <PyObject *> value
* else:
*/
__pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_1) {
/* "View.MemoryView":420
* try:
* if self.dtype_is_object:
* (<PyObject **> item)[0] = <PyObject *> value # <<<<<<<<<<<<<<
* else:
* self.assign_item_from_object(<char *> item, value)
*/
(((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
/* "View.MemoryView":419
*
* try:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* (<PyObject **> item)[0] = <PyObject *> value
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":422
* (<PyObject **> item)[0] = <PyObject *> value
* else:
* self.assign_item_from_object(<char *> item, value) # <<<<<<<<<<<<<<
*
*
*/
/*else*/ {
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L8:;
/* "View.MemoryView":426
*
*
* if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
*/
__pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":427
*
* if self.view.suboffsets != NULL:
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<<
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
* item, self.dtype_is_object)
*/
__pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":426
*
*
* if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
*/
}
/* "View.MemoryView":428
* if self.view.suboffsets != NULL:
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<<
* item, self.dtype_is_object)
* finally:
*/
__pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
}
/* "View.MemoryView":431
* item, self.dtype_is_object)
* finally:
* PyMem_Free(tmp) # <<<<<<<<<<<<<<
*
* cdef setitem_indexed(self, index, value):
*/
/*finally:*/ {
/*normal exit:*/{
PyMem_Free(__pyx_v_tmp);
goto __pyx_L7;
}
/*exception exit:*/{
__pyx_L6_error:;
__pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
__Pyx_XGOTREF(__pyx_t_6);
__Pyx_XGOTREF(__pyx_t_7);
__Pyx_XGOTREF(__pyx_t_8);
__Pyx_XGOTREF(__pyx_t_9);
__Pyx_XGOTREF(__pyx_t_10);
__Pyx_XGOTREF(__pyx_t_11);
__pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
{
PyMem_Free(__pyx_v_tmp);
}
if (PY_MAJOR_VERSION >= 3) {
__Pyx_XGIVEREF(__pyx_t_9);
__Pyx_XGIVEREF(__pyx_t_10);
__Pyx_XGIVEREF(__pyx_t_11);
__Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
}
__Pyx_XGIVEREF(__pyx_t_6);
__Pyx_XGIVEREF(__pyx_t_7);
__Pyx_XGIVEREF(__pyx_t_8);
__Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
__pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
__pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
goto __pyx_L1_error;
}
__pyx_L7:;
}
/* "View.MemoryView":401
* src.ndim, dst.ndim, self.dtype_is_object)
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
* cdef int array[128]
* cdef void *tmp = NULL
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":433
* PyMem_Free(tmp)
*
* cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value)
*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
char *__pyx_v_itemp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
char *__pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_indexed", 0);
/* "View.MemoryView":434
*
* cdef setitem_indexed(self, index, value):
* cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<<
* self.assign_item_from_object(itemp, value)
*
*/
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_itemp = __pyx_t_1;
/* "View.MemoryView":435
* cdef setitem_indexed(self, index, value):
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<<
*
* cdef convert_item_to_object(self, char *itemp):
*/
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":433
* PyMem_Free(tmp)
*
* cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value)
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":437
* self.assign_item_from_object(itemp, value)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
PyObject *__pyx_v_struct = NULL;
PyObject *__pyx_v_bytesitem = 0;
PyObject *__pyx_v_result = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
Py_ssize_t __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
size_t __pyx_t_10;
int __pyx_t_11;
int __pyx_t_12;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":440
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
* import struct # <<<<<<<<<<<<<<
* cdef bytes bytesitem
*
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":443
* cdef bytes bytesitem
*
* bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<<
* try:
* result = struct.unpack(self.view.format, bytesitem)
*/
__pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":444
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
{
__Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_2);
__Pyx_XGOTREF(__pyx_t_3);
__Pyx_XGOTREF(__pyx_t_4);
/*try:*/ {
/* "View.MemoryView":445
* bytesitem = itemp[:self.view.itemsize]
* try:
* result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<<
* except struct.error:
* raise ValueError("Unable to convert item to object")
*/
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = NULL;
__pyx_t_8 = 0;
if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_7)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_7);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
__pyx_t_8 = 1;
}
}
__pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_9);
if (__pyx_t_7) {
__Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
}
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
__Pyx_INCREF(__pyx_v_bytesitem);
__Pyx_GIVEREF(__pyx_v_bytesitem);
PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
__pyx_t_6 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_result = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":444
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
}
/* "View.MemoryView":449
* raise ValueError("Unable to convert item to object")
* else:
* if len(self.view.format) == 1: # <<<<<<<<<<<<<<
* return result[0]
* return result
*/
/*else:*/ {
__pyx_t_10 = strlen(__pyx_v_self->view.format);
__pyx_t_11 = ((__pyx_t_10 == 1) != 0);
if (__pyx_t_11) {
/* "View.MemoryView":450
* else:
* if len(self.view.format) == 1:
* return result[0] # <<<<<<<<<<<<<<
* return result
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;};
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L6_except_return;
/* "View.MemoryView":449
* raise ValueError("Unable to convert item to object")
* else:
* if len(self.view.format) == 1: # <<<<<<<<<<<<<<
* return result[0]
* return result
*/
}
/* "View.MemoryView":451
* if len(self.view.format) == 1:
* return result[0]
* return result # <<<<<<<<<<<<<<
*
* cdef assign_item_from_object(self, char *itemp, object value):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_result);
__pyx_r = __pyx_v_result;
goto __pyx_L6_except_return;
}
__pyx_L3_error:;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":446
* try:
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error: # <<<<<<<<<<<<<<
* raise ValueError("Unable to convert item to object")
* else:
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_12 = PyErr_ExceptionMatches(__pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_12) {
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GOTREF(__pyx_t_9);
/* "View.MemoryView":447
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
* raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
* else:
* if len(self.view.format) == 1:
*/
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
}
goto __pyx_L5_except_error;
__pyx_L5_except_error:;
/* "View.MemoryView":444
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
__Pyx_XGIVEREF(__pyx_t_2);
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
goto __pyx_L1_error;
__pyx_L6_except_return:;
__Pyx_XGIVEREF(__pyx_t_2);
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
goto __pyx_L0;
}
/* "View.MemoryView":437
* self.assign_item_from_object(itemp, value)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_struct);
__Pyx_XDECREF(__pyx_v_bytesitem);
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":453
* return result
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
PyObject *__pyx_v_struct = NULL;
char __pyx_v_c;
PyObject *__pyx_v_bytesvalue = 0;
Py_ssize_t __pyx_v_i;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
Py_ssize_t __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
char *__pyx_t_10;
char *__pyx_t_11;
char *__pyx_t_12;
char *__pyx_t_13;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":456
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
* import struct # <<<<<<<<<<<<<<
* cdef char c
* cdef bytes bytesvalue
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":461
* cdef Py_ssize_t i
*
* if isinstance(value, tuple): # <<<<<<<<<<<<<<
* bytesvalue = struct.pack(self.view.format, *value)
* else:
*/
__pyx_t_2 = PyTuple_Check(__pyx_v_value);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
/* "View.MemoryView":462
*
* if isinstance(value, tuple):
* bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<<
* else:
* bytesvalue = struct.pack(self.view.format, value)
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":461
* cdef Py_ssize_t i
*
* if isinstance(value, tuple): # <<<<<<<<<<<<<<
* bytesvalue = struct.pack(self.view.format, *value)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":464
* bytesvalue = struct.pack(self.view.format, *value)
* else:
* bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<<
*
* for i, c in enumerate(bytesvalue):
*/
/*else*/ {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = NULL;
__pyx_t_7 = 0;
if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_6, function);
__pyx_t_7 = 1;
}
}
__pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
if (__pyx_t_5) {
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
}
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
__Pyx_INCREF(__pyx_v_value);
__Pyx_GIVEREF(__pyx_v_value);
PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
__pyx_t_1 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
}
__pyx_L3:;
/* "View.MemoryView":466
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_7 = 0;
if (unlikely(__pyx_v_bytesvalue == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_INCREF(__pyx_v_bytesvalue);
__pyx_t_9 = __pyx_v_bytesvalue;
__pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9);
__pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9));
for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
__pyx_t_10 = __pyx_t_13;
__pyx_v_c = (__pyx_t_10[0]);
/* "View.MemoryView":467
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
__pyx_v_i = __pyx_t_7;
/* "View.MemoryView":466
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_7 = (__pyx_t_7 + 1);
/* "View.MemoryView":467
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
(__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* "View.MemoryView":453
* return result
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_struct);
__Pyx_XDECREF(__pyx_v_bytesvalue);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":470
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_STRIDES:
* info.shape = self.view.shape
*/
/* Python wrapper */
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
Py_ssize_t *__pyx_t_2;
char *__pyx_t_3;
void *__pyx_t_4;
int __pyx_t_5;
Py_ssize_t __pyx_t_6;
__Pyx_RefNannySetupContext("__getbuffer__", 0);
if (__pyx_v_info != NULL) {
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
}
/* "View.MemoryView":471
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":472
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_STRIDES:
* info.shape = self.view.shape # <<<<<<<<<<<<<<
* else:
* info.shape = NULL
*/
__pyx_t_2 = __pyx_v_self->view.shape;
__pyx_v_info->shape = __pyx_t_2;
/* "View.MemoryView":471
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":474
* info.shape = self.view.shape
* else:
* info.shape = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_STRIDES:
*/
/*else*/ {
__pyx_v_info->shape = NULL;
}
__pyx_L3:;
/* "View.MemoryView":476
* info.shape = NULL
*
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.strides = self.view.strides
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":477
*
* if flags & PyBUF_STRIDES:
* info.strides = self.view.strides # <<<<<<<<<<<<<<
* else:
* info.strides = NULL
*/
__pyx_t_2 = __pyx_v_self->view.strides;
__pyx_v_info->strides = __pyx_t_2;
/* "View.MemoryView":476
* info.shape = NULL
*
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.strides = self.view.strides
* else:
*/
goto __pyx_L4;
}
/* "View.MemoryView":479
* info.strides = self.view.strides
* else:
* info.strides = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_INDIRECT:
*/
/*else*/ {
__pyx_v_info->strides = NULL;
}
__pyx_L4:;
/* "View.MemoryView":481
* info.strides = NULL
*
* if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
* info.suboffsets = self.view.suboffsets
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":482
*
* if flags & PyBUF_INDIRECT:
* info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<<
* else:
* info.suboffsets = NULL
*/
__pyx_t_2 = __pyx_v_self->view.suboffsets;
__pyx_v_info->suboffsets = __pyx_t_2;
/* "View.MemoryView":481
* info.strides = NULL
*
* if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
* info.suboffsets = self.view.suboffsets
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":484
* info.suboffsets = self.view.suboffsets
* else:
* info.suboffsets = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
/*else*/ {
__pyx_v_info->suboffsets = NULL;
}
__pyx_L5:;
/* "View.MemoryView":486
* info.suboffsets = NULL
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.view.format
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":487
*
* if flags & PyBUF_FORMAT:
* info.format = self.view.format # <<<<<<<<<<<<<<
* else:
* info.format = NULL
*/
__pyx_t_3 = __pyx_v_self->view.format;
__pyx_v_info->format = __pyx_t_3;
/* "View.MemoryView":486
* info.suboffsets = NULL
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.view.format
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":489
* info.format = self.view.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.buf = self.view.buf
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L6:;
/* "View.MemoryView":491
* info.format = NULL
*
* info.buf = self.view.buf # <<<<<<<<<<<<<<
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
*/
__pyx_t_4 = __pyx_v_self->view.buf;
__pyx_v_info->buf = __pyx_t_4;
/* "View.MemoryView":492
*
* info.buf = self.view.buf
* info.ndim = self.view.ndim # <<<<<<<<<<<<<<
* info.itemsize = self.view.itemsize
* info.len = self.view.len
*/
__pyx_t_5 = __pyx_v_self->view.ndim;
__pyx_v_info->ndim = __pyx_t_5;
/* "View.MemoryView":493
* info.buf = self.view.buf
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize # <<<<<<<<<<<<<<
* info.len = self.view.len
* info.readonly = 0
*/
__pyx_t_6 = __pyx_v_self->view.itemsize;
__pyx_v_info->itemsize = __pyx_t_6;
/* "View.MemoryView":494
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
* info.len = self.view.len # <<<<<<<<<<<<<<
* info.readonly = 0
* info.obj = self
*/
__pyx_t_6 = __pyx_v_self->view.len;
__pyx_v_info->len = __pyx_t_6;
/* "View.MemoryView":495
* info.itemsize = self.view.itemsize
* info.len = self.view.len
* info.readonly = 0 # <<<<<<<<<<<<<<
* info.obj = self
*
*/
__pyx_v_info->readonly = 0;
/* "View.MemoryView":496
* info.len = self.view.len
* info.readonly = 0
* info.obj = self # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = ((PyObject *)__pyx_v_self);
/* "View.MemoryView":470
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_STRIDES:
* info.shape = self.view.shape
*/
/* function exit code */
__pyx_r = 0;
if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(Py_None);
__Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":503
* property T:
* @cname('__pyx_memoryview_transpose')
* def __get__(self): # <<<<<<<<<<<<<<
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":504
* @cname('__pyx_memoryview_transpose')
* def __get__(self):
* cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<<
* transpose_memslice(&result.from_slice)
* return result
*/
__pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":505
* def __get__(self):
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":506
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
* return result # <<<<<<<<<<<<<<
*
* property base:
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":503
* property T:
* @cname('__pyx_memoryview_transpose')
* def __get__(self): # <<<<<<<<<<<<<<
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":510
* property base:
* @cname('__pyx_memoryview__get__base')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":511
* @cname('__pyx_memoryview__get__base')
* def __get__(self):
* return self.obj # <<<<<<<<<<<<<<
*
* property shape:
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->obj);
__pyx_r = __pyx_v_self->obj;
goto __pyx_L0;
/* "View.MemoryView":510
* property base:
* @cname('__pyx_memoryview__get__base')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":515
* property shape:
* @cname('__pyx_memoryview_get_shape')
* def __get__(self): # <<<<<<<<<<<<<<
* return tuple([length for length in self.view.shape[:self.view.ndim]])
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_length;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
Py_ssize_t *__pyx_t_2;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":516
* @cname('__pyx_memoryview_get_shape')
* def __get__(self):
* return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* property strides:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
__pyx_t_2 = __pyx_t_4;
__pyx_v_length = (__pyx_t_2[0]);
__pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "View.MemoryView":515
* property shape:
* @cname('__pyx_memoryview_get_shape')
* def __get__(self): # <<<<<<<<<<<<<<
* return tuple([length for length in self.view.shape[:self.view.ndim]])
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":520
* property strides:
* @cname('__pyx_memoryview_get_strides')
* def __get__(self): # <<<<<<<<<<<<<<
* if self.view.strides == NULL:
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_stride;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":521
* @cname('__pyx_memoryview_get_strides')
* def __get__(self):
* if self.view.strides == NULL: # <<<<<<<<<<<<<<
*
* raise ValueError("Buffer view does not expose strides")
*/
__pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":523
* if self.view.strides == NULL:
*
* raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]])
*/
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":521
* @cname('__pyx_memoryview_get_strides')
* def __get__(self):
* if self.view.strides == NULL: # <<<<<<<<<<<<<<
*
* raise ValueError("Buffer view does not expose strides")
*/
}
/* "View.MemoryView":525
* raise ValueError("Buffer view does not expose strides")
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* property suboffsets:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
__pyx_t_3 = __pyx_t_5;
__pyx_v_stride = (__pyx_t_3[0]);
__pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
}
__pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L0;
/* "View.MemoryView":520
* property strides:
* @cname('__pyx_memoryview_get_strides')
* def __get__(self): # <<<<<<<<<<<<<<
* if self.view.strides == NULL:
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":529
* property suboffsets:
* @cname('__pyx_memoryview_get_suboffsets')
* def __get__(self): # <<<<<<<<<<<<<<
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
Py_ssize_t *__pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":530
* @cname('__pyx_memoryview_get_suboffsets')
* def __get__(self):
* if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
* return (-1,) * self.view.ndim
*
*/
__pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":531
* def __get__(self):
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Multiply(__pyx_tuple__19, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":530
* @cname('__pyx_memoryview_get_suboffsets')
* def __get__(self):
* if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
* return (-1,) * self.view.ndim
*
*/
}
/* "View.MemoryView":533
* return (-1,) * self.view.ndim
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* property ndim:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
__pyx_t_4 = __pyx_t_6;
__pyx_v_suboffset = (__pyx_t_4[0]);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":529
* property suboffsets:
* @cname('__pyx_memoryview_get_suboffsets')
* def __get__(self): # <<<<<<<<<<<<<<
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":537
* property ndim:
* @cname('__pyx_memoryview_get_ndim')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.view.ndim
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":538
* @cname('__pyx_memoryview_get_ndim')
* def __get__(self):
* return self.view.ndim # <<<<<<<<<<<<<<
*
* property itemsize:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":537
* property ndim:
* @cname('__pyx_memoryview_get_ndim')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.view.ndim
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":542
* property itemsize:
* @cname('__pyx_memoryview_get_itemsize')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":543
* @cname('__pyx_memoryview_get_itemsize')
* def __get__(self):
* return self.view.itemsize # <<<<<<<<<<<<<<
*
* property nbytes:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":542
* property itemsize:
* @cname('__pyx_memoryview_get_itemsize')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.view.itemsize
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":547
* property nbytes:
* @cname('__pyx_memoryview_get_nbytes')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.size * self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":548
* @cname('__pyx_memoryview_get_nbytes')
* def __get__(self):
* return self.size * self.view.itemsize # <<<<<<<<<<<<<<
*
* property size:
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":547
* property nbytes:
* @cname('__pyx_memoryview_get_nbytes')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.size * self.view.itemsize
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":552
* property size:
* @cname('__pyx_memoryview_get_size')
* def __get__(self): # <<<<<<<<<<<<<<
* if self._size is None:
* result = 1
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_v_result = NULL;
PyObject *__pyx_v_length = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":553
* @cname('__pyx_memoryview_get_size')
* def __get__(self):
* if self._size is None: # <<<<<<<<<<<<<<
* result = 1
*
*/
__pyx_t_1 = (__pyx_v_self->_size == Py_None);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":554
* def __get__(self):
* if self._size is None:
* result = 1 # <<<<<<<<<<<<<<
*
* for length in self.view.shape[:self.view.ndim]:
*/
__Pyx_INCREF(__pyx_int_1);
__pyx_v_result = __pyx_int_1;
/* "View.MemoryView":556
* result = 1
*
* for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<<
* result *= length
*
*/
__pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
__pyx_t_3 = __pyx_t_5;
__pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
__pyx_t_6 = 0;
/* "View.MemoryView":557
*
* for length in self.view.shape[:self.view.ndim]:
* result *= length # <<<<<<<<<<<<<<
*
* self._size = result
*/
__pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
__pyx_t_6 = 0;
}
/* "View.MemoryView":559
* result *= length
*
* self._size = result # <<<<<<<<<<<<<<
*
* return self._size
*/
__Pyx_INCREF(__pyx_v_result);
__Pyx_GIVEREF(__pyx_v_result);
__Pyx_GOTREF(__pyx_v_self->_size);
__Pyx_DECREF(__pyx_v_self->_size);
__pyx_v_self->_size = __pyx_v_result;
/* "View.MemoryView":553
* @cname('__pyx_memoryview_get_size')
* def __get__(self):
* if self._size is None: # <<<<<<<<<<<<<<
* result = 1
*
*/
}
/* "View.MemoryView":561
* self._size = result
*
* return self._size # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->_size);
__pyx_r = __pyx_v_self->_size;
goto __pyx_L0;
/* "View.MemoryView":552
* property size:
* @cname('__pyx_memoryview_get_size')
* def __get__(self): # <<<<<<<<<<<<<<
* if self._size is None:
* result = 1
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XDECREF(__pyx_v_length);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":563
* return self._size
*
* def __len__(self): # <<<<<<<<<<<<<<
* if self.view.ndim >= 1:
* return self.view.shape[0]
*/
/* Python wrapper */
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("__len__", 0);
/* "View.MemoryView":564
*
* def __len__(self):
* if self.view.ndim >= 1: # <<<<<<<<<<<<<<
* return self.view.shape[0]
*
*/
__pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":565
* def __len__(self):
* if self.view.ndim >= 1:
* return self.view.shape[0] # <<<<<<<<<<<<<<
*
* return 0
*/
__pyx_r = (__pyx_v_self->view.shape[0]);
goto __pyx_L0;
/* "View.MemoryView":564
*
* def __len__(self):
* if self.view.ndim >= 1: # <<<<<<<<<<<<<<
* return self.view.shape[0]
*
*/
}
/* "View.MemoryView":567
* return self.view.shape[0]
*
* return 0 # <<<<<<<<<<<<<<
*
* def __repr__(self):
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":563
* return self._size
*
* def __len__(self): # <<<<<<<<<<<<<<
* if self.view.ndim >= 1:
* return self.view.shape[0]
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":569
* return 0
*
* def __repr__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self))
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__repr__", 0);
/* "View.MemoryView":570
*
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
* id(self))
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":571
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self)) # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":570
*
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
* id(self))
*
*/
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
__pyx_t_1 = 0;
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":569
* return 0
*
* def __repr__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self))
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":573
* id(self))
*
* def __str__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
/* "View.MemoryView":574
*
* def __str__(self):
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":573
* id(self))
*
* def __str__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":577
*
*
* def is_c_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice *__pyx_v_mslice;
__Pyx_memviewslice __pyx_v_tmp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_c_contig", 0);
/* "View.MemoryView":580
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice, 'C', self.view.ndim)
*
*/
__pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));
/* "View.MemoryView":581
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice, 'C', self.view.ndim) # <<<<<<<<<<<<<<
*
* def is_f_contig(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":577
*
*
* def is_c_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":583
* return slice_is_contig(mslice, 'C', self.view.ndim)
*
* def is_f_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice *__pyx_v_mslice;
__Pyx_memviewslice __pyx_v_tmp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_f_contig", 0);
/* "View.MemoryView":586
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice, 'F', self.view.ndim)
*
*/
__pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));
/* "View.MemoryView":587
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice, 'F', self.view.ndim) # <<<<<<<<<<<<<<
*
* def copy(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":583
* return slice_is_contig(mslice, 'C', self.view.ndim)
*
* def is_f_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":589
* return slice_is_contig(mslice, 'F', self.view.ndim)
*
* def copy(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice __pyx_v_mslice;
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("copy", 0);
/* "View.MemoryView":591
* def copy(self):
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<<
*
* slice_copy(self, &mslice)
*/
__pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
/* "View.MemoryView":593
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*
* slice_copy(self, &mslice) # <<<<<<<<<<<<<<
* mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
* self.view.itemsize,
*/
__pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
/* "View.MemoryView":594
*
* slice_copy(self, &mslice)
* mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<<
* self.view.itemsize,
* flags|PyBUF_C_CONTIGUOUS,
*/
__pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), __pyx_k_c, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_mslice = __pyx_t_1;
/* "View.MemoryView":599
* self.dtype_is_object)
*
* return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<<
*
* def copy_fortran(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":589
* return slice_is_contig(mslice, 'F', self.view.ndim)
*
* def copy(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":601
* return memoryview_copy_from_slice(self, &mslice)
*
* def copy_fortran(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice __pyx_v_src;
__Pyx_memviewslice __pyx_v_dst;
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("copy_fortran", 0);
/* "View.MemoryView":603
* def copy_fortran(self):
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<<
*
* slice_copy(self, &src)
*/
__pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
/* "View.MemoryView":605
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*
* slice_copy(self, &src) # <<<<<<<<<<<<<<
* dst = slice_copy_contig(&src, "fortran", self.view.ndim,
* self.view.itemsize,
*/
__pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
/* "View.MemoryView":606
*
* slice_copy(self, &src)
* dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<<
* self.view.itemsize,
* flags|PyBUF_F_CONTIGUOUS,
*/
__pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), __pyx_k_fortran, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_dst = __pyx_t_1;
/* "View.MemoryView":611
* self.dtype_is_object)
*
* return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":601
* return memoryview_copy_from_slice(self, &mslice)
*
* def copy_fortran(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":615
*
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
*/
static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
struct __pyx_memoryview_obj *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
/* "View.MemoryView":616
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
* cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<<
* result.typeinfo = typeinfo
* return result
*/
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_o);
__Pyx_GIVEREF(__pyx_v_o);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":617
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result->typeinfo = __pyx_v_typeinfo;
/* "View.MemoryView":618
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
* return result # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_check')
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":615
*
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":621
*
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
* return isinstance(o, memoryview)
*
*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("memoryview_check", 0);
/* "View.MemoryView":622
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o):
* return isinstance(o, memoryview) # <<<<<<<<<<<<<<
*
* cdef tuple _unellipsify(object index, int ndim):
*/
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
__pyx_r = __pyx_t_1;
goto __pyx_L0;
/* "View.MemoryView":621
*
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
* return isinstance(o, memoryview)
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":624
* return isinstance(o, memoryview)
*
* cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
* """
* Replace all ellipses with full slices and fill incomplete indices with
*/
static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
PyObject *__pyx_v_tup = NULL;
PyObject *__pyx_v_result = NULL;
int __pyx_v_have_slices;
int __pyx_v_seen_ellipsis;
CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
PyObject *__pyx_v_item = NULL;
Py_ssize_t __pyx_v_nslices;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
Py_ssize_t __pyx_t_5;
PyObject *(*__pyx_t_6)(PyObject *);
PyObject *__pyx_t_7 = NULL;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_t_10;
PyObject *__pyx_t_11 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("_unellipsify", 0);
/* "View.MemoryView":629
* full slices.
* """
* if not isinstance(index, tuple): # <<<<<<<<<<<<<<
* tup = (index,)
* else:
*/
__pyx_t_1 = PyTuple_Check(__pyx_v_index);
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":630
* """
* if not isinstance(index, tuple):
* tup = (index,) # <<<<<<<<<<<<<<
* else:
* tup = index
*/
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_index);
__Pyx_GIVEREF(__pyx_v_index);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
__pyx_v_tup = __pyx_t_3;
__pyx_t_3 = 0;
/* "View.MemoryView":629
* full slices.
* """
* if not isinstance(index, tuple): # <<<<<<<<<<<<<<
* tup = (index,)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":632
* tup = (index,)
* else:
* tup = index # <<<<<<<<<<<<<<
*
* result = []
*/
/*else*/ {
__Pyx_INCREF(__pyx_v_index);
__pyx_v_tup = __pyx_v_index;
}
__pyx_L3:;
/* "View.MemoryView":634
* tup = index
*
* result = [] # <<<<<<<<<<<<<<
* have_slices = False
* seen_ellipsis = False
*/
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_v_result = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":635
*
* result = []
* have_slices = False # <<<<<<<<<<<<<<
* seen_ellipsis = False
* for idx, item in enumerate(tup):
*/
__pyx_v_have_slices = 0;
/* "View.MemoryView":636
* result = []
* have_slices = False
* seen_ellipsis = False # <<<<<<<<<<<<<<
* for idx, item in enumerate(tup):
* if item is Ellipsis:
*/
__pyx_v_seen_ellipsis = 0;
/* "View.MemoryView":637
* have_slices = False
* seen_ellipsis = False
* for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
* if item is Ellipsis:
* if not seen_ellipsis:
*/
__Pyx_INCREF(__pyx_int_0);
__pyx_t_3 = __pyx_int_0;
if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
__pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
__pyx_t_6 = NULL;
} else {
__pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
for (;;) {
if (likely(!__pyx_t_6)) {
if (likely(PyList_CheckExact(__pyx_t_4))) {
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
#endif
} else {
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
#endif
}
} else {
__pyx_t_7 = __pyx_t_6(__pyx_t_4);
if (unlikely(!__pyx_t_7)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_7);
}
__Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
__pyx_t_7 = 0;
__Pyx_INCREF(__pyx_t_3);
__Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
__pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_3);
__pyx_t_3 = __pyx_t_7;
__pyx_t_7 = 0;
/* "View.MemoryView":638
* seen_ellipsis = False
* for idx, item in enumerate(tup):
* if item is Ellipsis: # <<<<<<<<<<<<<<
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
*/
__pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":639
* for idx, item in enumerate(tup):
* if item is Ellipsis:
* if not seen_ellipsis: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True
*/
__pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":640
* if item is Ellipsis:
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
* seen_ellipsis = True
* else:
*/
__pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
{ Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
__Pyx_INCREF(__pyx_slice__20);
__Pyx_GIVEREF(__pyx_slice__20);
PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__20);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
/* "View.MemoryView":641
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True # <<<<<<<<<<<<<<
* else:
* result.append(slice(None))
*/
__pyx_v_seen_ellipsis = 1;
/* "View.MemoryView":639
* for idx, item in enumerate(tup):
* if item is Ellipsis:
* if not seen_ellipsis: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True
*/
goto __pyx_L7;
}
/* "View.MemoryView":643
* seen_ellipsis = True
* else:
* result.append(slice(None)) # <<<<<<<<<<<<<<
* have_slices = True
* else:
*/
/*else*/ {
__pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__21); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L7:;
/* "View.MemoryView":644
* else:
* result.append(slice(None))
* have_slices = True # <<<<<<<<<<<<<<
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item):
*/
__pyx_v_have_slices = 1;
/* "View.MemoryView":638
* seen_ellipsis = False
* for idx, item in enumerate(tup):
* if item is Ellipsis: # <<<<<<<<<<<<<<
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
*/
goto __pyx_L6;
}
/* "View.MemoryView":646
* have_slices = True
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
* raise TypeError("Cannot index with type '%s'" % type(item))
*
*/
/*else*/ {
__pyx_t_2 = PySlice_Check(__pyx_v_item);
__pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
if (__pyx_t_10) {
} else {
__pyx_t_1 = __pyx_t_10;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
__pyx_t_1 = __pyx_t_10;
__pyx_L9_bool_binop_done:;
if (__pyx_t_1) {
/* "View.MemoryView":647
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item):
* raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<<
*
* have_slices = have_slices or isinstance(item, slice)
*/
__pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_11);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
__Pyx_Raise(__pyx_t_7, 0, 0, 0);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":646
* have_slices = True
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
* raise TypeError("Cannot index with type '%s'" % type(item))
*
*/
}
/* "View.MemoryView":649
* raise TypeError("Cannot index with type '%s'" % type(item))
*
* have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<<
* result.append(item)
*
*/
__pyx_t_10 = (__pyx_v_have_slices != 0);
if (!__pyx_t_10) {
} else {
__pyx_t_1 = __pyx_t_10;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_10 = PySlice_Check(__pyx_v_item);
__pyx_t_2 = (__pyx_t_10 != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L11_bool_binop_done:;
__pyx_v_have_slices = __pyx_t_1;
/* "View.MemoryView":650
*
* have_slices = have_slices or isinstance(item, slice)
* result.append(item) # <<<<<<<<<<<<<<
*
* nslices = ndim - len(result)
*/
__pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L6:;
/* "View.MemoryView":637
* have_slices = False
* seen_ellipsis = False
* for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
* if item is Ellipsis:
* if not seen_ellipsis:
*/
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":652
* result.append(item)
*
* nslices = ndim - len(result) # <<<<<<<<<<<<<<
* if nslices:
* result.extend([slice(None)] * nslices)
*/
__pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
/* "View.MemoryView":653
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
__pyx_t_1 = (__pyx_v_nslices != 0);
if (__pyx_t_1) {
/* "View.MemoryView":654
* nslices = ndim - len(result)
* if nslices:
* result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<<
*
* return have_slices or nslices, tuple(result)
*/
__pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
{ Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
__Pyx_INCREF(__pyx_slice__22);
__Pyx_GIVEREF(__pyx_slice__22);
PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__22);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":653
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
}
/* "View.MemoryView":656
* result.extend([slice(None)] * nslices)
*
* return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<<
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
*/
__Pyx_XDECREF(__pyx_r);
if (!__pyx_v_have_slices) {
} else {
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L14_bool_binop_done;
}
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __pyx_t_4;
__pyx_t_4 = 0;
__pyx_L14_bool_binop_done:;
__pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
__pyx_t_3 = 0;
__pyx_t_4 = 0;
__pyx_r = ((PyObject*)__pyx_t_7);
__pyx_t_7 = 0;
goto __pyx_L0;
/* "View.MemoryView":624
* return isinstance(o, memoryview)
*
* cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
* """
* Replace all ellipses with full slices and fill incomplete indices with
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_tup);
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XDECREF(__pyx_v_idx);
__Pyx_XDECREF(__pyx_v_item);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":658
* return have_slices or nslices, tuple(result)
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
*/
static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
Py_ssize_t *__pyx_t_1;
Py_ssize_t *__pyx_t_2;
Py_ssize_t *__pyx_t_3;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
/* "View.MemoryView":659
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<<
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported")
*/
__pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
__pyx_t_1 = __pyx_t_3;
__pyx_v_suboffset = (__pyx_t_1[0]);
/* "View.MemoryView":660
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* raise ValueError("Indirect dimensions not supported")
*
*/
__pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":661
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":660
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* raise ValueError("Indirect dimensions not supported")
*
*/
}
}
/* "View.MemoryView":658
* return have_slices or nslices, tuple(result)
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":668
*
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
* cdef int new_ndim = 0, suboffset_dim = -1, dim
* cdef bint negative_step
*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
int __pyx_v_new_ndim;
int __pyx_v_suboffset_dim;
int __pyx_v_dim;
__Pyx_memviewslice __pyx_v_src;
__Pyx_memviewslice __pyx_v_dst;
__Pyx_memviewslice *__pyx_v_p_src;
struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
__Pyx_memviewslice *__pyx_v_p_dst;
int *__pyx_v_p_suboffset_dim;
Py_ssize_t __pyx_v_start;
Py_ssize_t __pyx_v_stop;
Py_ssize_t __pyx_v_step;
int __pyx_v_have_start;
int __pyx_v_have_stop;
int __pyx_v_have_step;
PyObject *__pyx_v_index = NULL;
struct __pyx_memoryview_obj *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
struct __pyx_memoryview_obj *__pyx_t_4;
char *__pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
PyObject *(*__pyx_t_8)(PyObject *);
PyObject *__pyx_t_9 = NULL;
Py_ssize_t __pyx_t_10;
int __pyx_t_11;
Py_ssize_t __pyx_t_12;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memview_slice", 0);
/* "View.MemoryView":669
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices):
* cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<<
* cdef bint negative_step
* cdef __Pyx_memviewslice src, dst
*/
__pyx_v_new_ndim = 0;
__pyx_v_suboffset_dim = -1;
/* "View.MemoryView":676
*
*
* memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<<
*
* cdef _memoryviewslice memviewsliceobj
*/
memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)));
/* "View.MemoryView":680
* cdef _memoryviewslice memviewsliceobj
*
* assert memview.view.ndim > 0 # <<<<<<<<<<<<<<
*
* if isinstance(memview, _memoryviewslice):
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "View.MemoryView":682
* assert memview.view.ndim > 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":683
*
* if isinstance(memview, _memoryviewslice):
* memviewsliceobj = memview # <<<<<<<<<<<<<<
* p_src = &memviewsliceobj.from_slice
* else:
*/
if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((PyObject *)__pyx_v_memview);
__Pyx_INCREF(__pyx_t_3);
__pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":684
* if isinstance(memview, _memoryviewslice):
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<<
* else:
* slice_copy(memview, &src)
*/
__pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
/* "View.MemoryView":682
* assert memview.view.ndim > 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice
*/
goto __pyx_L3;
}
/* "View.MemoryView":686
* p_src = &memviewsliceobj.from_slice
* else:
* slice_copy(memview, &src) # <<<<<<<<<<<<<<
* p_src = &src
*
*/
/*else*/ {
__pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
/* "View.MemoryView":687
* else:
* slice_copy(memview, &src)
* p_src = &src # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_p_src = (&__pyx_v_src);
}
__pyx_L3:;
/* "View.MemoryView":693
*
*
* dst.memview = p_src.memview # <<<<<<<<<<<<<<
* dst.data = p_src.data
*
*/
__pyx_t_4 = __pyx_v_p_src->memview;
__pyx_v_dst.memview = __pyx_t_4;
/* "View.MemoryView":694
*
* dst.memview = p_src.memview
* dst.data = p_src.data # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_v_p_src->data;
__pyx_v_dst.data = __pyx_t_5;
/* "View.MemoryView":699
*
*
* cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<<
* cdef int *p_suboffset_dim = &suboffset_dim
* cdef Py_ssize_t start, stop, step
*/
__pyx_v_p_dst = (&__pyx_v_dst);
/* "View.MemoryView":700
*
* cdef __Pyx_memviewslice *p_dst = &dst
* cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<<
* cdef Py_ssize_t start, stop, step
* cdef bint have_start, have_stop, have_step
*/
__pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
/* "View.MemoryView":704
* cdef bint have_start, have_stop, have_step
*
* for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
* if PyIndex_Check(index):
* slice_memviewslice(
*/
__pyx_t_6 = 0;
if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
__pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
__pyx_t_8 = NULL;
} else {
__pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
for (;;) {
if (likely(!__pyx_t_8)) {
if (likely(PyList_CheckExact(__pyx_t_3))) {
if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
#endif
} else {
if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
#endif
}
} else {
__pyx_t_9 = __pyx_t_8(__pyx_t_3);
if (unlikely(!__pyx_t_9)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
__Pyx_GOTREF(__pyx_t_9);
}
__Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
__pyx_t_9 = 0;
__pyx_v_dim = __pyx_t_6;
__pyx_t_6 = (__pyx_t_6 + 1);
/* "View.MemoryView":705
*
* for dim, index in enumerate(indices):
* if PyIndex_Check(index): # <<<<<<<<<<<<<<
* slice_memviewslice(
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
*/
__pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":709
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
* index, 0, 0, # start, stop, step # <<<<<<<<<<<<<<
* 0, 0, 0, # have_{start,stop,step}
* False)
*/
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":706
* for dim, index in enumerate(indices):
* if PyIndex_Check(index):
* slice_memviewslice( # <<<<<<<<<<<<<<
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
*/
__pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":705
*
* for dim, index in enumerate(indices):
* if PyIndex_Check(index): # <<<<<<<<<<<<<<
* slice_memviewslice(
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
*/
goto __pyx_L6;
}
/* "View.MemoryView":712
* 0, 0, 0, # have_{start,stop,step}
* False)
* elif index is None: # <<<<<<<<<<<<<<
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
*/
__pyx_t_2 = (__pyx_v_index == Py_None);
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":713
* False)
* elif index is None:
* p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<<
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1
*/
(__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
/* "View.MemoryView":714
* elif index is None:
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<<
* p_dst.suboffsets[new_ndim] = -1
* new_ndim += 1
*/
(__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
/* "View.MemoryView":715
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<<
* new_ndim += 1
* else:
*/
(__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
/* "View.MemoryView":716
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1
* new_ndim += 1 # <<<<<<<<<<<<<<
* else:
* start = index.start or 0
*/
__pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
/* "View.MemoryView":712
* 0, 0, 0, # have_{start,stop,step}
* False)
* elif index is None: # <<<<<<<<<<<<<<
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
*/
goto __pyx_L6;
}
/* "View.MemoryView":718
* new_ndim += 1
* else:
* start = index.start or 0 # <<<<<<<<<<<<<<
* stop = index.stop or 0
* step = index.step or 0
*/
/*else*/ {
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L7_bool_binop_done:;
__pyx_v_start = __pyx_t_10;
/* "View.MemoryView":719
* else:
* start = index.start or 0
* stop = index.stop or 0 # <<<<<<<<<<<<<<
* step = index.step or 0
*
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L9_bool_binop_done:;
__pyx_v_stop = __pyx_t_10;
/* "View.MemoryView":720
* start = index.start or 0
* stop = index.stop or 0
* step = index.step or 0 # <<<<<<<<<<<<<<
*
* have_start = index.start is not None
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L11_bool_binop_done:;
__pyx_v_step = __pyx_t_10;
/* "View.MemoryView":722
* step = index.step or 0
*
* have_start = index.start is not None # <<<<<<<<<<<<<<
* have_stop = index.stop is not None
* have_step = index.step is not None
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_start = __pyx_t_1;
/* "View.MemoryView":723
*
* have_start = index.start is not None
* have_stop = index.stop is not None # <<<<<<<<<<<<<<
* have_step = index.step is not None
*
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_stop = __pyx_t_1;
/* "View.MemoryView":724
* have_start = index.start is not None
* have_stop = index.stop is not None
* have_step = index.step is not None # <<<<<<<<<<<<<<
*
* slice_memviewslice(
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_step = __pyx_t_1;
/* "View.MemoryView":726
* have_step = index.step is not None
*
* slice_memviewslice( # <<<<<<<<<<<<<<
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
*/
__pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":732
* have_start, have_stop, have_step,
* True)
* new_ndim += 1 # <<<<<<<<<<<<<<
*
* if isinstance(memview, _memoryviewslice):
*/
__pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
}
__pyx_L6:;
/* "View.MemoryView":704
* cdef bint have_start, have_stop, have_step
*
* for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
* if PyIndex_Check(index):
* slice_memviewslice(
*/
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":734
* new_ndim += 1
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":735
*
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func,
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
/* "View.MemoryView":736
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func, # <<<<<<<<<<<<<<
* memviewsliceobj.to_dtype_func,
* memview.dtype_is_object)
*/
if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
/* "View.MemoryView":737
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
* else:
*/
if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
/* "View.MemoryView":735
*
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func,
*/
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":734
* new_ndim += 1
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
*/
}
/* "View.MemoryView":740
* memview.dtype_is_object)
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
*
*/
/*else*/ {
__Pyx_XDECREF(((PyObject *)__pyx_r));
/* "View.MemoryView":741
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL,
* memview.dtype_is_object) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
/* "View.MemoryView":740
* memview.dtype_is_object)
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
*
*/
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":668
*
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
* cdef int new_ndim = 0, suboffset_dim = -1, dim
* cdef bint negative_step
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
__Pyx_XDECREF(__pyx_v_index);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":765
*
* @cname('__pyx_memoryview_slice_memviewslice')
* cdef int slice_memviewslice( # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
Py_ssize_t __pyx_v_new_shape;
int __pyx_v_negative_step;
int __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":785
* cdef bint negative_step
*
* if not is_slice: # <<<<<<<<<<<<<<
*
* if start < 0:
*/
__pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":787
* if not is_slice:
*
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if not 0 <= start < shape:
*/
__pyx_t_1 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":788
*
* if start < 0:
* start += shape # <<<<<<<<<<<<<<
* if not 0 <= start < shape:
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
*/
__pyx_v_start = (__pyx_v_start + __pyx_v_shape);
/* "View.MemoryView":787
* if not is_slice:
*
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if not 0 <= start < shape:
*/
}
/* "View.MemoryView":789
* if start < 0:
* start += shape
* if not 0 <= start < shape: # <<<<<<<<<<<<<<
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
* else:
*/
__pyx_t_1 = (0 <= __pyx_v_start);
if (__pyx_t_1) {
__pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
}
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":790
* start += shape
* if not 0 <= start < shape:
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<<
* else:
*
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_Index_out_of_bounds_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":789
* if start < 0:
* start += shape
* if not 0 <= start < shape: # <<<<<<<<<<<<<<
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
* else:
*/
}
/* "View.MemoryView":785
* cdef bint negative_step
*
* if not is_slice: # <<<<<<<<<<<<<<
*
* if start < 0:
*/
goto __pyx_L3;
}
/* "View.MemoryView":793
* else:
*
* negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<<
*
* if have_step and step == 0:
*/
/*else*/ {
__pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
if (__pyx_t_1) {
} else {
__pyx_t_2 = __pyx_t_1;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_1 = ((__pyx_v_step < 0) != 0);
__pyx_t_2 = __pyx_t_1;
__pyx_L6_bool_binop_done:;
__pyx_v_negative_step = __pyx_t_2;
/* "View.MemoryView":795
* negative_step = have_step != 0 and step < 0
*
* if have_step and step == 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
*
*/
__pyx_t_1 = (__pyx_v_have_step != 0);
if (__pyx_t_1) {
} else {
__pyx_t_2 = __pyx_t_1;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_1 = ((__pyx_v_step == 0) != 0);
__pyx_t_2 = __pyx_t_1;
__pyx_L9_bool_binop_done:;
if (__pyx_t_2) {
/* "View.MemoryView":796
*
* if have_step and step == 0:
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Step_may_not_be_zero_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":795
* negative_step = have_step != 0 and step < 0
*
* if have_step and step == 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
*
*/
}
/* "View.MemoryView":799
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
__pyx_t_2 = (__pyx_v_have_start != 0);
if (__pyx_t_2) {
/* "View.MemoryView":800
*
* if have_start:
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if start < 0:
*/
__pyx_t_2 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":801
* if have_start:
* if start < 0:
* start += shape # <<<<<<<<<<<<<<
* if start < 0:
* start = 0
*/
__pyx_v_start = (__pyx_v_start + __pyx_v_shape);
/* "View.MemoryView":802
* if start < 0:
* start += shape
* if start < 0: # <<<<<<<<<<<<<<
* start = 0
* elif start >= shape:
*/
__pyx_t_2 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":803
* start += shape
* if start < 0:
* start = 0 # <<<<<<<<<<<<<<
* elif start >= shape:
* if negative_step:
*/
__pyx_v_start = 0;
/* "View.MemoryView":802
* if start < 0:
* start += shape
* if start < 0: # <<<<<<<<<<<<<<
* start = 0
* elif start >= shape:
*/
}
/* "View.MemoryView":800
*
* if have_start:
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if start < 0:
*/
goto __pyx_L12;
}
/* "View.MemoryView":804
* if start < 0:
* start = 0
* elif start >= shape: # <<<<<<<<<<<<<<
* if negative_step:
* start = shape - 1
*/
__pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":805
* start = 0
* elif start >= shape:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":806
* elif start >= shape:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = shape
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":805
* start = 0
* elif start >= shape:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L14;
}
/* "View.MemoryView":808
* start = shape - 1
* else:
* start = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
/*else*/ {
__pyx_v_start = __pyx_v_shape;
}
__pyx_L14:;
/* "View.MemoryView":804
* if start < 0:
* start = 0
* elif start >= shape: # <<<<<<<<<<<<<<
* if negative_step:
* start = shape - 1
*/
}
__pyx_L12:;
/* "View.MemoryView":799
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
goto __pyx_L11;
}
/* "View.MemoryView":810
* start = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
/*else*/ {
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":811
* else:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = 0
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":810
* start = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L15;
}
/* "View.MemoryView":813
* start = shape - 1
* else:
* start = 0 # <<<<<<<<<<<<<<
*
* if have_stop:
*/
/*else*/ {
__pyx_v_start = 0;
}
__pyx_L15:;
}
__pyx_L11:;
/* "View.MemoryView":815
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
__pyx_t_2 = (__pyx_v_have_stop != 0);
if (__pyx_t_2) {
/* "View.MemoryView":816
*
* if have_stop:
* if stop < 0: # <<<<<<<<<<<<<<
* stop += shape
* if stop < 0:
*/
__pyx_t_2 = ((__pyx_v_stop < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":817
* if have_stop:
* if stop < 0:
* stop += shape # <<<<<<<<<<<<<<
* if stop < 0:
* stop = 0
*/
__pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
/* "View.MemoryView":818
* if stop < 0:
* stop += shape
* if stop < 0: # <<<<<<<<<<<<<<
* stop = 0
* elif stop > shape:
*/
__pyx_t_2 = ((__pyx_v_stop < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":819
* stop += shape
* if stop < 0:
* stop = 0 # <<<<<<<<<<<<<<
* elif stop > shape:
* stop = shape
*/
__pyx_v_stop = 0;
/* "View.MemoryView":818
* if stop < 0:
* stop += shape
* if stop < 0: # <<<<<<<<<<<<<<
* stop = 0
* elif stop > shape:
*/
}
/* "View.MemoryView":816
*
* if have_stop:
* if stop < 0: # <<<<<<<<<<<<<<
* stop += shape
* if stop < 0:
*/
goto __pyx_L17;
}
/* "View.MemoryView":820
* if stop < 0:
* stop = 0
* elif stop > shape: # <<<<<<<<<<<<<<
* stop = shape
* else:
*/
__pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":821
* stop = 0
* elif stop > shape:
* stop = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
__pyx_v_stop = __pyx_v_shape;
/* "View.MemoryView":820
* if stop < 0:
* stop = 0
* elif stop > shape: # <<<<<<<<<<<<<<
* stop = shape
* else:
*/
}
__pyx_L17:;
/* "View.MemoryView":815
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
goto __pyx_L16;
}
/* "View.MemoryView":823
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
/*else*/ {
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":824
* else:
* if negative_step:
* stop = -1 # <<<<<<<<<<<<<<
* else:
* stop = shape
*/
__pyx_v_stop = -1L;
/* "View.MemoryView":823
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
goto __pyx_L19;
}
/* "View.MemoryView":826
* stop = -1
* else:
* stop = shape # <<<<<<<<<<<<<<
*
* if not have_step:
*/
/*else*/ {
__pyx_v_stop = __pyx_v_shape;
}
__pyx_L19:;
}
__pyx_L16:;
/* "View.MemoryView":828
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
__pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":829
*
* if not have_step:
* step = 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_step = 1;
/* "View.MemoryView":828
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
}
/* "View.MemoryView":833
*
* with cython.cdivision(True):
* new_shape = (stop - start) // step # <<<<<<<<<<<<<<
*
* if (stop - start) - step * new_shape:
*/
__pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
/* "View.MemoryView":835
* new_shape = (stop - start) // step
*
* if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
* new_shape += 1
*
*/
__pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":836
*
* if (stop - start) - step * new_shape:
* new_shape += 1 # <<<<<<<<<<<<<<
*
* if new_shape < 0:
*/
__pyx_v_new_shape = (__pyx_v_new_shape + 1);
/* "View.MemoryView":835
* new_shape = (stop - start) // step
*
* if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
* new_shape += 1
*
*/
}
/* "View.MemoryView":838
* new_shape += 1
*
* if new_shape < 0: # <<<<<<<<<<<<<<
* new_shape = 0
*
*/
__pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":839
*
* if new_shape < 0:
* new_shape = 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_new_shape = 0;
/* "View.MemoryView":838
* new_shape += 1
*
* if new_shape < 0: # <<<<<<<<<<<<<<
* new_shape = 0
*
*/
}
/* "View.MemoryView":842
*
*
* dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<<
* dst.shape[new_ndim] = new_shape
* dst.suboffsets[new_ndim] = suboffset
*/
(__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
/* "View.MemoryView":843
*
* dst.strides[new_ndim] = stride * step
* dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<<
* dst.suboffsets[new_ndim] = suboffset
*
*/
(__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
/* "View.MemoryView":844
* dst.strides[new_ndim] = stride * step
* dst.shape[new_ndim] = new_shape
* dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<<
*
*
*/
(__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
}
__pyx_L3:;
/* "View.MemoryView":847
*
*
* if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
* dst.data += start * stride
* else:
*/
__pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":848
*
* if suboffset_dim[0] < 0:
* dst.data += start * stride # <<<<<<<<<<<<<<
* else:
* dst.suboffsets[suboffset_dim[0]] += start * stride
*/
__pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
/* "View.MemoryView":847
*
*
* if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
* dst.data += start * stride
* else:
*/
goto __pyx_L23;
}
/* "View.MemoryView":850
* dst.data += start * stride
* else:
* dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<<
*
* if suboffset >= 0:
*/
/*else*/ {
__pyx_t_3 = (__pyx_v_suboffset_dim[0]);
(__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
}
__pyx_L23:;
/* "View.MemoryView":852
* dst.suboffsets[suboffset_dim[0]] += start * stride
*
* if suboffset >= 0: # <<<<<<<<<<<<<<
* if not is_slice:
* if new_ndim == 0:
*/
__pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":853
*
* if suboffset >= 0:
* if not is_slice: # <<<<<<<<<<<<<<
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset
*/
__pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":854
* if suboffset >= 0:
* if not is_slice:
* if new_ndim == 0: # <<<<<<<<<<<<<<
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
*/
__pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":855
* if not is_slice:
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset # <<<<<<<<<<<<<<
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d "
*/
__pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
/* "View.MemoryView":854
* if suboffset >= 0:
* if not is_slice:
* if new_ndim == 0: # <<<<<<<<<<<<<<
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
*/
goto __pyx_L26;
}
/* "View.MemoryView":857
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<<
* "must be indexed and not sliced", dim)
* else:
*/
/*else*/ {
/* "View.MemoryView":858
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d "
* "must be indexed and not sliced", dim) # <<<<<<<<<<<<<<
* else:
* suboffset_dim[0] = new_ndim
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_All_dimensions_preceding_dimensi, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L26:;
/* "View.MemoryView":853
*
* if suboffset >= 0:
* if not is_slice: # <<<<<<<<<<<<<<
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset
*/
goto __pyx_L25;
}
/* "View.MemoryView":860
* "must be indexed and not sliced", dim)
* else:
* suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<<
*
* return 0
*/
/*else*/ {
(__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
}
__pyx_L25:;
/* "View.MemoryView":852
* dst.suboffsets[suboffset_dim[0]] += start * stride
*
* if suboffset >= 0: # <<<<<<<<<<<<<<
* if not is_slice:
* if new_ndim == 0:
*/
}
/* "View.MemoryView":862
* suboffset_dim[0] = new_ndim
*
* return 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":765
*
* @cname('__pyx_memoryview_slice_memviewslice')
* cdef int slice_memviewslice( # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":868
*
* @cname('__pyx_pybuffer_index')
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
*/
static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
Py_ssize_t __pyx_v_shape;
Py_ssize_t __pyx_v_stride;
Py_ssize_t __pyx_v_suboffset;
Py_ssize_t __pyx_v_itemsize;
char *__pyx_v_resultp;
char *__pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("pybuffer_index", 0);
/* "View.MemoryView":870
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<<
* cdef Py_ssize_t itemsize = view.itemsize
* cdef char *resultp
*/
__pyx_v_suboffset = -1L;
/* "View.MemoryView":871
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
* cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<<
* cdef char *resultp
*
*/
__pyx_t_1 = __pyx_v_view->itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":874
* cdef char *resultp
*
* if view.ndim == 0: # <<<<<<<<<<<<<<
* shape = view.len / itemsize
* stride = itemsize
*/
__pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":875
*
* if view.ndim == 0:
* shape = view.len / itemsize # <<<<<<<<<<<<<<
* stride = itemsize
* else:
*/
if (unlikely(__pyx_v_itemsize == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
/* "View.MemoryView":876
* if view.ndim == 0:
* shape = view.len / itemsize
* stride = itemsize # <<<<<<<<<<<<<<
* else:
* shape = view.shape[dim]
*/
__pyx_v_stride = __pyx_v_itemsize;
/* "View.MemoryView":874
* cdef char *resultp
*
* if view.ndim == 0: # <<<<<<<<<<<<<<
* shape = view.len / itemsize
* stride = itemsize
*/
goto __pyx_L3;
}
/* "View.MemoryView":878
* stride = itemsize
* else:
* shape = view.shape[dim] # <<<<<<<<<<<<<<
* stride = view.strides[dim]
* if view.suboffsets != NULL:
*/
/*else*/ {
__pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
/* "View.MemoryView":879
* else:
* shape = view.shape[dim]
* stride = view.strides[dim] # <<<<<<<<<<<<<<
* if view.suboffsets != NULL:
* suboffset = view.suboffsets[dim]
*/
__pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
/* "View.MemoryView":880
* shape = view.shape[dim]
* stride = view.strides[dim]
* if view.suboffsets != NULL: # <<<<<<<<<<<<<<
* suboffset = view.suboffsets[dim]
*
*/
__pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":881
* stride = view.strides[dim]
* if view.suboffsets != NULL:
* suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<<
*
* if index < 0:
*/
__pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
/* "View.MemoryView":880
* shape = view.shape[dim]
* stride = view.strides[dim]
* if view.suboffsets != NULL: # <<<<<<<<<<<<<<
* suboffset = view.suboffsets[dim]
*
*/
}
}
__pyx_L3:;
/* "View.MemoryView":883
* suboffset = view.suboffsets[dim]
*
* if index < 0: # <<<<<<<<<<<<<<
* index += view.shape[dim]
* if index < 0:
*/
__pyx_t_2 = ((__pyx_v_index < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":884
*
* if index < 0:
* index += view.shape[dim] # <<<<<<<<<<<<<<
* if index < 0:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*/
__pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
/* "View.MemoryView":885
* if index < 0:
* index += view.shape[dim]
* if index < 0: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
__pyx_t_2 = ((__pyx_v_index < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":886
* index += view.shape[dim]
* if index < 0:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
*
* if index >= shape:
*/
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":885
* if index < 0:
* index += view.shape[dim]
* if index < 0: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
}
/* "View.MemoryView":883
* suboffset = view.suboffsets[dim]
*
* if index < 0: # <<<<<<<<<<<<<<
* index += view.shape[dim]
* if index < 0:
*/
}
/* "View.MemoryView":888
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* if index >= shape: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
__pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":889
*
* if index >= shape:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
*
* resultp = bufp + index * stride
*/
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":888
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* if index >= shape: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
}
/* "View.MemoryView":891
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* resultp = bufp + index * stride # <<<<<<<<<<<<<<
* if suboffset >= 0:
* resultp = (<char **> resultp)[0] + suboffset
*/
__pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
/* "View.MemoryView":892
*
* resultp = bufp + index * stride
* if suboffset >= 0: # <<<<<<<<<<<<<<
* resultp = (<char **> resultp)[0] + suboffset
*
*/
__pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":893
* resultp = bufp + index * stride
* if suboffset >= 0:
* resultp = (<char **> resultp)[0] + suboffset # <<<<<<<<<<<<<<
*
* return resultp
*/
__pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
/* "View.MemoryView":892
*
* resultp = bufp + index * stride
* if suboffset >= 0: # <<<<<<<<<<<<<<
* resultp = (<char **> resultp)[0] + suboffset
*
*/
}
/* "View.MemoryView":895
* resultp = (<char **> resultp)[0] + suboffset
*
* return resultp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_resultp;
goto __pyx_L0;
/* "View.MemoryView":868
*
* @cname('__pyx_pybuffer_index')
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":901
*
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
* cdef int ndim = memslice.memview.view.ndim
*
*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
int __pyx_v_ndim;
Py_ssize_t *__pyx_v_shape;
Py_ssize_t *__pyx_v_strides;
int __pyx_v_i;
int __pyx_v_j;
int __pyx_r;
int __pyx_t_1;
Py_ssize_t *__pyx_t_2;
long __pyx_t_3;
Py_ssize_t __pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
int __pyx_t_7;
int __pyx_t_8;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":902
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
* cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<<
*
* cdef Py_ssize_t *shape = memslice.shape
*/
__pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
__pyx_v_ndim = __pyx_t_1;
/* "View.MemoryView":904
* cdef int ndim = memslice.memview.view.ndim
*
* cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<<
* cdef Py_ssize_t *strides = memslice.strides
*
*/
__pyx_t_2 = __pyx_v_memslice->shape;
__pyx_v_shape = __pyx_t_2;
/* "View.MemoryView":905
*
* cdef Py_ssize_t *shape = memslice.shape
* cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = __pyx_v_memslice->strides;
__pyx_v_strides = __pyx_t_2;
/* "View.MemoryView":909
*
* cdef int i, j
* for i in range(ndim / 2): # <<<<<<<<<<<<<<
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i]
*/
__pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":910
* cdef int i, j
* for i in range(ndim / 2):
* j = ndim - 1 - i # <<<<<<<<<<<<<<
* strides[i], strides[j] = strides[j], strides[i]
* shape[i], shape[j] = shape[j], shape[i]
*/
__pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
/* "View.MemoryView":911
* for i in range(ndim / 2):
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<<
* shape[i], shape[j] = shape[j], shape[i]
*
*/
__pyx_t_4 = (__pyx_v_strides[__pyx_v_j]);
__pyx_t_5 = (__pyx_v_strides[__pyx_v_i]);
(__pyx_v_strides[__pyx_v_i]) = __pyx_t_4;
(__pyx_v_strides[__pyx_v_j]) = __pyx_t_5;
/* "View.MemoryView":912
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i]
* shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<<
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
*/
__pyx_t_5 = (__pyx_v_shape[__pyx_v_j]);
__pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
(__pyx_v_shape[__pyx_v_i]) = __pyx_t_5;
(__pyx_v_shape[__pyx_v_j]) = __pyx_t_4;
/* "View.MemoryView":914
* shape[i], shape[j] = shape[j], shape[i]
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
*/
__pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
if (!__pyx_t_7) {
} else {
__pyx_t_6 = __pyx_t_7;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
__pyx_t_6 = __pyx_t_7;
__pyx_L6_bool_binop_done:;
if (__pyx_t_6) {
/* "View.MemoryView":915
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<<
*
* return 1
*/
__pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, __pyx_k_Cannot_transpose_memoryview_with); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":914
* shape[i], shape[j] = shape[j], shape[i]
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
*/
}
}
/* "View.MemoryView":917
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
* return 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 1;
goto __pyx_L0;
/* "View.MemoryView":901
*
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
* cdef int ndim = memslice.memview.view.ndim
*
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":934
* cdef int (*to_dtype_func)(char *, object) except 0
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
*/
/* Python wrapper */
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":935
*
* def __dealloc__(self):
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<<
*
* cdef convert_item_to_object(self, char *itemp):
*/
__PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
/* "View.MemoryView":934
* cdef int (*to_dtype_func)(char *, object) except 0
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":937
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* if self.to_object_func != NULL:
* return self.to_object_func(itemp)
*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":938
*
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL: # <<<<<<<<<<<<<<
* return self.to_object_func(itemp)
* else:
*/
__pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":939
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL:
* return self.to_object_func(itemp) # <<<<<<<<<<<<<<
* else:
* return memoryview.convert_item_to_object(self, itemp)
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":938
*
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL: # <<<<<<<<<<<<<<
* return self.to_object_func(itemp)
* else:
*/
}
/* "View.MemoryView":941
* return self.to_object_func(itemp)
* else:
* return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<<
*
* cdef assign_item_from_object(self, char *itemp, object value):
*/
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":937
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* if self.to_object_func != NULL:
* return self.to_object_func(itemp)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":943
* return memoryview.convert_item_to_object(self, itemp)
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value)
*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":944
*
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
* self.to_dtype_func(itemp, value)
* else:
*/
__pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":945
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<<
* else:
* memoryview.assign_item_from_object(self, itemp, value)
*/
__pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":944
*
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
* self.to_dtype_func(itemp, value)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":947
* self.to_dtype_func(itemp, value)
* else:
* memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<<
*
* property base:
*/
/*else*/ {
__pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_L3:;
/* "View.MemoryView":943
* return memoryview.convert_item_to_object(self, itemp)
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value)
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":951
* property base:
* @cname('__pyx_memoryviewslice__get__base')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":952
* @cname('__pyx_memoryviewslice__get__base')
* def __get__(self):
* return self.from_object # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->from_object);
__pyx_r = __pyx_v_self->from_object;
goto __pyx_L0;
/* "View.MemoryView":951
* property base:
* @cname('__pyx_memoryviewslice__get__base')
* def __get__(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":958
*
* @cname('__pyx_memoryview_fromslice')
* cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
* int ndim,
* object (*to_object_func)(char *),
*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_v_length = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
__Pyx_TypeInfo *__pyx_t_4;
Py_buffer __pyx_t_5;
Py_ssize_t *__pyx_t_6;
Py_ssize_t *__pyx_t_7;
Py_ssize_t *__pyx_t_8;
Py_ssize_t __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_fromslice", 0);
/* "View.MemoryView":966
* cdef _memoryviewslice result
*
* if <PyObject *> memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
* return None
*
*/
__pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":967
*
* if <PyObject *> memviewslice.memview == Py_None:
* return None # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_None);
__pyx_r = Py_None;
goto __pyx_L0;
/* "View.MemoryView":966
* cdef _memoryviewslice result
*
* if <PyObject *> memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
* return None
*
*/
}
/* "View.MemoryView":972
*
*
* result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<<
*
* result.from_slice = memviewslice
*/
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
__Pyx_INCREF(__pyx_int_0);
__Pyx_GIVEREF(__pyx_int_0);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":974
* result = _memoryviewslice(None, 0, dtype_is_object)
*
* result.from_slice = memviewslice # <<<<<<<<<<<<<<
* __PYX_INC_MEMVIEW(&memviewslice, 1)
*
*/
__pyx_v_result->from_slice = __pyx_v_memviewslice;
/* "View.MemoryView":975
*
* result.from_slice = memviewslice
* __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<<
*
* result.from_object = (<memoryview> memviewslice.memview).base
*/
__PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
/* "View.MemoryView":977
* __PYX_INC_MEMVIEW(&memviewslice, 1)
*
* result.from_object = (<memoryview> memviewslice.memview).base # <<<<<<<<<<<<<<
* result.typeinfo = memviewslice.memview.typeinfo
*
*/
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__Pyx_GOTREF(__pyx_v_result->from_object);
__Pyx_DECREF(__pyx_v_result->from_object);
__pyx_v_result->from_object = __pyx_t_2;
__pyx_t_2 = 0;
/* "View.MemoryView":978
*
* result.from_object = (<memoryview> memviewslice.memview).base
* result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<<
*
* result.view = memviewslice.memview.view
*/
__pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
__pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
/* "View.MemoryView":980
* result.typeinfo = memviewslice.memview.typeinfo
*
* result.view = memviewslice.memview.view # <<<<<<<<<<<<<<
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim
*/
__pyx_t_5 = __pyx_v_memviewslice.memview->view;
__pyx_v_result->__pyx_base.view = __pyx_t_5;
/* "View.MemoryView":981
*
* result.view = memviewslice.memview.view
* result.view.buf = <void *> memviewslice.data # <<<<<<<<<<<<<<
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None
*/
__pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
/* "View.MemoryView":982
* result.view = memviewslice.memview.view
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &result.view).obj = Py_None
* Py_INCREF(Py_None)
*/
__pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
/* "View.MemoryView":983
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
/* "View.MemoryView":984
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* result.flags = PyBUF_RECORDS
*/
Py_INCREF(Py_None);
/* "View.MemoryView":986
* Py_INCREF(Py_None)
*
* result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<<
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape
*/
__pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
/* "View.MemoryView":988
* result.flags = PyBUF_RECORDS
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape # <<<<<<<<<<<<<<
* result.view.strides = <Py_ssize_t *> result.from_slice.strides
*
*/
__pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
/* "View.MemoryView":989
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape
* result.view.strides = <Py_ssize_t *> result.from_slice.strides # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
/* "View.MemoryView":992
*
*
* result.view.suboffsets = NULL # <<<<<<<<<<<<<<
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0:
*/
__pyx_v_result->__pyx_base.view.suboffsets = NULL;
/* "View.MemoryView":993
*
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<<
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
*/
__pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
__pyx_t_6 = __pyx_t_8;
__pyx_v_suboffset = (__pyx_t_6[0]);
/* "View.MemoryView":994
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break
*/
__pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":995
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
/* "View.MemoryView":996
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break # <<<<<<<<<<<<<<
*
* result.view.len = result.view.itemsize
*/
goto __pyx_L5_break;
/* "View.MemoryView":994
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break
*/
}
}
__pyx_L5_break:;
/* "View.MemoryView":998
* break
*
* result.view.len = result.view.itemsize # <<<<<<<<<<<<<<
* for length in result.view.shape[:ndim]:
* result.view.len *= length
*/
__pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
__pyx_v_result->__pyx_base.view.len = __pyx_t_9;
/* "View.MemoryView":999
*
* result.view.len = result.view.itemsize
* for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<<
* result.view.len *= length
*
*/
__pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
__pyx_t_6 = __pyx_t_8;
__pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":1000
* result.view.len = result.view.itemsize
* for length in result.view.shape[:ndim]:
* result.view.len *= length # <<<<<<<<<<<<<<
*
* result.to_object_func = to_object_func
*/
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result->__pyx_base.view.len = __pyx_t_9;
}
/* "View.MemoryView":1002
* result.view.len *= length
*
* result.to_object_func = to_object_func # <<<<<<<<<<<<<<
* result.to_dtype_func = to_dtype_func
*
*/
__pyx_v_result->to_object_func = __pyx_v_to_object_func;
/* "View.MemoryView":1003
*
* result.to_object_func = to_object_func
* result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<<
*
* return result
*/
__pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
/* "View.MemoryView":1005
* result.to_dtype_func = to_dtype_func
*
* return result # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":958
*
* @cname('__pyx_memoryview_fromslice')
* cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
* int ndim,
* object (*to_object_func)(char *),
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XDECREF(__pyx_v_length);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1008
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
* cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *mslice):
* cdef _memoryviewslice obj
*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
__Pyx_memviewslice *__pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("get_slice_from_memview", 0);
/* "View.MemoryView":1011
* __Pyx_memviewslice *mslice):
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* obj = memview
* return &obj.from_slice
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1012
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice):
* obj = memview # <<<<<<<<<<<<<<
* return &obj.from_slice
* else:
*/
if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = ((PyObject *)__pyx_v_memview);
__Pyx_INCREF(__pyx_t_3);
__pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":1013
* if isinstance(memview, _memoryviewslice):
* obj = memview
* return &obj.from_slice # <<<<<<<<<<<<<<
* else:
* slice_copy(memview, mslice)
*/
__pyx_r = (&__pyx_v_obj->from_slice);
goto __pyx_L0;
/* "View.MemoryView":1011
* __Pyx_memviewslice *mslice):
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* obj = memview
* return &obj.from_slice
*/
}
/* "View.MemoryView":1015
* return &obj.from_slice
* else:
* slice_copy(memview, mslice) # <<<<<<<<<<<<<<
* return mslice
*
*/
/*else*/ {
__pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
/* "View.MemoryView":1016
* else:
* slice_copy(memview, mslice)
* return mslice # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_slice_copy')
*/
__pyx_r = __pyx_v_mslice;
goto __pyx_L0;
}
/* "View.MemoryView":1008
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
* cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *mslice):
* cdef _memoryviewslice obj
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_obj);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1019
*
* @cname('__pyx_memoryview_slice_copy')
* cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
* cdef int dim
* cdef (Py_ssize_t*) shape, strides, suboffsets
*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
int __pyx_v_dim;
Py_ssize_t *__pyx_v_shape;
Py_ssize_t *__pyx_v_strides;
Py_ssize_t *__pyx_v_suboffsets;
__Pyx_RefNannyDeclarations
Py_ssize_t *__pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
Py_ssize_t __pyx_t_4;
__Pyx_RefNannySetupContext("slice_copy", 0);
/* "View.MemoryView":1023
* cdef (Py_ssize_t*) shape, strides, suboffsets
*
* shape = memview.view.shape # <<<<<<<<<<<<<<
* strides = memview.view.strides
* suboffsets = memview.view.suboffsets
*/
__pyx_t_1 = __pyx_v_memview->view.shape;
__pyx_v_shape = __pyx_t_1;
/* "View.MemoryView":1024
*
* shape = memview.view.shape
* strides = memview.view.strides # <<<<<<<<<<<<<<
* suboffsets = memview.view.suboffsets
*
*/
__pyx_t_1 = __pyx_v_memview->view.strides;
__pyx_v_strides = __pyx_t_1;
/* "View.MemoryView":1025
* shape = memview.view.shape
* strides = memview.view.strides
* suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<<
*
* dst.memview = <__pyx_memoryview *> memview
*/
__pyx_t_1 = __pyx_v_memview->view.suboffsets;
__pyx_v_suboffsets = __pyx_t_1;
/* "View.MemoryView":1027
* suboffsets = memview.view.suboffsets
*
* dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<<
* dst.data = <char *> memview.view.buf
*
*/
__pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
/* "View.MemoryView":1028
*
* dst.memview = <__pyx_memoryview *> memview
* dst.data = <char *> memview.view.buf # <<<<<<<<<<<<<<
*
* for dim in range(memview.view.ndim):
*/
__pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
/* "View.MemoryView":1030
* dst.data = <char *> memview.view.buf
*
* for dim in range(memview.view.ndim): # <<<<<<<<<<<<<<
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim]
*/
__pyx_t_2 = __pyx_v_memview->view.ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_dim = __pyx_t_3;
/* "View.MemoryView":1031
*
* for dim in range(memview.view.ndim):
* dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<<
* dst.strides[dim] = strides[dim]
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
*/
(__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
/* "View.MemoryView":1032
* for dim in range(memview.view.ndim):
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<<
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
*
*/
(__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
/* "View.MemoryView":1033
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim]
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_object')
*/
if ((__pyx_v_suboffsets != 0)) {
__pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]);
} else {
__pyx_t_4 = -1L;
}
(__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4;
}
/* "View.MemoryView":1019
*
* @cname('__pyx_memoryview_slice_copy')
* cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
* cdef int dim
* cdef (Py_ssize_t*) shape, strides, suboffsets
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":1036
*
* @cname('__pyx_memoryview_copy_object')
* cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
__Pyx_memviewslice __pyx_v_memviewslice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_copy", 0);
/* "View.MemoryView":1039
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
* slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<<
* return memoryview_copy_from_slice(memview, &memviewslice)
*
*/
__pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
/* "View.MemoryView":1040
* cdef __Pyx_memviewslice memviewslice
* slice_copy(memview, &memviewslice)
* return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_object_from_slice')
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":1036
*
* @cname('__pyx_memoryview_copy_object')
* cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1043
*
* @cname('__pyx_memoryview_copy_object_from_slice')
* cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
* """
* Create a new memoryview object from a given memoryview object and slice.
*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
PyObject *(*__pyx_v_to_object_func)(char *);
int (*__pyx_v_to_dtype_func)(char *, PyObject *);
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *(*__pyx_t_3)(char *);
int (*__pyx_t_4)(char *, PyObject *);
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
/* "View.MemoryView":1050
* cdef int (*to_dtype_func)(char *, object) except 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1051
*
* if isinstance(memview, _memoryviewslice):
* to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<<
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
* else:
*/
__pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
__pyx_v_to_object_func = __pyx_t_3;
/* "View.MemoryView":1052
* if isinstance(memview, _memoryviewslice):
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<<
* else:
* to_object_func = NULL
*/
__pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
__pyx_v_to_dtype_func = __pyx_t_4;
/* "View.MemoryView":1050
* cdef int (*to_dtype_func)(char *, object) except 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
*/
goto __pyx_L3;
}
/* "View.MemoryView":1054
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
* else:
* to_object_func = NULL # <<<<<<<<<<<<<<
* to_dtype_func = NULL
*
*/
/*else*/ {
__pyx_v_to_object_func = NULL;
/* "View.MemoryView":1055
* else:
* to_object_func = NULL
* to_dtype_func = NULL # <<<<<<<<<<<<<<
*
* return memoryview_fromslice(memviewslice[0], memview.view.ndim,
*/
__pyx_v_to_dtype_func = NULL;
}
__pyx_L3:;
/* "View.MemoryView":1057
* to_dtype_func = NULL
*
* return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<<
* to_object_func, to_dtype_func,
* memview.dtype_is_object)
*/
__Pyx_XDECREF(__pyx_r);
/* "View.MemoryView":1059
* return memoryview_fromslice(memviewslice[0], memview.view.ndim,
* to_object_func, to_dtype_func,
* memview.dtype_is_object) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "View.MemoryView":1043
*
* @cname('__pyx_memoryview_copy_object_from_slice')
* cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
* """
* Create a new memoryview object from a given memoryview object and slice.
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1065
*
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
* if arg < 0:
* return -arg
*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
Py_ssize_t __pyx_r;
int __pyx_t_1;
/* "View.MemoryView":1066
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0: # <<<<<<<<<<<<<<
* return -arg
* else:
*/
__pyx_t_1 = ((__pyx_v_arg < 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1067
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0:
* return -arg # <<<<<<<<<<<<<<
* else:
* return arg
*/
__pyx_r = (-__pyx_v_arg);
goto __pyx_L0;
/* "View.MemoryView":1066
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0: # <<<<<<<<<<<<<<
* return -arg
* else:
*/
}
/* "View.MemoryView":1069
* return -arg
* else:
* return arg # <<<<<<<<<<<<<<
*
* @cname('__pyx_get_best_slice_order')
*/
/*else*/ {
__pyx_r = __pyx_v_arg;
goto __pyx_L0;
}
/* "View.MemoryView":1065
*
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
* if arg < 0:
* return -arg
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1072
*
* @cname('__pyx_get_best_slice_order')
* cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
* """
* Figure out the best memory access order for a given slice.
*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
int __pyx_v_i;
Py_ssize_t __pyx_v_c_stride;
Py_ssize_t __pyx_v_f_stride;
char __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
/* "View.MemoryView":1077
* """
* cdef int i
* cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<<
* cdef Py_ssize_t f_stride = 0
*
*/
__pyx_v_c_stride = 0;
/* "View.MemoryView":1078
* cdef int i
* cdef Py_ssize_t c_stride = 0
* cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<<
*
* for i in range(ndim - 1, -1, -1):
*/
__pyx_v_f_stride = 0;
/* "View.MemoryView":1080
* cdef Py_ssize_t f_stride = 0
*
* for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i]
*/
for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1081
*
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* c_stride = mslice.strides[i]
* break
*/
__pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1082
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i] # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1083
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i]
* break # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
goto __pyx_L4_break;
/* "View.MemoryView":1081
*
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* c_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L4_break:;
/* "View.MemoryView":1085
* break
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i]
*/
__pyx_t_1 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1086
*
* for i in range(ndim):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* f_stride = mslice.strides[i]
* break
*/
__pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1087
* for i in range(ndim):
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i] # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1088
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i]
* break # <<<<<<<<<<<<<<
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
*/
goto __pyx_L7_break;
/* "View.MemoryView":1086
*
* for i in range(ndim):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* f_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L7_break:;
/* "View.MemoryView":1090
* break
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
* return 'C'
* else:
*/
__pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1091
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
* return 'C' # <<<<<<<<<<<<<<
* else:
* return 'F'
*/
__pyx_r = 'C';
goto __pyx_L0;
/* "View.MemoryView":1090
* break
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
* return 'C'
* else:
*/
}
/* "View.MemoryView":1093
* return 'C'
* else:
* return 'F' # <<<<<<<<<<<<<<
*
* @cython.cdivision(True)
*/
/*else*/ {
__pyx_r = 'F';
goto __pyx_L0;
}
/* "View.MemoryView":1072
*
* @cname('__pyx_get_best_slice_order')
* cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
* """
* Figure out the best memory access order for a given slice.
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1096
*
* @cython.cdivision(True)
* cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
* char *dst_data, Py_ssize_t *dst_strides,
* Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
*/
static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
Py_ssize_t __pyx_v_dst_extent;
Py_ssize_t __pyx_v_src_stride;
Py_ssize_t __pyx_v_dst_stride;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
Py_ssize_t __pyx_t_4;
Py_ssize_t __pyx_t_5;
/* "View.MemoryView":1103
*
* cdef Py_ssize_t i
* cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0]
*/
__pyx_v_src_extent = (__pyx_v_src_shape[0]);
/* "View.MemoryView":1104
* cdef Py_ssize_t i
* cdef Py_ssize_t src_extent = src_shape[0]
* cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t src_stride = src_strides[0]
* cdef Py_ssize_t dst_stride = dst_strides[0]
*/
__pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
/* "View.MemoryView":1105
* cdef Py_ssize_t src_extent = src_shape[0]
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
*/
__pyx_v_src_stride = (__pyx_v_src_strides[0]);
/* "View.MemoryView":1106
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0]
* cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<<
*
* if ndim == 1:
*/
__pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
/* "View.MemoryView":1108
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
*/
__pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1109
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
__pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L5_bool_binop_done;
}
__pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L5_bool_binop_done;
}
/* "View.MemoryView":1110
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride): # <<<<<<<<<<<<<<
* memcpy(dst_data, src_data, itemsize * dst_extent)
* else:
*/
__pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
if (__pyx_t_2) {
__pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
}
__pyx_t_3 = (__pyx_t_2 != 0);
__pyx_t_1 = __pyx_t_3;
__pyx_L5_bool_binop_done:;
/* "View.MemoryView":1109
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
if (__pyx_t_1) {
/* "View.MemoryView":1111
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<<
* else:
* for i in range(dst_extent):
*/
memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent));
/* "View.MemoryView":1109
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
goto __pyx_L4;
}
/* "View.MemoryView":1113
* memcpy(dst_data, src_data, itemsize * dst_extent)
* else:
* for i in range(dst_extent): # <<<<<<<<<<<<<<
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride
*/
/*else*/ {
__pyx_t_4 = __pyx_v_dst_extent;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":1114
* else:
* for i in range(dst_extent):
* memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<<
* src_data += src_stride
* dst_data += dst_stride
*/
memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize);
/* "View.MemoryView":1115
* for i in range(dst_extent):
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride # <<<<<<<<<<<<<<
* dst_data += dst_stride
* else:
*/
__pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
/* "View.MemoryView":1116
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride
* dst_data += dst_stride # <<<<<<<<<<<<<<
* else:
* for i in range(dst_extent):
*/
__pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
}
}
__pyx_L4:;
/* "View.MemoryView":1108
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
*/
goto __pyx_L3;
}
/* "View.MemoryView":1118
* dst_data += dst_stride
* else:
* for i in range(dst_extent): # <<<<<<<<<<<<<<
* _copy_strided_to_strided(src_data, src_strides + 1,
* dst_data, dst_strides + 1,
*/
/*else*/ {
__pyx_t_4 = __pyx_v_dst_extent;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":1119
* else:
* for i in range(dst_extent):
* _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<<
* dst_data, dst_strides + 1,
* src_shape + 1, dst_shape + 1,
*/
_copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);
/* "View.MemoryView":1123
* src_shape + 1, dst_shape + 1,
* ndim - 1, itemsize)
* src_data += src_stride # <<<<<<<<<<<<<<
* dst_data += dst_stride
*
*/
__pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
/* "View.MemoryView":1124
* ndim - 1, itemsize)
* src_data += src_stride
* dst_data += dst_stride # <<<<<<<<<<<<<<
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
*/
__pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
}
}
__pyx_L3:;
/* "View.MemoryView":1096
*
* @cython.cdivision(True)
* cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
* char *dst_data, Py_ssize_t *dst_strides,
* Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
*/
/* function exit code */
}
/* "View.MemoryView":1126
* dst_data += dst_stride
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
*/
static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
/* "View.MemoryView":1129
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
* _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<<
* src.shape, dst.shape, ndim, itemsize)
*
*/
_copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);
/* "View.MemoryView":1126
* dst_data += dst_stride
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1133
*
* @cname('__pyx_memoryview_slice_get_size')
* cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef int i
*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
int __pyx_v_i;
Py_ssize_t __pyx_v_size;
Py_ssize_t __pyx_r;
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
/* "View.MemoryView":1136
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef int i
* cdef Py_ssize_t size = src.memview.view.itemsize # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
__pyx_t_1 = __pyx_v_src->memview->view.itemsize;
__pyx_v_size = __pyx_t_1;
/* "View.MemoryView":1138
* cdef Py_ssize_t size = src.memview.view.itemsize
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* size *= src.shape[i]
*
*/
__pyx_t_2 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1139
*
* for i in range(ndim):
* size *= src.shape[i] # <<<<<<<<<<<<<<
*
* return size
*/
__pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i]));
}
/* "View.MemoryView":1141
* size *= src.shape[i]
*
* return size # <<<<<<<<<<<<<<
*
* @cname('__pyx_fill_contig_strides_array')
*/
__pyx_r = __pyx_v_size;
goto __pyx_L0;
/* "View.MemoryView":1133
*
* @cname('__pyx_memoryview_slice_get_size')
* cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef int i
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1144
*
* @cname('__pyx_fill_contig_strides_array')
* cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
* Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
* int ndim, char order) nogil:
*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
int __pyx_v_idx;
Py_ssize_t __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
/* "View.MemoryView":1153
* cdef int idx
*
* if order == 'F': # <<<<<<<<<<<<<<
* for idx in range(ndim):
* strides[idx] = stride
*/
__pyx_t_1 = ((__pyx_v_order == 'F') != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1154
*
* if order == 'F':
* for idx in range(ndim): # <<<<<<<<<<<<<<
* strides[idx] = stride
* stride = stride * shape[idx]
*/
__pyx_t_2 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_idx = __pyx_t_3;
/* "View.MemoryView":1155
* if order == 'F':
* for idx in range(ndim):
* strides[idx] = stride # <<<<<<<<<<<<<<
* stride = stride * shape[idx]
* else:
*/
(__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
/* "View.MemoryView":1156
* for idx in range(ndim):
* strides[idx] = stride
* stride = stride * shape[idx] # <<<<<<<<<<<<<<
* else:
* for idx in range(ndim - 1, -1, -1):
*/
__pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
}
/* "View.MemoryView":1153
* cdef int idx
*
* if order == 'F': # <<<<<<<<<<<<<<
* for idx in range(ndim):
* strides[idx] = stride
*/
goto __pyx_L3;
}
/* "View.MemoryView":1158
* stride = stride * shape[idx]
* else:
* for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* strides[idx] = stride
* stride = stride * shape[idx]
*/
/*else*/ {
for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) {
__pyx_v_idx = __pyx_t_2;
/* "View.MemoryView":1159
* else:
* for idx in range(ndim - 1, -1, -1):
* strides[idx] = stride # <<<<<<<<<<<<<<
* stride = stride * shape[idx]
*
*/
(__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
/* "View.MemoryView":1160
* for idx in range(ndim - 1, -1, -1):
* strides[idx] = stride
* stride = stride * shape[idx] # <<<<<<<<<<<<<<
*
* return stride
*/
__pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
}
}
__pyx_L3:;
/* "View.MemoryView":1162
* stride = stride * shape[idx]
*
* return stride # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_data_to_temp')
*/
__pyx_r = __pyx_v_stride;
goto __pyx_L0;
/* "View.MemoryView":1144
*
* @cname('__pyx_fill_contig_strides_array')
* cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
* Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
* int ndim, char order) nogil:
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1165
*
* @cname('__pyx_memoryview_copy_data_to_temp')
* cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *tmpslice,
* char order,
*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
int __pyx_v_i;
void *__pyx_v_result;
size_t __pyx_v_itemsize;
size_t __pyx_v_size;
void *__pyx_r;
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
struct __pyx_memoryview_obj *__pyx_t_4;
int __pyx_t_5;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":1176
* cdef void *result
*
* cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
* cdef size_t size = slice_get_size(src, ndim)
*
*/
__pyx_t_1 = __pyx_v_src->memview->view.itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":1177
*
* cdef size_t itemsize = src.memview.view.itemsize
* cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<<
*
* result = malloc(size)
*/
__pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
/* "View.MemoryView":1179
* cdef size_t size = slice_get_size(src, ndim)
*
* result = malloc(size) # <<<<<<<<<<<<<<
* if not result:
* _err(MemoryError, NULL)
*/
__pyx_v_result = malloc(__pyx_v_size);
/* "View.MemoryView":1180
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
__pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1181
* result = malloc(size)
* if not result:
* _err(MemoryError, NULL) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1180
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
}
/* "View.MemoryView":1184
*
*
* tmpslice.data = <char *> result # <<<<<<<<<<<<<<
* tmpslice.memview = src.memview
* for i in range(ndim):
*/
__pyx_v_tmpslice->data = ((char *)__pyx_v_result);
/* "View.MemoryView":1185
*
* tmpslice.data = <char *> result
* tmpslice.memview = src.memview # <<<<<<<<<<<<<<
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i]
*/
__pyx_t_4 = __pyx_v_src->memview;
__pyx_v_tmpslice->memview = __pyx_t_4;
/* "View.MemoryView":1186
* tmpslice.data = <char *> result
* tmpslice.memview = src.memview
* for i in range(ndim): # <<<<<<<<<<<<<<
* tmpslice.shape[i] = src.shape[i]
* tmpslice.suboffsets[i] = -1
*/
__pyx_t_3 = __pyx_v_ndim;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":1187
* tmpslice.memview = src.memview
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<<
* tmpslice.suboffsets[i] = -1
*
*/
(__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
/* "View.MemoryView":1188
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i]
* tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
*
* fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
*/
(__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
}
/* "View.MemoryView":1190
* tmpslice.suboffsets[i] = -1
*
* fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<<
* ndim, order)
*
*/
__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order);
/* "View.MemoryView":1194
*
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0
*/
__pyx_t_3 = __pyx_v_ndim;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":1195
*
* for i in range(ndim):
* if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
* tmpslice.strides[i] = 0
*
*/
__pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1196
* for i in range(ndim):
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0 # <<<<<<<<<<<<<<
*
* if slice_is_contig(src, order, ndim):
*/
(__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
/* "View.MemoryView":1195
*
* for i in range(ndim):
* if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
* tmpslice.strides[i] = 0
*
*/
}
}
/* "View.MemoryView":1198
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1199
*
* if slice_is_contig(src, order, ndim):
* memcpy(result, src.data, size) # <<<<<<<<<<<<<<
* else:
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*/
memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size);
/* "View.MemoryView":1198
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
goto __pyx_L9;
}
/* "View.MemoryView":1201
* memcpy(result, src.data, size)
* else:
* copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<<
*
* return result
*/
/*else*/ {
copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
}
__pyx_L9:;
/* "View.MemoryView":1203
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*
* return result # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
/* "View.MemoryView":1165
*
* @cname('__pyx_memoryview_copy_data_to_temp')
* cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *tmpslice,
* char order,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = NULL;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1208
*
* @cname('__pyx_memoryview_err_extents')
* cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
*/
static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_extents", 0);
/* "View.MemoryView":1211
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
* (i, extent1, extent2)) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_err_dim')
*/
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_3 = 0;
/* "View.MemoryView":1210
* cdef int _err_extents(int i, Py_ssize_t extent1,
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<<
* (i, extent1, extent2))
*
*/
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1208
*
* @cname('__pyx_memoryview_err_extents')
* cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1214
*
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii') % dim)
*
*/
static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_dim", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1215
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
* raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_err')
*/
__pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_INCREF(__pyx_v_error);
__pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_2)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
}
}
if (!__pyx_t_2) {
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_GOTREF(__pyx_t_1);
} else {
__pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1214
*
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii') % dim)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1218
*
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
* if msg != NULL:
* raise error(msg.decode('ascii'))
*/
static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1219
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii'))
* else:
*/
__pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1220
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL:
* raise error(msg.decode('ascii')) # <<<<<<<<<<<<<<
* else:
* raise error
*/
__pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_error);
__pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
}
}
if (!__pyx_t_5) {
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_GOTREF(__pyx_t_2);
} else {
__pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1219
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii'))
* else:
*/
}
/* "View.MemoryView":1222
* raise error(msg.decode('ascii'))
* else:
* raise error # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_contents')
*/
/*else*/ {
__Pyx_Raise(__pyx_v_error, 0, 0, 0);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
/* "View.MemoryView":1218
*
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
* if msg != NULL:
* raise error(msg.decode('ascii'))
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1225
*
* @cname('__pyx_memoryview_copy_contents')
* cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice dst,
* int src_ndim, int dst_ndim,
*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
void *__pyx_v_tmpdata;
size_t __pyx_v_itemsize;
int __pyx_v_i;
char __pyx_v_order;
int __pyx_v_broadcasting;
int __pyx_v_direct_copy;
__Pyx_memviewslice __pyx_v_tmp;
int __pyx_v_ndim;
int __pyx_r;
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
void *__pyx_t_6;
int __pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":1233
* Check for overlapping memory and verify the shapes.
* """
* cdef void *tmpdata = NULL # <<<<<<<<<<<<<<
* cdef size_t itemsize = src.memview.view.itemsize
* cdef int i
*/
__pyx_v_tmpdata = NULL;
/* "View.MemoryView":1234
* """
* cdef void *tmpdata = NULL
* cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
* cdef int i
* cdef char order = get_best_order(&src, src_ndim)
*/
__pyx_t_1 = __pyx_v_src.memview->view.itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":1236
* cdef size_t itemsize = src.memview.view.itemsize
* cdef int i
* cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<<
* cdef bint broadcasting = False
* cdef bint direct_copy = False
*/
__pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
/* "View.MemoryView":1237
* cdef int i
* cdef char order = get_best_order(&src, src_ndim)
* cdef bint broadcasting = False # <<<<<<<<<<<<<<
* cdef bint direct_copy = False
* cdef __Pyx_memviewslice tmp
*/
__pyx_v_broadcasting = 0;
/* "View.MemoryView":1238
* cdef char order = get_best_order(&src, src_ndim)
* cdef bint broadcasting = False
* cdef bint direct_copy = False # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice tmp
*
*/
__pyx_v_direct_copy = 0;
/* "View.MemoryView":1241
* cdef __Pyx_memviewslice tmp
*
* if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
*/
__pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1242
*
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<<
* elif dst_ndim < src_ndim:
* broadcast_leading(&dst, dst_ndim, src_ndim)
*/
__pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
/* "View.MemoryView":1241
* cdef __Pyx_memviewslice tmp
*
* if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
*/
goto __pyx_L3;
}
/* "View.MemoryView":1243
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
*/
__pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1244
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
* broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<<
*
* cdef int ndim = max(src_ndim, dst_ndim)
*/
__pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
/* "View.MemoryView":1243
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
*/
}
__pyx_L3:;
/* "View.MemoryView":1246
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
* cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
__pyx_t_3 = __pyx_v_dst_ndim;
__pyx_t_4 = __pyx_v_src_ndim;
if (((__pyx_t_3 > __pyx_t_4) != 0)) {
__pyx_t_5 = __pyx_t_3;
} else {
__pyx_t_5 = __pyx_t_4;
}
__pyx_v_ndim = __pyx_t_5;
/* "View.MemoryView":1248
* cdef int ndim = max(src_ndim, dst_ndim)
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1:
*/
__pyx_t_5 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1249
*
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
* if src.shape[i] == 1:
* broadcasting = True
*/
__pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1250
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1: # <<<<<<<<<<<<<<
* broadcasting = True
* src.strides[i] = 0
*/
__pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1251
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1:
* broadcasting = True # <<<<<<<<<<<<<<
* src.strides[i] = 0
* else:
*/
__pyx_v_broadcasting = 1;
/* "View.MemoryView":1252
* if src.shape[i] == 1:
* broadcasting = True
* src.strides[i] = 0 # <<<<<<<<<<<<<<
* else:
* _err_extents(i, dst.shape[i], src.shape[i])
*/
(__pyx_v_src.strides[__pyx_v_i]) = 0;
/* "View.MemoryView":1250
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1: # <<<<<<<<<<<<<<
* broadcasting = True
* src.strides[i] = 0
*/
goto __pyx_L7;
}
/* "View.MemoryView":1254
* src.strides[i] = 0
* else:
* _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<<
*
* if src.suboffsets[i] >= 0:
*/
/*else*/ {
__pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L7:;
/* "View.MemoryView":1249
*
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
* if src.shape[i] == 1:
* broadcasting = True
*/
}
/* "View.MemoryView":1256
* _err_extents(i, dst.shape[i], src.shape[i])
*
* if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
*/
__pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1257
*
* if src.suboffsets[i] >= 0:
* _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<<
*
* if slices_overlap(&src, &dst, ndim, itemsize):
*/
__pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Dimension_d_is_not_direct, __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1256
* _err_extents(i, dst.shape[i], src.shape[i])
*
* if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
*/
}
}
/* "View.MemoryView":1259
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
* if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
*
* if not slice_is_contig(&src, order, ndim):
*/
__pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1261
* if slices_overlap(&src, &dst, ndim, itemsize):
*
* if not slice_is_contig(&src, order, ndim): # <<<<<<<<<<<<<<
* order = get_best_order(&dst, ndim)
*
*/
__pyx_t_2 = ((!(__pyx_memviewslice_is_contig((&__pyx_v_src), __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1262
*
* if not slice_is_contig(&src, order, ndim):
* order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<<
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
*/
__pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
/* "View.MemoryView":1261
* if slices_overlap(&src, &dst, ndim, itemsize):
*
* if not slice_is_contig(&src, order, ndim): # <<<<<<<<<<<<<<
* order = get_best_order(&dst, ndim)
*
*/
}
/* "View.MemoryView":1264
* order = get_best_order(&dst, ndim)
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<<
* src = tmp
*
*/
__pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_tmpdata = __pyx_t_6;
/* "View.MemoryView":1265
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
* src = tmp # <<<<<<<<<<<<<<
*
* if not broadcasting:
*/
__pyx_v_src = __pyx_v_tmp;
/* "View.MemoryView":1259
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
* if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
*
* if not slice_is_contig(&src, order, ndim):
*/
}
/* "View.MemoryView":1267
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1270
*
*
* if slice_is_contig(&src, 'C', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(&dst, 'C', ndim)
* elif slice_is_contig(&src, 'F', ndim):
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'C', __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1271
*
* if slice_is_contig(&src, 'C', ndim):
* direct_copy = slice_is_contig(&dst, 'C', ndim) # <<<<<<<<<<<<<<
* elif slice_is_contig(&src, 'F', ndim):
* direct_copy = slice_is_contig(&dst, 'F', ndim)
*/
__pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'C', __pyx_v_ndim);
/* "View.MemoryView":1270
*
*
* if slice_is_contig(&src, 'C', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(&dst, 'C', ndim)
* elif slice_is_contig(&src, 'F', ndim):
*/
goto __pyx_L12;
}
/* "View.MemoryView":1272
* if slice_is_contig(&src, 'C', ndim):
* direct_copy = slice_is_contig(&dst, 'C', ndim)
* elif slice_is_contig(&src, 'F', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(&dst, 'F', ndim)
*
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'F', __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1273
* direct_copy = slice_is_contig(&dst, 'C', ndim)
* elif slice_is_contig(&src, 'F', ndim):
* direct_copy = slice_is_contig(&dst, 'F', ndim) # <<<<<<<<<<<<<<
*
* if direct_copy:
*/
__pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'F', __pyx_v_ndim);
/* "View.MemoryView":1272
* if slice_is_contig(&src, 'C', ndim):
* direct_copy = slice_is_contig(&dst, 'C', ndim)
* elif slice_is_contig(&src, 'F', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(&dst, 'F', ndim)
*
*/
}
__pyx_L12:;
/* "View.MemoryView":1275
* direct_copy = slice_is_contig(&dst, 'F', ndim)
*
* if direct_copy: # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
__pyx_t_2 = (__pyx_v_direct_copy != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1277
* if direct_copy:
*
* refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1278
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
* memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<<
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata)
*/
memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim));
/* "View.MemoryView":1279
* refcount_copying(&dst, dtype_is_object, ndim, False)
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
* free(tmpdata)
* return 0
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1280
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata) # <<<<<<<<<<<<<<
* return 0
*
*/
free(__pyx_v_tmpdata);
/* "View.MemoryView":1281
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata)
* return 0 # <<<<<<<<<<<<<<
*
* if order == 'F' == get_best_order(&dst, ndim):
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":1275
* direct_copy = slice_is_contig(&dst, 'F', ndim)
*
* if direct_copy: # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
}
/* "View.MemoryView":1267
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1283
* return 0
*
* if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = (__pyx_v_order == 'F');
if (__pyx_t_2) {
__pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
}
__pyx_t_7 = (__pyx_t_2 != 0);
if (__pyx_t_7) {
/* "View.MemoryView":1286
*
*
* transpose_memslice(&src) # <<<<<<<<<<<<<<
* transpose_memslice(&dst)
*
*/
__pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1287
*
* transpose_memslice(&src)
* transpose_memslice(&dst) # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
__pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":1283
* return 0
*
* if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1289
* transpose_memslice(&dst)
*
* refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* copy_strided_to_strided(&src, &dst, ndim, itemsize)
* refcount_copying(&dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1290
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
* copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<<
* refcount_copying(&dst, dtype_is_object, ndim, True)
*
*/
copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
/* "View.MemoryView":1291
* refcount_copying(&dst, dtype_is_object, ndim, False)
* copy_strided_to_strided(&src, &dst, ndim, itemsize)
* refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
*
* free(tmpdata)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1293
* refcount_copying(&dst, dtype_is_object, ndim, True)
*
* free(tmpdata) # <<<<<<<<<<<<<<
* return 0
*
*/
free(__pyx_v_tmpdata);
/* "View.MemoryView":1294
*
* free(tmpdata)
* return 0 # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_broadcast_leading')
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":1225
*
* @cname('__pyx_memoryview_copy_contents')
* cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice dst,
* int src_ndim, int dst_ndim,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1297
*
* @cname('__pyx_memoryview_broadcast_leading')
* cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
* int ndim,
* int ndim_other) nogil:
*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
int __pyx_v_i;
int __pyx_v_offset;
int __pyx_t_1;
int __pyx_t_2;
/* "View.MemoryView":1301
* int ndim_other) nogil:
* cdef int i
* cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<<
*
* for i in range(ndim - 1, -1, -1):
*/
__pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
/* "View.MemoryView":1303
* cdef int offset = ndim_other - ndim
*
* for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i]
*/
for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1304
*
* for i in range(ndim - 1, -1, -1):
* mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<<
* mslice.strides[i + offset] = mslice.strides[i]
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*/
(__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
/* "View.MemoryView":1305
* for i in range(ndim - 1, -1, -1):
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<<
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*
*/
(__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1306
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i]
* mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<<
*
* for i in range(offset):
*/
(__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
}
/* "View.MemoryView":1308
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*
* for i in range(offset): # <<<<<<<<<<<<<<
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0]
*/
__pyx_t_1 = __pyx_v_offset;
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "View.MemoryView":1309
*
* for i in range(offset):
* mslice.shape[i] = 1 # <<<<<<<<<<<<<<
* mslice.strides[i] = mslice.strides[0]
* mslice.suboffsets[i] = -1
*/
(__pyx_v_mslice->shape[__pyx_v_i]) = 1;
/* "View.MemoryView":1310
* for i in range(offset):
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<<
* mslice.suboffsets[i] = -1
*
*/
(__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
/* "View.MemoryView":1311
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0]
* mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
*
*
*/
(__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
}
/* "View.MemoryView":1297
*
* @cname('__pyx_memoryview_broadcast_leading')
* cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
* int ndim,
* int ndim_other) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1319
*
* @cname('__pyx_memoryview_refcount_copying')
* cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
* int ndim, bint inc) nogil:
*
*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
int __pyx_t_1;
/* "View.MemoryView":1323
*
*
* if dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice_with_gil(dst.data, dst.shape,
* dst.strides, ndim, inc)
*/
__pyx_t_1 = (__pyx_v_dtype_is_object != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1324
*
* if dtype_is_object:
* refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<<
* dst.strides, ndim, inc)
*
*/
__pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);
/* "View.MemoryView":1323
*
*
* if dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice_with_gil(dst.data, dst.shape,
* dst.strides, ndim, inc)
*/
}
/* "View.MemoryView":1319
*
* @cname('__pyx_memoryview_refcount_copying')
* cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
* int ndim, bint inc) nogil:
*
*/
/* function exit code */
}
/* "View.MemoryView":1328
*
* @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
* cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
__Pyx_RefNannyDeclarations
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
/* "View.MemoryView":1331
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
* refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
/* "View.MemoryView":1328
*
* @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
* cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
PyGILState_Release(__pyx_gilstate_save);
#endif
}
/* "View.MemoryView":1334
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
* cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim, bint inc):
* cdef Py_ssize_t i
*/
static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
Py_ssize_t __pyx_t_2;
int __pyx_t_3;
__Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
/* "View.MemoryView":1338
* cdef Py_ssize_t i
*
* for i in range(shape[0]): # <<<<<<<<<<<<<<
* if ndim == 1:
* if inc:
*/
__pyx_t_1 = (__pyx_v_shape[0]);
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "View.MemoryView":1339
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
__pyx_t_3 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_3) {
/* "View.MemoryView":1340
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
__pyx_t_3 = (__pyx_v_inc != 0);
if (__pyx_t_3) {
/* "View.MemoryView":1341
* if ndim == 1:
* if inc:
* Py_INCREF((<PyObject **> data)[0]) # <<<<<<<<<<<<<<
* else:
* Py_DECREF((<PyObject **> data)[0])
*/
Py_INCREF((((PyObject **)__pyx_v_data)[0]));
/* "View.MemoryView":1340
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":1343
* Py_INCREF((<PyObject **> data)[0])
* else:
* Py_DECREF((<PyObject **> data)[0]) # <<<<<<<<<<<<<<
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1,
*/
/*else*/ {
Py_DECREF((((PyObject **)__pyx_v_data)[0]));
}
__pyx_L6:;
/* "View.MemoryView":1339
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
goto __pyx_L5;
}
/* "View.MemoryView":1345
* Py_DECREF((<PyObject **> data)[0])
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
* ndim - 1, inc)
*
*/
/*else*/ {
/* "View.MemoryView":1346
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1,
* ndim - 1, inc) # <<<<<<<<<<<<<<
*
* data += strides[0]
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
}
__pyx_L5:;
/* "View.MemoryView":1348
* ndim - 1, inc)
*
* data += strides[0] # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
}
/* "View.MemoryView":1334
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
* cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim, bint inc):
* cdef Py_ssize_t i
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":1354
*
* @cname('__pyx_memoryview_slice_assign_scalar')
* cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {
/* "View.MemoryView":1357
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
* refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
* itemsize, item)
*/
__pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1358
* bint dtype_is_object) nogil:
* refcount_copying(dst, dtype_is_object, ndim, False)
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<<
* itemsize, item)
* refcount_copying(dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);
/* "View.MemoryView":1360
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
* itemsize, item)
* refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
*
*
*/
__pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1354
*
* @cname('__pyx_memoryview_slice_assign_scalar')
* cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1364
*
* @cname('__pyx_memoryview__slice_assign_scalar')
* cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* size_t itemsize, void *item) nogil:
*/
static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
Py_ssize_t __pyx_v_stride;
Py_ssize_t __pyx_v_extent;
int __pyx_t_1;
Py_ssize_t __pyx_t_2;
Py_ssize_t __pyx_t_3;
/* "View.MemoryView":1368
* size_t itemsize, void *item) nogil:
* cdef Py_ssize_t i
* cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t extent = shape[0]
*
*/
__pyx_v_stride = (__pyx_v_strides[0]);
/* "View.MemoryView":1369
* cdef Py_ssize_t i
* cdef Py_ssize_t stride = strides[0]
* cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<<
*
* if ndim == 1:
*/
__pyx_v_extent = (__pyx_v_shape[0]);
/* "View.MemoryView":1371
* cdef Py_ssize_t extent = shape[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* for i in range(extent):
* memcpy(data, item, itemsize)
*/
__pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1372
*
* if ndim == 1:
* for i in range(extent): # <<<<<<<<<<<<<<
* memcpy(data, item, itemsize)
* data += stride
*/
__pyx_t_2 = __pyx_v_extent;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1373
* if ndim == 1:
* for i in range(extent):
* memcpy(data, item, itemsize) # <<<<<<<<<<<<<<
* data += stride
* else:
*/
memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize);
/* "View.MemoryView":1374
* for i in range(extent):
* memcpy(data, item, itemsize)
* data += stride # <<<<<<<<<<<<<<
* else:
* for i in range(extent):
*/
__pyx_v_data = (__pyx_v_data + __pyx_v_stride);
}
/* "View.MemoryView":1371
* cdef Py_ssize_t extent = shape[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* for i in range(extent):
* memcpy(data, item, itemsize)
*/
goto __pyx_L3;
}
/* "View.MemoryView":1376
* data += stride
* else:
* for i in range(extent): # <<<<<<<<<<<<<<
* _slice_assign_scalar(data, shape + 1, strides + 1,
* ndim - 1, itemsize, item)
*/
/*else*/ {
__pyx_t_2 = __pyx_v_extent;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1377
* else:
* for i in range(extent):
* _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
* ndim - 1, itemsize, item)
* data += stride
*/
__pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);
/* "View.MemoryView":1379
* _slice_assign_scalar(data, shape + 1, strides + 1,
* ndim - 1, itemsize, item)
* data += stride # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_data = (__pyx_v_data + __pyx_v_stride);
}
}
__pyx_L3:;
/* "View.MemoryView":1364
*
* @cname('__pyx_memoryview__slice_assign_scalar')
* cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* size_t itemsize, void *item) nogil:
*/
/* function exit code */
}
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_array_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_array_obj *)o);
p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) {
Py_DECREF(o); o = 0;
}
return o;
}
static void __pyx_tp_dealloc_array(PyObject *o) {
struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
#if PY_VERSION_HEX >= 0x030400a1
if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_array___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->mode);
Py_CLEAR(p->_format);
(*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
PyObject *r;
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
Py_DECREF(x);
return r;
}
static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
return __pyx_array___setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
"Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
return -1;
}
}
static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
PyObject *v = PyObject_GenericGetAttr(o, n);
if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
v = __pyx_array___getattr__(o, n);
}
return v;
}
static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
return get_memview(o);
}
static PyMethodDef __pyx_methods_array[] = {
{"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_array[] = {
{(char *)"memview", __pyx_getprop___pyx_array_memview, 0, 0, 0},
{0, 0, 0, 0, 0}
};
static PySequenceMethods __pyx_tp_as_sequence_array = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_array, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_array = {
0, /*mp_length*/
__pyx_array___getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_array = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getwritebuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getsegcount*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getcharbuffer*/
#endif
__pyx_array_getbuffer, /*bf_getbuffer*/
0, /*bf_releasebuffer*/
};
static PyTypeObject __pyx_type___pyx_array = {
PyVarObject_HEAD_INIT(0, 0)
"partition_comparison.array", /*tp_name*/
sizeof(struct __pyx_array_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_array, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
0, /*tp_repr*/
0, /*tp_as_number*/
&__pyx_tp_as_sequence_array, /*tp_as_sequence*/
&__pyx_tp_as_mapping_array, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
__pyx_tp_getattro_array, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_array, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_array, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets_array, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_array, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
};
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_MemviewEnum_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_MemviewEnum_obj *)o);
p->name = Py_None; Py_INCREF(Py_None);
return o;
}
static void __pyx_tp_dealloc_Enum(PyObject *o) {
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
#if PY_VERSION_HEX >= 0x030400a1
if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
Py_CLEAR(p->name);
(*Py_TYPE(o)->tp_free)(o);
}
static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
if (p->name) {
e = (*v)(p->name, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear_Enum(PyObject *o) {
PyObject* tmp;
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
tmp = ((PyObject*)p->name);
p->name = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
static PyMethodDef __pyx_methods_Enum[] = {
{0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_MemviewEnum = {
PyVarObject_HEAD_INIT(0, 0)
"partition_comparison.Enum", /*tp_name*/
sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_Enum, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
__pyx_MemviewEnum___repr__, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
0, /*tp_doc*/
__pyx_tp_traverse_Enum, /*tp_traverse*/
__pyx_tp_clear_Enum, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_Enum, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
__pyx_MemviewEnum___init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_Enum, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
};
static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_memoryview_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_memoryview_obj *)o);
p->__pyx_vtab = __pyx_vtabptr_memoryview;
p->obj = Py_None; Py_INCREF(Py_None);
p->_size = Py_None; Py_INCREF(Py_None);
p->_array_interface = Py_None; Py_INCREF(Py_None);
p->view.obj = NULL;
if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) {
Py_DECREF(o); o = 0;
}
return o;
}
static void __pyx_tp_dealloc_memoryview(PyObject *o) {
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
#if PY_VERSION_HEX >= 0x030400a1
if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_memoryview___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->obj);
Py_CLEAR(p->_size);
Py_CLEAR(p->_array_interface);
(*Py_TYPE(o)->tp_free)(o);
}
static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
if (p->obj) {
e = (*v)(p->obj, a); if (e) return e;
}
if (p->_size) {
e = (*v)(p->_size, a); if (e) return e;
}
if (p->_array_interface) {
e = (*v)(p->_array_interface, a); if (e) return e;
}
if (p->view.obj) {
e = (*v)(p->view.obj, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear_memoryview(PyObject *o) {
PyObject* tmp;
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
tmp = ((PyObject*)p->obj);
p->obj = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
tmp = ((PyObject*)p->_size);
p->_size = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
tmp = ((PyObject*)p->_array_interface);
p->_array_interface = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
Py_CLEAR(p->view.obj);
return 0;
}
static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
PyObject *r;
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
Py_DECREF(x);
return r;
}
static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
return __pyx_memoryview___setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
"Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
return -1;
}
}
static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_transpose(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview__get__base(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_shape(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_strides(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_suboffsets(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_ndim(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_itemsize(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_nbytes(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryview_get_size(o);
}
static PyMethodDef __pyx_methods_memoryview[] = {
{"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
{"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
{"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
{"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_memoryview[] = {
{(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, 0, 0},
{(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, 0, 0},
{(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, 0, 0},
{(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, 0, 0},
{(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, 0, 0},
{(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, 0, 0},
{(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, 0, 0},
{(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, 0, 0},
{(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, 0, 0},
{0, 0, 0, 0, 0}
};
static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
__pyx_memoryview___len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_memoryview, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
__pyx_memoryview___len__, /*mp_length*/
__pyx_memoryview___getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getwritebuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getsegcount*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getcharbuffer*/
#endif
__pyx_memoryview_getbuffer, /*bf_getbuffer*/
0, /*bf_releasebuffer*/
};
static PyTypeObject __pyx_type___pyx_memoryview = {
PyVarObject_HEAD_INIT(0, 0)
"partition_comparison.memoryview", /*tp_name*/
sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_memoryview, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
__pyx_memoryview___repr__, /*tp_repr*/
0, /*tp_as_number*/
&__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
&__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
__pyx_memoryview___str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
0, /*tp_doc*/
__pyx_tp_traverse_memoryview, /*tp_traverse*/
__pyx_tp_clear_memoryview, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_memoryview, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets_memoryview, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_memoryview, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
};
static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_memoryviewslice_obj *p;
PyObject *o = __pyx_tp_new_memoryview(t, a, k);
if (unlikely(!o)) return 0;
p = ((struct __pyx_memoryviewslice_obj *)o);
p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
p->from_object = Py_None; Py_INCREF(Py_None);
p->from_slice.memview = NULL;
return o;
}
static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
#if PY_VERSION_HEX >= 0x030400a1
if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_memoryviewslice___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->from_object);
PyObject_GC_Track(o);
__pyx_tp_dealloc_memoryview(o);
}
static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
if (p->from_object) {
e = (*v)(p->from_object, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
PyObject* tmp;
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
__pyx_tp_clear_memoryview(o);
tmp = ((PyObject*)p->from_object);
p->from_object = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
__PYX_XDEC_MEMVIEW(&p->from_slice, 1);
return 0;
}
static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_memoryviewslice__get__base(o);
}
static PyMethodDef __pyx_methods__memoryviewslice[] = {
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
{(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, 0, 0},
{0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_memoryviewslice = {
PyVarObject_HEAD_INIT(0, 0)
"partition_comparison._memoryviewslice", /*tp_name*/
sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
#if CYTHON_COMPILING_IN_PYPY
__pyx_memoryview___repr__, /*tp_repr*/
#else
0, /*tp_repr*/
#endif
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
#if CYTHON_COMPILING_IN_PYPY
__pyx_memoryview___str__, /*tp_str*/
#else
0, /*tp_str*/
#endif
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
"Internal class for passing memoryview slices to Python", /*tp_doc*/
__pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
__pyx_tp_clear__memoryviewslice, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods__memoryviewslice, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets__memoryviewslice, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new__memoryviewslice, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
};
static PyMethodDef __pyx_methods[] = {
{0, 0, 0, 0}
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
#if PY_VERSION_HEX < 0x03020000
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
#else
PyModuleDef_HEAD_INIT,
#endif
"partition_comparison",
0, /* m_doc */
-1, /* m_size */
__pyx_methods /* m_methods */,
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
{&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
{&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
{&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
{&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
{&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
{&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
{&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
{&__pyx_kp_s_Expected_at_least_d_arguments, __pyx_k_Expected_at_least_d_arguments, sizeof(__pyx_k_Expected_at_least_d_arguments), 0, 0, 1, 0},
{&__pyx_kp_s_Function_call_with_ambiguous_arg, __pyx_k_Function_call_with_ambiguous_arg, sizeof(__pyx_k_Function_call_with_ambiguous_arg), 0, 0, 1, 0},
{&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
{&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
{&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
{&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
{&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
{&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
{&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
{&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
{&__pyx_kp_s_No_matching_signature_found, __pyx_k_No_matching_signature_found, sizeof(__pyx_k_No_matching_signature_found), 0, 0, 1, 0},
{&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
{&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
{&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
{&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
{&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
{&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
{&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
{&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
{&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
{&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
{&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
{&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
{&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
{&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
{&__pyx_n_s_defaults, __pyx_k_defaults, sizeof(__pyx_k_defaults), 0, 0, 1, 1},
{&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
{&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
{&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
{&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
{&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
{&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
{&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
{&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
{&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
{&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
{&__pyx_kp_s_home_fgonda_results_partition_c, __pyx_k_home_fgonda_results_partition_c, sizeof(__pyx_k_home_fgonda_results_partition_c), 0, 0, 1, 0},
{&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
{&__pyx_n_s_int16_t, __pyx_k_int16_t, sizeof(__pyx_k_int16_t), 0, 0, 1, 1},
{&__pyx_n_s_int32_t, __pyx_k_int32_t, sizeof(__pyx_k_int32_t), 0, 0, 1, 1},
{&__pyx_n_s_int64_t, __pyx_k_int64_t, sizeof(__pyx_k_int64_t), 0, 0, 1, 1},
{&__pyx_n_s_int8_t, __pyx_k_int8_t, sizeof(__pyx_k_int8_t), 0, 0, 1, 1},
{&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
{&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
{&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
{&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
{&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
{&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
{&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
{&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
{&__pyx_n_s_ndarray, __pyx_k_ndarray, sizeof(__pyx_k_ndarray), 0, 0, 1, 1},
{&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
{&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
{&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
{&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
{&__pyx_n_s_partition_comparison, __pyx_k_partition_comparison, sizeof(__pyx_k_partition_comparison), 0, 0, 1, 1},
{&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
{&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
{&__pyx_n_s_rand_index, __pyx_k_rand_index, sizeof(__pyx_k_rand_index), 0, 0, 1, 1},
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
{&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
{&__pyx_n_s_signatures, __pyx_k_signatures, sizeof(__pyx_k_signatures), 0, 0, 1, 1},
{&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
{&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
{&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
{&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
{&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
{&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
{&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
{&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
{&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
{&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
{&__pyx_n_s_uint16_t, __pyx_k_uint16_t, sizeof(__pyx_k_uint16_t), 0, 0, 1, 1},
{&__pyx_n_s_uint32_t, __pyx_k_uint32_t, sizeof(__pyx_k_uint32_t), 0, 0, 1, 1},
{&__pyx_n_s_uint64_t, __pyx_k_uint64_t, sizeof(__pyx_k_uint64_t), 0, 0, 1, 1},
{&__pyx_n_s_uint8_t, __pyx_k_uint8_t, sizeof(__pyx_k_uint8_t), 0, 0, 1, 1},
{&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
{&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
{&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
{&__pyx_n_s_variation_of_information, __pyx_k_variation_of_information, sizeof(__pyx_k_variation_of_information), 0, 0, 1, 1},
{&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
{&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
{&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
}
static int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__2);
__Pyx_GIVEREF(__pyx_tuple__2);
__pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__4);
__Pyx_GIVEREF(__pyx_tuple__4);
__pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__5);
__Pyx_GIVEREF(__pyx_tuple__5);
__pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__6);
__Pyx_GIVEREF(__pyx_tuple__6);
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__7);
__Pyx_GIVEREF(__pyx_tuple__7);
__pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__8);
__Pyx_GIVEREF(__pyx_tuple__8);
__pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__9);
__Pyx_GIVEREF(__pyx_tuple__9);
__pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__10);
__Pyx_GIVEREF(__pyx_tuple__10);
/* "View.MemoryView":129
*
* if not self.ndim:
* raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
*
* if itemsize <= 0:
*/
__pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__11);
__Pyx_GIVEREF(__pyx_tuple__11);
/* "View.MemoryView":132
*
* if itemsize <= 0:
* raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
*
* if not isinstance(format, bytes):
*/
__pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__12);
__Pyx_GIVEREF(__pyx_tuple__12);
/* "View.MemoryView":135
*
* if not isinstance(format, bytes):
* format = format.encode('ASCII') # <<<<<<<<<<<<<<
* self._format = format # keep a reference to the byte string
* self.format = self._format
*/
__pyx_tuple__13 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__13);
__Pyx_GIVEREF(__pyx_tuple__13);
/* "View.MemoryView":144
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__14);
__Pyx_GIVEREF(__pyx_tuple__14);
/* "View.MemoryView":172
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__15);
__Pyx_GIVEREF(__pyx_tuple__15);
/* "View.MemoryView":188
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
* info.buf = self.data
* info.len = self.len
*/
__pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__16);
__Pyx_GIVEREF(__pyx_tuple__16);
/* "View.MemoryView":447
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
* raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
* else:
* if len(self.view.format) == 1:
*/
__pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__17);
__Pyx_GIVEREF(__pyx_tuple__17);
/* "View.MemoryView":523
* if self.view.strides == NULL:
*
* raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]])
*/
__pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__18);
__Pyx_GIVEREF(__pyx_tuple__18);
/* "View.MemoryView":531
* def __get__(self):
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
*/
__pyx_tuple__19 = PyTuple_New(1); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__19);
__Pyx_INCREF(__pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_int_neg_1);
PyTuple_SET_ITEM(__pyx_tuple__19, 0, __pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_tuple__19);
/* "View.MemoryView":640
* if item is Ellipsis:
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
* seen_ellipsis = True
* else:
*/
__pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_slice__20);
__Pyx_GIVEREF(__pyx_slice__20);
/* "View.MemoryView":643
* seen_ellipsis = True
* else:
* result.append(slice(None)) # <<<<<<<<<<<<<<
* have_slices = True
* else:
*/
__pyx_slice__21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_slice__21);
__Pyx_GIVEREF(__pyx_slice__21);
/* "View.MemoryView":654
* nslices = ndim - len(result)
* if nslices:
* result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<<
*
* return have_slices or nslices, tuple(result)
*/
__pyx_slice__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_slice__22);
__Pyx_GIVEREF(__pyx_slice__22);
/* "View.MemoryView":661
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__23);
__Pyx_GIVEREF(__pyx_tuple__23);
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_tuple__24 = PyTuple_Pack(2, __pyx_n_s_x, __pyx_n_s_y); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__24);
__Pyx_GIVEREF(__pyx_tuple__24);
__pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_fgonda_results_partition_c, __pyx_n_s_rand_index, 20, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_tuple__26 = PyTuple_Pack(2, __pyx_n_s_x, __pyx_n_s_y); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__26);
__Pyx_GIVEREF(__pyx_tuple__26);
__pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_fgonda_results_partition_c, __pyx_n_s_variation_of_information, 24, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "View.MemoryView":278
* return self.name
*
* cdef generic = Enum("<strided and direct or indirect>") # <<<<<<<<<<<<<<
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>")
*/
__pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__28);
__Pyx_GIVEREF(__pyx_tuple__28);
/* "View.MemoryView":279
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__29);
__Pyx_GIVEREF(__pyx_tuple__29);
/* "View.MemoryView":280
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__30);
__Pyx_GIVEREF(__pyx_tuple__30);
/* "View.MemoryView":283
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__31);
__Pyx_GIVEREF(__pyx_tuple__31);
/* "View.MemoryView":284
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__32);
__Pyx_GIVEREF(__pyx_tuple__32);
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
}
#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initpartition_comparison(void); /*proto*/
PyMODINIT_FUNC initpartition_comparison(void)
#else
PyMODINIT_FUNC PyInit_partition_comparison(void); /*proto*/
PyMODINIT_FUNC PyInit_partition_comparison(void)
#endif
{
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
PyErr_Clear();
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
if (!__Pyx_RefNanny)
Py_FatalError("failed to import 'refnanny' module");
}
#endif
__Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_partition_comparison(void)", 0);
if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#ifdef __Pyx_CyFunction_USED
if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
#ifdef __Pyx_FusedFunction_USED
if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
#ifdef __Pyx_Coroutine_USED
if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
#ifdef __Pyx_Generator_USED
if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
#ifdef __Pyx_StopAsyncIteration_USED
if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
/*--- Library function declarations ---*/
/*--- Threads initialization code ---*/
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
#ifdef WITH_THREAD /* Python build with threading support? */
PyEval_InitThreads();
#endif
#endif
/*--- Module creation code ---*/
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4("partition_comparison", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
#else
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
Py_INCREF(__pyx_d);
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#if CYTHON_COMPILING_IN_PYPY
Py_INCREF(__pyx_b);
#endif
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
/*--- Initialize various global constants etc. ---*/
if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
if (__pyx_module_is_main_partition_comparison) {
if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if PY_MAJOR_VERSION >= 3
{
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (!PyDict_GetItemString(modules, "partition_comparison")) {
if (unlikely(PyDict_SetItemString(modules, "partition_comparison", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/*--- Builtin init code ---*/
if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/*--- Constants init code ---*/
if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/*--- Global init code ---*/
generic = Py_None; Py_INCREF(Py_None);
strided = Py_None; Py_INCREF(Py_None);
indirect = Py_None; Py_INCREF(Py_None);
contiguous = Py_None; Py_INCREF(Py_None);
indirect_contiguous = Py_None; Py_INCREF(Py_None);
/*--- Variable export code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
if (PyType_Ready(&__pyx_type___pyx_array) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type___pyx_array.tp_print = 0;
__pyx_array_type = &__pyx_type___pyx_array;
if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type___pyx_MemviewEnum.tp_print = 0;
__pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
__pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
__pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
__pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
__pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
__pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
__pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
__pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
__pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type___pyx_memoryview.tp_print = 0;
if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_memoryview_type = &__pyx_type___pyx_memoryview;
__pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
__pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
__pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
__pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
__pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type___pyx_memoryviewslice.tp_print = 0;
if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
/*--- Type import code ---*/
/*--- Variable import code ---*/
/*--- Function import code ---*/
/*--- Execution code ---*/
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
/* "partition_comparison.pyx":20
* uint64_t
*
* def rand_index(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_0__pyx_mdef_20partition_comparison_5rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_int8_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_1__pyx_mdef_20partition_comparison_7rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_int16_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_2__pyx_mdef_20partition_comparison_9rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_int32_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_3__pyx_mdef_20partition_comparison_11rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_int64_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_4__pyx_mdef_20partition_comparison_13rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_uint8_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_5__pyx_mdef_20partition_comparison_15rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_uint16_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_6__pyx_mdef_20partition_comparison_17rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_uint32_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_fuse_7__pyx_mdef_20partition_comparison_19rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_uint64_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_NewEx(&__pyx_mdef_20partition_comparison_1rand_index, 0, __pyx_n_s_rand_index, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
__Pyx_GIVEREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_rand_index, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "partition_comparison.pyx":24
* return randIndex(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*
* def variation_of_information(Label[::1] x, Label[::1] y): # <<<<<<<<<<<<<<
* assert x.size == y.size
* return variationOfInformation(&(x[0]), (&x[0]) + <int> x.size, &(y[0]), True)
*/
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_0__pyx_mdef_20partition_comparison_23variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_int8_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_1__pyx_mdef_20partition_comparison_25variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_int16_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_2__pyx_mdef_20partition_comparison_27variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_int32_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_3__pyx_mdef_20partition_comparison_29variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_int64_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_4__pyx_mdef_20partition_comparison_31variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_uint8_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_5__pyx_mdef_20partition_comparison_33variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_uint16_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_6__pyx_mdef_20partition_comparison_35variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_uint32_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_fuse_7__pyx_mdef_20partition_comparison_37variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_uint64_t, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __pyx_FusedFunction_NewEx(&__pyx_mdef_20partition_comparison_3variation_of_information, 0, __pyx_n_s_variation_of_information, NULL, __pyx_n_s_partition_comparison, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_empty_tuple);
((__pyx_FusedFunctionObject *) __pyx_t_4)->__signatures__ = __pyx_t_3;
__Pyx_GIVEREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_variation_of_information, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
/* "partition_comparison.pyx":1
* cimport cython # <<<<<<<<<<<<<<
*
* from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
*/
__pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
/* "View.MemoryView":205
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
* def __dealloc__(array self):
*/
__pyx_t_5 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
PyType_Modified(__pyx_array_type);
/* "View.MemoryView":278
* return self.name
*
* cdef generic = Enum("<strided and direct or indirect>") # <<<<<<<<<<<<<<
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>")
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XGOTREF(generic);
__Pyx_DECREF_SET(generic, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":279
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XGOTREF(strided);
__Pyx_DECREF_SET(strided, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":280
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XGOTREF(indirect);
__Pyx_DECREF_SET(indirect, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":283
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XGOTREF(contiguous);
__Pyx_DECREF_SET(contiguous, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":284
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XGOTREF(indirect_contiguous);
__Pyx_DECREF_SET(indirect_contiguous, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":498
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
PyType_Modified(__pyx_memoryview_type);
/* "View.MemoryView":954
* return self.from_object
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
PyType_Modified(__pyx_memoryviewslice_type);
/* "__pyxutil":2
*
* cdef extern from *: # <<<<<<<<<<<<<<
* void __pyx_PyErr_Clear "PyErr_Clear" ()
* __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(object)
*/
/*--- Wrapped vars code ---*/
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
if (__pyx_m) {
if (__pyx_d) {
__Pyx_AddTraceback("init partition_comparison", __pyx_clineno, __pyx_lineno, __pyx_filename);
}
Py_DECREF(__pyx_m); __pyx_m = 0;
} else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ImportError, "init partition_comparison");
}
__pyx_L0:;
__Pyx_RefNannyFinishContext();
#if PY_MAJOR_VERSION < 3
return;
#else
return __pyx_m;
#endif
}
/* --- Runtime support code --- */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
PyObject *m = NULL, *p = NULL;
void *r = NULL;
m = PyImport_ImportModule((char *)modname);
if (!m) goto end;
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
if (!p) goto end;
r = PyLong_AsVoidPtr(p);
end:
Py_XDECREF(p);
Py_XDECREF(m);
return (__Pyx_RefNannyAPIStruct *)r;
}
#endif
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
if (unlikely(!result)) {
PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined", name);
#else
"name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
}
return result;
}
static void __Pyx_RaiseArgtupleInvalid(
const char* func_name,
int exact,
Py_ssize_t num_min,
Py_ssize_t num_max,
Py_ssize_t num_found)
{
Py_ssize_t num_expected;
const char *more_or_less;
if (num_found < num_min) {
num_expected = num_min;
more_or_less = "at least";
} else {
num_expected = num_max;
more_or_less = "at most";
}
if (exact) {
more_or_less = "exactly";
}
PyErr_Format(PyExc_TypeError,
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
func_name, more_or_less, num_expected,
(num_expected == 1) ? "" : "s", num_found);
}
static void __Pyx_RaiseDoubleKeywordsError(
const char* func_name,
PyObject* kw_name)
{
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION >= 3
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
#else
"%s() got multiple values for keyword argument '%s'", func_name,
PyString_AsString(kw_name));
#endif
}
static int __Pyx_ParseOptionalKeywords(
PyObject *kwds,
PyObject **argnames[],
PyObject *kwds2,
PyObject *values[],
Py_ssize_t num_pos_args,
const char* function_name)
{
PyObject *key = 0, *value = 0;
Py_ssize_t pos = 0;
PyObject*** name;
PyObject*** first_kw_arg = argnames + num_pos_args;
while (PyDict_Next(kwds, &pos, &key, &value)) {
name = first_kw_arg;
while (*name && (**name != key)) name++;
if (*name) {
values[name-argnames] = value;
continue;
}
name = first_kw_arg;
#if PY_MAJOR_VERSION < 3
if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
while (*name) {
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
&& _PyString_Eq(**name, key)) {
values[name-argnames] = value;
break;
}
name++;
}
if (*name) continue;
else {
PyObject*** argname = argnames;
while (argname != first_kw_arg) {
if ((**argname == key) || (
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
&& _PyString_Eq(**argname, key))) {
goto arg_passed_twice;
}
argname++;
}
}
} else
#endif
if (likely(PyUnicode_Check(key))) {
while (*name) {
int cmp = (**name == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
(PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
#endif
PyUnicode_Compare(**name, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
if (cmp == 0) {
values[name-argnames] = value;
break;
}
name++;
}
if (*name) continue;
else {
PyObject*** argname = argnames;
while (argname != first_kw_arg) {
int cmp = (**argname == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
(PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
#endif
PyUnicode_Compare(**argname, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
if (cmp == 0) goto arg_passed_twice;
argname++;
}
}
} else
goto invalid_keyword_type;
if (kwds2) {
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
} else {
goto invalid_keyword;
}
}
return 0;
arg_passed_twice:
__Pyx_RaiseDoubleKeywordsError(function_name, key);
goto bad;
invalid_keyword_type:
PyErr_Format(PyExc_TypeError,
"%.200s() keywords must be strings", function_name);
goto bad;
invalid_keyword:
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3
"%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key));
#else
"%s() got an unexpected keyword argument '%U'",
function_name, key);
#endif
bad:
return -1;
}
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
PyObject *empty_list = 0;
PyObject *module = 0;
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
PyObject *list;
#if PY_VERSION_HEX < 0x03030000
PyObject *py_import;
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
if (!py_import)
goto bad;
#endif
if (from_list)
list = from_list;
else {
empty_list = PyList_New(0);
if (!empty_list)
goto bad;
list = empty_list;
}
global_dict = PyModule_GetDict(__pyx_m);
if (!global_dict)
goto bad;
empty_dict = PyDict_New();
if (!empty_dict)
goto bad;
{
#if PY_MAJOR_VERSION >= 3
if (level == -1) {
if (strchr(__Pyx_MODULE_NAME, '.')) {
#if PY_VERSION_HEX < 0x03030000
PyObject *py_level = PyInt_FromLong(1);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
#else
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, 1);
#endif
if (!module) {
if (!PyErr_ExceptionMatches(PyExc_ImportError))
goto bad;
PyErr_Clear();
}
}
level = 0;
}
#endif
if (!module) {
#if PY_VERSION_HEX < 0x03030000
PyObject *py_level = PyInt_FromLong(level);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
#else
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, level);
#endif
}
}
bad:
#if PY_VERSION_HEX < 0x03030000
Py_XDECREF(py_import);
#endif
Py_XDECREF(empty_list);
Py_XDECREF(empty_dict);
return module;
}
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
*type = tstate->exc_type;
*value = tstate->exc_value;
*tb = tstate->exc_traceback;
Py_XINCREF(*type);
Py_XINCREF(*value);
Py_XINCREF(*tb);
#else
PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = type;
tstate->exc_value = value;
tstate->exc_traceback = tb;
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
#else
PyErr_SetExcInfo(type, value, tb);
#endif
}
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
local_type = tstate->curexc_type;
local_value = tstate->curexc_value;
local_tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
#else
PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(tstate->curexc_type))
#else
if (unlikely(PyErr_Occurred()))
#endif
goto bad;
#if PY_MAJOR_VERSION >= 3
if (local_tb) {
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad;
}
#endif
Py_XINCREF(local_tb);
Py_XINCREF(local_type);
Py_XINCREF(local_value);
*type = local_type;
*value = local_value;
*tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = local_type;
tstate->exc_value = local_value;
tstate->exc_traceback = local_tb;
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
#else
PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
return 0;
bad:
*type = 0;
*value = 0;
*tb = 0;
Py_XDECREF(local_type);
Py_XDECREF(local_value);
Py_XDECREF(local_tb);
return -1;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
PyObject *r;
if (!j) return NULL;
r = PyObject_GetItem(o, j);
Py_DECREF(j);
return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
PyObject *r = PyList_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (PyTuple_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
} else {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (likely(l >= 0)) {
i += l;
} else {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
PyErr_Clear();
else
return NULL;
}
}
return m->sq_item(o, i);
}
}
#else
if (is_list || PySequence_Check(o)) {
return PySequence_GetItem(o, i);
}
#endif
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
PyObject *result;
ternaryfunc call = func->ob_type->tp_call;
if (unlikely(!call))
return PyObject_Call(func, arg, kw);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = (*call)(func, arg, kw);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->curexc_type;
tmp_value = tstate->curexc_value;
tmp_tb = tstate->curexc_traceback;
tstate->curexc_type = type;
tstate->curexc_value = value;
tstate->curexc_traceback = tb;
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
#else
PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
*type = tstate->curexc_type;
*value = tstate->curexc_value;
*tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
#else
PyErr_Fetch(type, value, tb);
#endif
}
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
CYTHON_UNUSED PyObject *cause) {
Py_XINCREF(type);
if (!value || value == Py_None)
value = NULL;
else
Py_INCREF(value);
if (!tb || tb == Py_None)
tb = NULL;
else {
Py_INCREF(tb);
if (!PyTraceBack_Check(tb)) {
PyErr_SetString(PyExc_TypeError,
"raise: arg 3 must be a traceback or None");
goto raise_error;
}
}
if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
if (!value) {
Py_INCREF(Py_None);
value = Py_None;
}
#endif
PyErr_NormalizeException(&type, &value, &tb);
} else {
if (value) {
PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value");
goto raise_error;
}
value = type;
type = (PyObject*) Py_TYPE(type);
Py_INCREF(type);
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException");
goto raise_error;
}
}
__Pyx_ErrRestore(type, value, tb);
return;
raise_error:
Py_XDECREF(value);
Py_XDECREF(type);
Py_XDECREF(tb);
return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
PyObject* owned_instance = NULL;
if (tb == Py_None) {
tb = 0;
} else if (tb && !PyTraceBack_Check(tb)) {
PyErr_SetString(PyExc_TypeError,
"raise: arg 3 must be a traceback or None");
goto bad;
}
if (value == Py_None)
value = 0;
if (PyExceptionInstance_Check(type)) {
if (value) {
PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value");
goto bad;
}
value = type;
type = (PyObject*) Py_TYPE(value);
} else if (PyExceptionClass_Check(type)) {
PyObject *instance_class = NULL;
if (value && PyExceptionInstance_Check(value)) {
instance_class = (PyObject*) Py_TYPE(value);
if (instance_class != type) {
int is_subclass = PyObject_IsSubclass(instance_class, type);
if (!is_subclass) {
instance_class = NULL;
} else if (unlikely(is_subclass == -1)) {
goto bad;
} else {
type = instance_class;
}
}
}
if (!instance_class) {
PyObject *args;
if (!value)
args = PyTuple_New(0);
else if (PyTuple_Check(value)) {
Py_INCREF(value);
args = value;
} else
args = PyTuple_Pack(1, value);
if (!args)
goto bad;
owned_instance = PyObject_Call(type, args, NULL);
Py_DECREF(args);
if (!owned_instance)
goto bad;
value = owned_instance;
if (!PyExceptionInstance_Check(value)) {
PyErr_Format(PyExc_TypeError,
"calling %R should have returned an instance of "
"BaseException, not %R",
type, Py_TYPE(value));
goto bad;
}
}
} else {
PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException");
goto bad;
}
#if PY_VERSION_HEX >= 0x03030000
if (cause) {
#else
if (cause && cause != Py_None) {
#endif
PyObject *fixed_cause;
if (cause == Py_None) {
fixed_cause = NULL;
} else if (PyExceptionClass_Check(cause)) {
fixed_cause = PyObject_CallObject(cause, NULL);
if (fixed_cause == NULL)
goto bad;
} else if (PyExceptionInstance_Check(cause)) {
fixed_cause = cause;
Py_INCREF(fixed_cause);
} else {
PyErr_SetString(PyExc_TypeError,
"exception causes must derive from "
"BaseException");
goto bad;
}
PyException_SetCause(value, fixed_cause);
}
PyErr_SetObject(type, value);
if (tb) {
#if CYTHON_COMPILING_IN_PYPY
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
Py_INCREF(tb);
PyErr_Restore(tmp_type, tmp_value, tb);
Py_XDECREF(tmp_tb);
#else
PyThreadState *tstate = PyThreadState_GET();
PyObject* tmp_tb = tstate->curexc_traceback;
if (tb != tmp_tb) {
Py_INCREF(tb);
tstate->curexc_traceback = tb;
Py_XDECREF(tmp_tb);
}
#endif
}
bad:
Py_XDECREF(owned_instance);
return;
}
#endif
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
Py_ssize_t length;
#if CYTHON_PEP393_ENABLED
length = PyUnicode_GET_LENGTH(x);
if (likely(length == 1)) {
return PyUnicode_READ_CHAR(x, 0);
}
#else
length = PyUnicode_GET_SIZE(x);
if (likely(length == 1)) {
return PyUnicode_AS_UNICODE(x)[0];
}
#if Py_UNICODE_SIZE == 2
else if (PyUnicode_GET_SIZE(x) == 2) {
Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
if (high_val >= 0xD800 && high_val <= 0xDBFF) {
Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
}
}
}
#endif
#endif
PyErr_Format(PyExc_ValueError,
"only single character unicode strings can be converted to Py_UCS4, "
"got length %" CYTHON_FORMAT_SSIZE_T "d", length);
return (Py_UCS4)-1;
}
static long __Pyx__PyObject_Ord(PyObject* c) {
Py_ssize_t size;
if (PyBytes_Check(c)) {
size = PyBytes_GET_SIZE(c);
if (likely(size == 1)) {
return (unsigned char) PyBytes_AS_STRING(c)[0];
}
#if PY_MAJOR_VERSION < 3
} else if (PyUnicode_Check(c)) {
return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
} else if (PyByteArray_Check(c)) {
size = PyByteArray_GET_SIZE(c);
if (likely(size == 1)) {
return (unsigned char) PyByteArray_AS_STRING(c)[0];
}
#endif
} else {
PyErr_Format(PyExc_TypeError,
"ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
return (long)(Py_UCS4)-1;
}
PyErr_Format(PyExc_TypeError,
"ord() expected a character, but string of length %zd found", size);
return (long)(Py_UCS4)-1;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
int r;
if (!j) return -1;
r = PyObject_SetItem(o, j, v);
Py_DECREF(j);
return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
PyObject* old = PyList_GET_ITEM(o, n);
Py_INCREF(v);
PyList_SET_ITEM(o, n, v);
Py_DECREF(old);
return 1;
}
} else {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_ass_item)) {
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (likely(l >= 0)) {
i += l;
} else {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
PyErr_Clear();
else
return -1;
}
}
return m->sq_ass_item(o, i, v);
}
}
#else
#if CYTHON_COMPILING_IN_PYPY
if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
if (is_list || PySequence_Check(o)) {
#endif
return PySequence_SetItem(o, i, v);
}
#endif
return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
PyObject* exc_type = tstate->curexc_type;
if (unlikely(exc_type)) {
if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
PyObject *exc_value, *exc_tb;
exc_value = tstate->curexc_value;
exc_tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
Py_DECREF(exc_type);
Py_XDECREF(exc_value);
Py_XDECREF(exc_tb);
return 0;
} else {
return -1;
}
}
return 0;
#else
if (unlikely(PyErr_Occurred())) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
PyErr_Clear();
return 0;
} else {
return -1;
}
}
return 0;
#endif
}
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
PyObject *self, *result;
PyCFunction cfunc;
cfunc = PyCFunction_GET_FUNCTION(func);
self = PyCFunction_GET_SELF(func);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = cfunc(self, arg);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
if (likely(PyCFunction_Check(func))) {
#endif
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
return __Pyx_PyObject_CallMethO(func, NULL);
}
}
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
Py_INCREF(arg);
PyTuple_SET_ITEM(args, 0, arg);
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
if (likely(PyCFunction_Check(func))) {
#endif
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
}
}
return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_Pack(1, arg);
if (unlikely(!args)) return NULL;
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
#endif
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
PyObject *method, *result = NULL;
method = __Pyx_PyObject_GetAttrStr(obj, method_name);
if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyMethod_Check(method))) {
PyObject *self = PyMethod_GET_SELF(method);
if (likely(self)) {
PyObject *function = PyMethod_GET_FUNCTION(method);
result = __Pyx_PyObject_CallOneArg(function, self);
Py_DECREF(method);
return result;
}
}
#endif
result = __Pyx_PyObject_CallNoArg(method);
Py_DECREF(method);
bad:
return result;
}
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError,
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
index, (index == 1) ? "" : "s");
}
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
PyErr_Format(PyExc_ValueError,
"too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
if (unlikely(retval)) {
Py_DECREF(retval);
__Pyx_RaiseTooManyValuesError(expected);
return -1;
} else {
return __Pyx_IterFinish();
}
return 0;
}
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
if (t == Py_None) {
__Pyx_RaiseNoneNotIterableError();
} else if (PyTuple_GET_SIZE(t) < index) {
__Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
} else {
__Pyx_RaiseTooManyValuesError(index);
}
}
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
int is_tuple, int has_known_size, int decref_tuple) {
Py_ssize_t index;
PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
iternextfunc iternext;
iter = PyObject_GetIter(tuple);
if (unlikely(!iter)) goto bad;
if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
iternext = Py_TYPE(iter)->tp_iternext;
value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
Py_DECREF(iter);
} else {
if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
__Pyx_UnpackTupleError(tuple, 2);
goto bad;
}
#if CYTHON_COMPILING_IN_PYPY
value1 = PySequence_ITEM(tuple, 0);
if (unlikely(!value1)) goto bad;
value2 = PySequence_ITEM(tuple, 1);
if (unlikely(!value2)) goto bad;
#else
value1 = PyTuple_GET_ITEM(tuple, 0);
value2 = PyTuple_GET_ITEM(tuple, 1);
Py_INCREF(value1);
Py_INCREF(value2);
#endif
if (decref_tuple) { Py_DECREF(tuple); }
}
*pvalue1 = value1;
*pvalue2 = value2;
return 0;
unpacking_failed:
if (!has_known_size && __Pyx_IterFinish() == 0)
__Pyx_RaiseNeedMoreValuesError(index);
bad:
Py_XDECREF(iter);
Py_XDECREF(value1);
Py_XDECREF(value2);
if (decref_tuple) { Py_XDECREF(tuple); }
return -1;
}
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
Py_ssize_t* p_orig_length, int* p_source_is_dict) {
is_dict = is_dict || likely(PyDict_CheckExact(iterable));
*p_source_is_dict = is_dict;
#if !CYTHON_COMPILING_IN_PYPY
if (is_dict) {
*p_orig_length = PyDict_Size(iterable);
Py_INCREF(iterable);
return iterable;
}
#endif
*p_orig_length = 0;
if (method_name) {
PyObject* iter;
iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
if (!iterable)
return NULL;
#if !CYTHON_COMPILING_IN_PYPY
if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
return iterable;
#endif
iter = PyObject_GetIter(iterable);
Py_DECREF(iterable);
return iter;
}
return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
if (source_is_dict) {
PyObject *key, *value;
if (unlikely(orig_length != PyDict_Size(iter_obj))) {
PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
return -1;
}
if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
return 0;
}
if (pitem) {
PyObject* tuple = PyTuple_New(2);
if (unlikely(!tuple)) {
return -1;
}
Py_INCREF(key);
Py_INCREF(value);
PyTuple_SET_ITEM(tuple, 0, key);
PyTuple_SET_ITEM(tuple, 1, value);
*pitem = tuple;
} else {
if (pkey) {
Py_INCREF(key);
*pkey = key;
}
if (pvalue) {
Py_INCREF(value);
*pvalue = value;
}
}
return 1;
} else if (PyTuple_CheckExact(iter_obj)) {
Py_ssize_t pos = *ppos;
if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
*ppos = pos + 1;
next_item = PyTuple_GET_ITEM(iter_obj, pos);
Py_INCREF(next_item);
} else if (PyList_CheckExact(iter_obj)) {
Py_ssize_t pos = *ppos;
if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
*ppos = pos + 1;
next_item = PyList_GET_ITEM(iter_obj, pos);
Py_INCREF(next_item);
} else
#endif
{
next_item = PyIter_Next(iter_obj);
if (unlikely(!next_item)) {
return __Pyx_IterFinish();
}
}
if (pitem) {
*pitem = next_item;
} else if (pkey && pvalue) {
if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
return -1;
} else if (pkey) {
*pkey = next_item;
} else {
*pvalue = next_item;
}
return 1;
}
static void __Pyx_RaiseBufferIndexError(int axis) {
PyErr_Format(PyExc_IndexError,
"Out of bounds on buffer access (axis %d)", axis);
}
static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
unsigned int n = 1;
return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
__Pyx_BufFmt_StackElem* stack,
__Pyx_TypeInfo* type) {
stack[0].field = &ctx->root;
stack[0].parent_offset = 0;
ctx->root.type = type;
ctx->root.name = "buffer dtype";
ctx->root.offset = 0;
ctx->head = stack;
ctx->head->field = &ctx->root;
ctx->fmt_offset = 0;
ctx->head->parent_offset = 0;
ctx->new_packmode = '@';
ctx->enc_packmode = '@';
ctx->new_count = 1;
ctx->enc_count = 0;
ctx->enc_type = 0;
ctx->is_complex = 0;
ctx->is_valid_array = 0;
ctx->struct_alignment = 0;
while (type->typegroup == 'S') {
++ctx->head;
ctx->head->field = type->fields;
ctx->head->parent_offset = 0;
type = type->fields->type;
}
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
int count;
const char* t = *ts;
if (*t < '0' || *t > '9') {
return -1;
} else {
count = *t++ - '0';
while (*t >= '0' && *t < '9') {
count *= 10;
count += *t++ - '0';
}
}
*ts = t;
return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
int number = __Pyx_BufFmt_ParseNumber(ts);
if (number == -1)
PyErr_Format(PyExc_ValueError,\
"Does not understand character buffer dtype format string ('%c')", **ts);
return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
PyErr_Format(PyExc_ValueError,
"Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
switch (ch) {
case 'c': return "'char'";
case 'b': return "'signed char'";
case 'B': return "'unsigned char'";
case 'h': return "'short'";
case 'H': return "'unsigned short'";
case 'i': return "'int'";
case 'I': return "'unsigned int'";
case 'l': return "'long'";
case 'L': return "'unsigned long'";
case 'q': return "'long long'";
case 'Q': return "'unsigned long long'";
case 'f': return (is_complex ? "'complex float'" : "'float'");
case 'd': return (is_complex ? "'complex double'" : "'double'");
case 'g': return (is_complex ? "'complex long double'" : "'long double'");
case 'T': return "a struct";
case 'O': return "Python object";
case 'P': return "a pointer";
case 's': case 'p': return "a string";
case 0: return "end";
default: return "unparseable format string";
}
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return 2;
case 'i': case 'I': case 'l': case 'L': return 4;
case 'q': case 'Q': return 8;
case 'f': return (is_complex ? 8 : 4);
case 'd': return (is_complex ? 16 : 8);
case 'g': {
PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
return 0;
}
case 'O': case 'P': return sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
switch (ch) {
case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(short);
case 'i': case 'I': return sizeof(int);
case 'l': case 'L': return sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(float) * (is_complex ? 2 : 1);
case 'd': return sizeof(double) * (is_complex ? 2 : 1);
case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
case 'O': case 'P': return sizeof(void*);
default: {
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
/* These are for computing the padding at the end of the struct to align
on the first member of the struct. This will probably the same as above,
but we don't have any guarantees.
*/
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
switch (ch) {
case 'c':
return 'H';
case 'b': case 'h': case 'i':
case 'l': case 'q': case 's': case 'p':
return 'I';
case 'B': case 'H': case 'I': case 'L': case 'Q':
return 'U';
case 'f': case 'd': case 'g':
return (is_complex ? 'C' : 'R');
case 'O':
return 'O';
case 'P':
return 'P';
default: {
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
if (ctx->head == NULL || ctx->head->field == &ctx->root) {
const char* expected;
const char* quote;
if (ctx->head == NULL) {
expected = "end";
quote = "";
} else {
expected = ctx->head->field->type->name;
quote = "'";
}
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch, expected %s%s%s but got %s",
quote, expected, quote,
__Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
} else {
__Pyx_StructField* field = ctx->head->field;
__Pyx_StructField* parent = (ctx->head - 1)->field;
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
parent->type->name, field->name);
}
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
char group;
size_t size, offset, arraysize = 1;
if (ctx->enc_type == 0) return 0;
if (ctx->head->field->type->arraysize[0]) {
int i, ndim = 0;
if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
ctx->is_valid_array = ctx->head->field->type->ndim == 1;
ndim = 1;
if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
PyErr_Format(PyExc_ValueError,
"Expected a dimension of size %zu, got %zu",
ctx->head->field->type->arraysize[0], ctx->enc_count);
return -1;
}
}
if (!ctx->is_valid_array) {
PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
ctx->head->field->type->ndim, ndim);
return -1;
}
for (i = 0; i < ctx->head->field->type->ndim; i++) {
arraysize *= ctx->head->field->type->arraysize[i];
}
ctx->is_valid_array = 0;
ctx->enc_count = 1;
}
group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
do {
__Pyx_StructField* field = ctx->head->field;
__Pyx_TypeInfo* type = field->type;
if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
} else {
size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
}
if (ctx->enc_packmode == '@') {
size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
size_t align_mod_offset;
if (align_at == 0) return -1;
align_mod_offset = ctx->fmt_offset % align_at;
if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
if (ctx->struct_alignment == 0)
ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
ctx->is_complex);
}
if (type->size != size || type->typegroup != group) {
if (type->typegroup == 'C' && type->fields != NULL) {
size_t parent_offset = ctx->head->parent_offset + field->offset;
++ctx->head;
ctx->head->field = type->fields;
ctx->head->parent_offset = parent_offset;
continue;
}
if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
} else {
__Pyx_BufFmt_RaiseExpected(ctx);
return -1;
}
}
offset = ctx->head->parent_offset + field->offset;
if (ctx->fmt_offset != offset) {
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
(Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
return -1;
}
ctx->fmt_offset += size;
if (arraysize)
ctx->fmt_offset += (arraysize - 1) * size;
--ctx->enc_count;
while (1) {
if (field == &ctx->root) {
ctx->head = NULL;
if (ctx->enc_count != 0) {
__Pyx_BufFmt_RaiseExpected(ctx);
return -1;
}
break;
}
ctx->head->field = ++field;
if (field->type == NULL) {
--ctx->head;
field = ctx->head->field;
continue;
} else if (field->type->typegroup == 'S') {
size_t parent_offset = ctx->head->parent_offset + field->offset;
if (field->type->fields->type == NULL) continue;
field = field->type->fields;
++ctx->head;
ctx->head->field = field;
ctx->head->parent_offset = parent_offset;
break;
} else {
break;
}
}
} while (ctx->enc_count);
ctx->enc_type = 0;
ctx->is_complex = 0;
return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
const char *ts = *tsp;
int i = 0, number;
int ndim = ctx->head->field->type->ndim;
;
++ts;
if (ctx->new_count != 1) {
PyErr_SetString(PyExc_ValueError,
"Cannot handle repeated arrays in format string");
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
while (*ts && *ts != ')') {
switch (*ts) {
case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
default: break;
}
number = __Pyx_BufFmt_ExpectNumber(&ts);
if (number == -1) return NULL;
if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
return PyErr_Format(PyExc_ValueError,
"Expected a dimension of size %zu, got %d",
ctx->head->field->type->arraysize[i], number);
if (*ts != ',' && *ts != ')')
return PyErr_Format(PyExc_ValueError,
"Expected a comma in format string, got '%c'", *ts);
if (*ts == ',') ts++;
i++;
}
if (i != ndim)
return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
ctx->head->field->type->ndim, i);
if (!*ts) {
PyErr_SetString(PyExc_ValueError,
"Unexpected end of format string, expected ')'");
return NULL;
}
ctx->is_valid_array = 1;
ctx->new_count = 1;
*tsp = ++ts;
return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
int got_Z = 0;
while (1) {
switch(*ts) {
case 0:
if (ctx->enc_type != 0 && ctx->head == NULL) {
__Pyx_BufFmt_RaiseExpected(ctx);
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
if (ctx->head != NULL) {
__Pyx_BufFmt_RaiseExpected(ctx);
return NULL;
}
return ts;
case ' ':
case '\r':
case '\n':
++ts;
break;
case '<':
if (!__Pyx_IsLittleEndian()) {
PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
return NULL;
}
ctx->new_packmode = '=';
++ts;
break;
case '>':
case '!':
if (__Pyx_IsLittleEndian()) {
PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
return NULL;
}
ctx->new_packmode = '=';
++ts;
break;
case '=':
case '@':
case '^':
ctx->new_packmode = *ts++;
break;
case 'T':
{
const char* ts_after_sub;
size_t i, struct_count = ctx->new_count;
size_t struct_alignment = ctx->struct_alignment;
ctx->new_count = 1;
++ts;
if (*ts != '{') {
PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_type = 0;
ctx->enc_count = 0;
ctx->struct_alignment = 0;
++ts;
ts_after_sub = ts;
for (i = 0; i != struct_count; ++i) {
ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
if (!ts_after_sub) return NULL;
}
ts = ts_after_sub;
if (struct_alignment) ctx->struct_alignment = struct_alignment;
}
break;
case '}':
{
size_t alignment = ctx->struct_alignment;
++ts;
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_type = 0;
if (alignment && ctx->fmt_offset % alignment) {
ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
}
}
return ts;
case 'x':
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->fmt_offset += ctx->new_count;
ctx->new_count = 1;
ctx->enc_count = 0;
ctx->enc_type = 0;
ctx->enc_packmode = ctx->new_packmode;
++ts;
break;
case 'Z':
got_Z = 1;
++ts;
if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
__Pyx_BufFmt_RaiseUnexpectedChar('Z');
return NULL;
}
case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
case 'l': case 'L': case 'q': case 'Q':
case 'f': case 'd': case 'g':
case 'O': case 'p':
if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
ctx->enc_packmode == ctx->new_packmode) {
ctx->enc_count += ctx->new_count;
ctx->new_count = 1;
got_Z = 0;
++ts;
break;
}
case 's':
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_count = ctx->new_count;
ctx->enc_packmode = ctx->new_packmode;
ctx->enc_type = *ts;
ctx->is_complex = got_Z;
++ts;
ctx->new_count = 1;
got_Z = 0;
break;
case ':':
++ts;
while(*ts != ':') ++ts;
++ts;
break;
case '(':
if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
break;
default:
{
int number = __Pyx_BufFmt_ExpectNumber(&ts);
if (number == -1) return NULL;
ctx->new_count = (size_t)number;
}
}
}
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
buf->buf = NULL;
buf->obj = NULL;
buf->strides = __Pyx_zeros;
buf->shape = __Pyx_zeros;
buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags,
int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
if (obj == Py_None || obj == NULL) {
__Pyx_ZeroBuffer(buf);
return 0;
}
buf->buf = NULL;
if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
if (buf->ndim != nd) {
PyErr_Format(PyExc_ValueError,
"Buffer has wrong number of dimensions (expected %d, got %d)",
nd, buf->ndim);
goto fail;
}
if (!cast) {
__Pyx_BufFmt_Context ctx;
__Pyx_BufFmt_Init(&ctx, stack, dtype);
if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
}
if ((unsigned)buf->itemsize != dtype->size) {
PyErr_Format(PyExc_ValueError,
"Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
buf->itemsize, (buf->itemsize > 1) ? "s" : "",
dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
goto fail;
}
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
return 0;
fail:;
__Pyx_ZeroBuffer(buf);
return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
if (info->buf == NULL) return;
if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
__Pyx_ReleaseBuffer(info);
}
static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
int ndim,
__Pyx_memviewslice *memviewslice,
int memview_is_new_reference)
{
__Pyx_RefNannyDeclarations
int i, retval=-1;
Py_buffer *buf = &memview->view;
__Pyx_RefNannySetupContext("init_memviewslice", 0);
if (!buf) {
PyErr_SetString(PyExc_ValueError,
"buf is NULL.");
goto fail;
} else if (memviewslice->memview || memviewslice->data) {
PyErr_SetString(PyExc_ValueError,
"memviewslice is already initialized!");
goto fail;
}
if (buf->strides) {
for (i = 0; i < ndim; i++) {
memviewslice->strides[i] = buf->strides[i];
}
} else {
Py_ssize_t stride = buf->itemsize;
for (i = ndim - 1; i >= 0; i--) {
memviewslice->strides[i] = stride;
stride *= buf->shape[i];
}
}
for (i = 0; i < ndim; i++) {
memviewslice->shape[i] = buf->shape[i];
if (buf->suboffsets) {
memviewslice->suboffsets[i] = buf->suboffsets[i];
} else {
memviewslice->suboffsets[i] = -1;
}
}
memviewslice->memview = memview;
memviewslice->data = (char *)buf->buf;
if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
Py_INCREF(memview);
}
retval = 0;
goto no_fail;
fail:
memviewslice->memview = 0;
memviewslice->data = 0;
retval = -1;
no_fail:
__Pyx_RefNannyFinishContext();
return retval;
}
static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) {
va_list vargs;
char msg[200];
#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, fmt);
#else
va_start(vargs);
#endif
vsnprintf(msg, 200, fmt, vargs);
Py_FatalError(msg);
va_end(vargs);
}
static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
PyThread_type_lock lock)
{
int result;
PyThread_acquire_lock(lock, 1);
result = (*acquisition_count)++;
PyThread_release_lock(lock);
return result;
}
static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
PyThread_type_lock lock)
{
int result;
PyThread_acquire_lock(lock, 1);
result = (*acquisition_count)--;
PyThread_release_lock(lock);
return result;
}
static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
{
int first_time;
struct __pyx_memoryview_obj *memview = memslice->memview;
if (!memview || (PyObject *) memview == Py_None)
return;
if (__pyx_get_slice_count(memview) < 0)
__pyx_fatalerror("Acquisition count is %d (line %d)",
__pyx_get_slice_count(memview), lineno);
first_time = __pyx_add_acquisition_count(memview) == 0;
if (first_time) {
if (have_gil) {
Py_INCREF((PyObject *) memview);
} else {
PyGILState_STATE _gilstate = PyGILState_Ensure();
Py_INCREF((PyObject *) memview);
PyGILState_Release(_gilstate);
}
}
}
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
int have_gil, int lineno) {
int last_time;
struct __pyx_memoryview_obj *memview = memslice->memview;
if (!memview ) {
return;
} else if ((PyObject *) memview == Py_None) {
memslice->memview = NULL;
return;
}
if (__pyx_get_slice_count(memview) <= 0)
__pyx_fatalerror("Acquisition count is %d (line %d)",
__pyx_get_slice_count(memview), lineno);
last_time = __pyx_sub_acquisition_count(memview) == 1;
memslice->data = NULL;
if (last_time) {
if (have_gil) {
Py_CLEAR(memslice->memview);
} else {
PyGILState_STATE _gilstate = PyGILState_Ensure();
Py_CLEAR(memslice->memview);
PyGILState_Release(_gilstate);
}
} else {
memslice->memview = NULL;
}
}
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
PyErr_Format(PyExc_TypeError,
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact)
{
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (none_allowed && obj == Py_None) return 1;
else if (exact) {
if (likely(Py_TYPE(obj) == type)) return 1;
#if PY_MAJOR_VERSION == 2
else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
#endif
}
else {
if (likely(PyObject_TypeCheck(obj, type))) return 1;
}
__Pyx_RaiseArgumentTypeInvalid(name, obj, type);
return 0;
}
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
return PyObject_RichCompareBool(s1, s2, equals);
#else
if (s1 == s2) {
return (equals == Py_EQ);
} else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
const char *ps1, *ps2;
Py_ssize_t length = PyBytes_GET_SIZE(s1);
if (length != PyBytes_GET_SIZE(s2))
return (equals == Py_NE);
ps1 = PyBytes_AS_STRING(s1);
ps2 = PyBytes_AS_STRING(s2);
if (ps1[0] != ps2[0]) {
return (equals == Py_NE);
} else if (length == 1) {
return (equals == Py_EQ);
} else {
int result = memcmp(ps1, ps2, (size_t)length);
return (equals == Py_EQ) ? (result == 0) : (result != 0);
}
} else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
return (equals == Py_NE);
} else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
return (equals == Py_NE);
} else {
int result;
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
if (!py_result)
return -1;
result = __Pyx_PyObject_IsTrue(py_result);
Py_DECREF(py_result);
return result;
}
#endif
}
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
PyObject* owned_ref = NULL;
#endif
int s1_is_unicode, s2_is_unicode;
if (s1 == s2) {
goto return_eq;
}
s1_is_unicode = PyUnicode_CheckExact(s1);
s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
owned_ref = PyUnicode_FromObject(s2);
if (unlikely(!owned_ref))
return -1;
s2 = owned_ref;
s2_is_unicode = 1;
} else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
owned_ref = PyUnicode_FromObject(s1);
if (unlikely(!owned_ref))
return -1;
s1 = owned_ref;
s1_is_unicode = 1;
} else if (((!s2_is_unicode) & (!s1_is_unicode))) {
return __Pyx_PyBytes_Equals(s1, s2, equals);
}
#endif
if (s1_is_unicode & s2_is_unicode) {
Py_ssize_t length;
int kind;
void *data1, *data2;
if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
return -1;
length = __Pyx_PyUnicode_GET_LENGTH(s1);
if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
goto return_ne;
}
kind = __Pyx_PyUnicode_KIND(s1);
if (kind != __Pyx_PyUnicode_KIND(s2)) {
goto return_ne;
}
data1 = __Pyx_PyUnicode_DATA(s1);
data2 = __Pyx_PyUnicode_DATA(s2);
if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
goto return_ne;
} else if (length == 1) {
goto return_eq;
} else {
int result = memcmp(data1, data2, (size_t)(length * kind));
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_EQ) ? (result == 0) : (result != 0);
}
} else if ((s1 == Py_None) & s2_is_unicode) {
goto return_ne;
} else if ((s2 == Py_None) & s1_is_unicode) {
goto return_ne;
} else {
int result;
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
if (!py_result)
return -1;
result = __Pyx_PyObject_IsTrue(py_result);
Py_DECREF(py_result);
return result;
}
return_eq:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_EQ);
return_ne:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_NE);
#endif
}
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
Py_ssize_t q = a / b;
Py_ssize_t r = a - q*b;
q -= ((r != 0) & ((r ^ b) < 0));
return q;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
if (likely(PyUnicode_Check(n)))
#else
if (likely(PyString_Check(n)))
#endif
return __Pyx_PyObject_GetAttrStr(o, n);
#endif
return PyObject_GetAttr(o, n);
}
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
const char* cstring, Py_ssize_t start, Py_ssize_t stop,
const char* encoding, const char* errors,
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
Py_ssize_t length;
if (unlikely((start < 0) | (stop < 0))) {
size_t slen = strlen(cstring);
if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
PyErr_SetString(PyExc_OverflowError,
"c-string too long to convert to Python");
return NULL;
}
length = (Py_ssize_t) slen;
if (start < 0) {
start += length;
if (start < 0)
start = 0;
}
if (stop < 0)
stop += length;
}
length = stop - start;
if (unlikely(length <= 0))
return PyUnicode_FromUnicode(NULL, 0);
cstring += start;
if (decode_func) {
return decode_func(cstring, length, errors);
} else {
return PyUnicode_Decode(cstring, length, encoding, errors);
}
}
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (likely(PyObject_TypeCheck(obj, type)))
return 1;
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
Py_TYPE(obj)->tp_name, type->tp_name);
return 0;
}
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = *type;
tstate->exc_value = *value;
tstate->exc_traceback = *tb;
#else
PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
PyErr_SetExcInfo(*type, *value, *tb);
#endif
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
}
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(op1))) {
const long b = intval;
long x;
long a = PyInt_AS_LONG(op1);
x = (long)((unsigned long)a + b);
if (likely((x^a) >= 0 || (x^b) >= 0))
return PyInt_FromLong(x);
return PyLong_Type.tp_as_number->nb_add(op1, op2);
}
#endif
#if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
if (likely(PyLong_CheckExact(op1))) {
const long b = intval;
long a, x;
const PY_LONG_LONG llb = intval;
PY_LONG_LONG lla, llx;
const digit* digits = ((PyLongObject*)op1)->ob_digit;
const Py_ssize_t size = Py_SIZE(op1);
if (likely(__Pyx_sst_abs(size) <= 1)) {
a = likely(size) ? digits[0] : 0;
if (size == -1) a = -a;
} else {
switch (size) {
case -2:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
case 2:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
case -3:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
case 3:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
case -4:
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
case 4:
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
}
default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
}
}
x = a + b;
return PyLong_FromLong(x);
long_long:
llx = lla + llb;
return PyLong_FromLongLong(llx);
}
#endif
if (PyFloat_CheckExact(op1)) {
const long b = intval;
double a = PyFloat_AS_DOUBLE(op1);
double result;
PyFPE_START_PROTECT("add", return NULL)
result = ((double)a) + (double)b;
PyFPE_END_PROTECT(result)
return PyFloat_FromDouble(result);
}
return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}
static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
long q = a / b;
long r = a - q*b;
q -= ((r != 0) & ((r ^ b) < 0));
return q;
}
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
int full_traceback, CYTHON_UNUSED int nogil) {
PyObject *old_exc, *old_val, *old_tb;
PyObject *ctx;
#ifdef WITH_THREAD
PyGILState_STATE state;
if (nogil)
state = PyGILState_Ensure();
#endif
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
if (full_traceback) {
Py_XINCREF(old_exc);
Py_XINCREF(old_val);
Py_XINCREF(old_tb);
__Pyx_ErrRestore(old_exc, old_val, old_tb);
PyErr_PrintEx(1);
}
#if PY_MAJOR_VERSION < 3
ctx = PyString_FromString(name);
#else
ctx = PyUnicode_FromString(name);
#endif
__Pyx_ErrRestore(old_exc, old_val, old_tb);
if (!ctx) {
PyErr_WriteUnraisable(Py_None);
} else {
PyErr_WriteUnraisable(ctx);
Py_DECREF(ctx);
}
#ifdef WITH_THREAD
if (nogil)
PyGILState_Release(state);
#endif
}
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
if (!ob)
goto bad;
if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
goto bad;
Py_DECREF(ob);
return 0;
bad:
Py_XDECREF(ob);
return -1;
}
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
PyObject* fake_module;
PyTypeObject* cached_type = NULL;
fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
if (!fake_module) return NULL;
Py_INCREF(fake_module);
cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
if (cached_type) {
if (!PyType_Check((PyObject*)cached_type)) {
PyErr_Format(PyExc_TypeError,
"Shared Cython type %.200s is not a type object",
type->tp_name);
goto bad;
}
if (cached_type->tp_basicsize != type->tp_basicsize) {
PyErr_Format(PyExc_TypeError,
"Shared Cython type %.200s has the wrong size, try recompiling",
type->tp_name);
goto bad;
}
} else {
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
PyErr_Clear();
if (PyType_Ready(type) < 0) goto bad;
if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
goto bad;
Py_INCREF(type);
cached_type = type;
}
done:
Py_DECREF(fake_module);
return cached_type;
bad:
Py_XDECREF(cached_type);
cached_type = NULL;
goto done;
}
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
if (unlikely(op->func_doc == NULL)) {
if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
if (unlikely(op->func_doc == NULL))
return NULL;
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
Py_INCREF(op->func_doc);
return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
PyObject *tmp = op->func_doc;
if (value == NULL) {
value = Py_None;
}
Py_INCREF(value);
op->func_doc = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
if (unlikely(op->func_name == NULL))
return NULL;
}
Py_INCREF(op->func_name);
return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
PyErr_SetString(PyExc_TypeError,
"__name__ must be set to a string object");
return -1;
}
tmp = op->func_name;
Py_INCREF(value);
op->func_name = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
Py_INCREF(op->func_qualname);
return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
PyErr_SetString(PyExc_TypeError,
"__qualname__ must be set to a string object");
return -1;
}
tmp = op->func_qualname;
Py_INCREF(value);
op->func_qualname = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
PyObject *self;
self = m->func_closure;
if (self == NULL)
self = Py_None;
Py_INCREF(self);
return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
if (unlikely(op->func_dict == NULL)) {
op->func_dict = PyDict_New();
if (unlikely(op->func_dict == NULL))
return NULL;
}
Py_INCREF(op->func_dict);
return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
PyObject *tmp;
if (unlikely(value == NULL)) {
PyErr_SetString(PyExc_TypeError,
"function's dictionary may not be deleted");
return -1;
}
if (unlikely(!PyDict_Check(value))) {
PyErr_SetString(PyExc_TypeError,
"setting function's dictionary to a non-dict");
return -1;
}
tmp = op->func_dict;
Py_INCREF(value);
op->func_dict = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
Py_INCREF(op->func_globals);
return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
PyObject* result = (op->func_code) ? op->func_code : Py_None;
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
int result = 0;
PyObject *res = op->defaults_getter((PyObject *) op);
if (unlikely(!res))
return -1;
#if CYTHON_COMPILING_IN_CPYTHON
op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
Py_INCREF(op->defaults_tuple);
op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
Py_INCREF(op->defaults_kwdict);
#else
op->defaults_tuple = PySequence_ITEM(res, 0);
if (unlikely(!op->defaults_tuple)) result = -1;
else {
op->defaults_kwdict = PySequence_ITEM(res, 1);
if (unlikely(!op->defaults_kwdict)) result = -1;
}
#endif
Py_DECREF(res);
return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
PyObject* tmp;
if (!value) {
value = Py_None;
} else if (value != Py_None && !PyTuple_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__defaults__ must be set to a tuple object");
return -1;
}
Py_INCREF(value);
tmp = op->defaults_tuple;
op->defaults_tuple = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
PyObject* result = op->defaults_tuple;
if (unlikely(!result)) {
if (op->defaults_getter) {
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
result = op->defaults_tuple;
} else {
result = Py_None;
}
}
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
PyObject* tmp;
if (!value) {
value = Py_None;
} else if (value != Py_None && !PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__kwdefaults__ must be set to a dict object");
return -1;
}
Py_INCREF(value);
tmp = op->defaults_kwdict;
op->defaults_kwdict = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
PyObject* result = op->defaults_kwdict;
if (unlikely(!result)) {
if (op->defaults_getter) {
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
result = op->defaults_kwdict;
} else {
result = Py_None;
}
}
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
PyObject* tmp;
if (!value || value == Py_None) {
value = NULL;
} else if (!PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__annotations__ must be set to a dict object");
return -1;
}
Py_XINCREF(value);
tmp = op->func_annotations;
op->func_annotations = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
PyObject* result = op->func_annotations;
if (unlikely(!result)) {
result = PyDict_New();
if (unlikely(!result)) return NULL;
op->func_annotations = result;
}
Py_INCREF(result);
return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
{(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
{(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
{(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
{(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
{(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
{(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
{(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
{(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
{(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
{(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
{(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
{(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
{(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
{(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
{(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
{(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
{(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
{(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
{0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
{(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
{0, 0, 0, 0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
{"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
{0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
__pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
if (op == NULL)
return NULL;
op->flags = flags;
__Pyx_CyFunction_weakreflist(op) = NULL;
op->func.m_ml = ml;
op->func.m_self = (PyObject *) op;
Py_XINCREF(closure);
op->func_closure = closure;
Py_XINCREF(module);
op->func.m_module = module;
op->func_dict = NULL;
op->func_name = NULL;
Py_INCREF(qualname);
op->func_qualname = qualname;
op->func_doc = NULL;
op->func_classobj = NULL;
op->func_globals = globals;
Py_INCREF(op->func_globals);
Py_XINCREF(code);
op->func_code = code;
op->defaults_pyobjects = 0;
op->defaults = NULL;
op->defaults_tuple = NULL;
op->defaults_kwdict = NULL;
op->defaults_getter = NULL;
op->func_annotations = NULL;
PyObject_GC_Track(op);
return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
Py_CLEAR(m->func_closure);
Py_CLEAR(m->func.m_module);
Py_CLEAR(m->func_dict);
Py_CLEAR(m->func_name);
Py_CLEAR(m->func_qualname);
Py_CLEAR(m->func_doc);
Py_CLEAR(m->func_globals);
Py_CLEAR(m->func_code);
Py_CLEAR(m->func_classobj);
Py_CLEAR(m->defaults_tuple);
Py_CLEAR(m->defaults_kwdict);
Py_CLEAR(m->func_annotations);
if (m->defaults) {
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
int i;
for (i = 0; i < m->defaults_pyobjects; i++)
Py_XDECREF(pydefaults[i]);
PyMem_Free(m->defaults);
m->defaults = NULL;
}
return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
PyObject_GC_UnTrack(m);
if (__Pyx_CyFunction_weakreflist(m) != NULL)
PyObject_ClearWeakRefs((PyObject *) m);
__Pyx_CyFunction_clear(m);
PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
Py_VISIT(m->func_closure);
Py_VISIT(m->func.m_module);
Py_VISIT(m->func_dict);
Py_VISIT(m->func_name);
Py_VISIT(m->func_qualname);
Py_VISIT(m->func_doc);
Py_VISIT(m->func_globals);
Py_VISIT(m->func_code);
Py_VISIT(m->func_classobj);
Py_VISIT(m->defaults_tuple);
Py_VISIT(m->defaults_kwdict);
if (m->defaults) {
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
int i;
for (i = 0; i < m->defaults_pyobjects; i++)
Py_VISIT(pydefaults[i]);
}
return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
Py_INCREF(func);
return func;
}
if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
if (type == NULL)
type = (PyObject *)(Py_TYPE(obj));
return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
}
if (obj == Py_None)
obj = NULL;
return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromFormat("<cyfunction %U at %p>",
op->func_qualname, (void *)op);
#else
return PyString_FromFormat("<cyfunction %s at %p>",
PyString_AsString(op->func_qualname), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
PyCFunctionObject* f = (PyCFunctionObject*)func;
PyCFunction meth = f->m_ml->ml_meth;
PyObject *self = f->m_self;
Py_ssize_t size;
switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
case METH_VARARGS:
if (likely(kw == NULL || PyDict_Size(kw) == 0))
return (*meth)(self, arg);
break;
case METH_VARARGS | METH_KEYWORDS:
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
case METH_NOARGS:
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
size = PyTuple_GET_SIZE(arg);
if (likely(size == 0))
return (*meth)(self, NULL);
PyErr_Format(PyExc_TypeError,
"%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
f->m_ml->ml_name, size);
return NULL;
}
break;
case METH_O:
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
size = PyTuple_GET_SIZE(arg);
if (likely(size == 1)) {
PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
if (unlikely(!arg0)) return NULL;
result = (*meth)(self, arg0);
Py_DECREF(arg0);
return result;
}
PyErr_Format(PyExc_TypeError,
"%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
f->m_ml->ml_name, size);
return NULL;
}
break;
default:
PyErr_SetString(PyExc_SystemError, "Bad call flags in "
"__Pyx_CyFunction_Call. METH_OLDARGS is no "
"longer supported!");
return NULL;
}
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
f->m_ml->ml_name);
return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"cython_function_or_method",
sizeof(__pyx_CyFunctionObject),
0,
(destructor) __Pyx_CyFunction_dealloc,
0,
0,
0,
#if PY_MAJOR_VERSION < 3
0,
#else
0,
#endif
(reprfunc) __Pyx_CyFunction_repr,
0,
0,
0,
0,
__Pyx_CyFunction_Call,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
0,
(traverseproc) __Pyx_CyFunction_traverse,
(inquiry) __Pyx_CyFunction_clear,
0,
#if PY_VERSION_HEX < 0x030500A0
offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
offsetof(PyCFunctionObject, m_weakreflist),
#endif
0,
0,
__pyx_CyFunction_methods,
__pyx_CyFunction_members,
__pyx_CyFunction_getsets,
0,
0,
__Pyx_CyFunction_descr_get,
0,
offsetof(__pyx_CyFunctionObject, func_dict),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
#if PY_VERSION_HEX >= 0x030400a1
0,
#endif
};
static int __pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
__pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
__pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
if (__pyx_CyFunctionType == NULL) {
return -1;
}
return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults = PyMem_Malloc(size);
if (!m->defaults)
return PyErr_NoMemory();
memset(m->defaults, 0, size);
m->defaults_pyobjects = pyobjects;
return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults_tuple = tuple;
Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults_kwdict = dict;
Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->func_annotations = dict;
Py_INCREF(dict);
}
static PyObject *
__pyx_FusedFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
PyObject *qualname, PyObject *self,
PyObject *module, PyObject *globals,
PyObject *code)
{
__pyx_FusedFunctionObject *fusedfunc =
(__pyx_FusedFunctionObject *) __Pyx_CyFunction_New(type, ml, flags, qualname,
self, module, globals, code);
if (!fusedfunc)
return NULL;
fusedfunc->__signatures__ = NULL;
fusedfunc->type = NULL;
fusedfunc->self = NULL;
return (PyObject *) fusedfunc;
}
static void __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self) {
__pyx_FusedFunction_clear(self);
__pyx_FusedFunctionType->tp_free((PyObject *) self);
}
static int
__pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self,
visitproc visit,
void *arg)
{
Py_VISIT(self->self);
Py_VISIT(self->type);
Py_VISIT(self->__signatures__);
return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg);
}
static int
__pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self)
{
Py_CLEAR(self->self);
Py_CLEAR(self->type);
Py_CLEAR(self->__signatures__);
return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self);
}
static PyObject *
__pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
__pyx_FusedFunctionObject *func, *meth;
func = (__pyx_FusedFunctionObject *) self;
if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) {
Py_INCREF(self);
return self;
}
if (obj == Py_None)
obj = NULL;
meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_NewEx(
((PyCFunctionObject *) func)->m_ml,
((__pyx_CyFunctionObject *) func)->flags,
((__pyx_CyFunctionObject *) func)->func_qualname,
((__pyx_CyFunctionObject *) func)->func_closure,
((PyCFunctionObject *) func)->m_module,
((__pyx_CyFunctionObject *) func)->func_globals,
((__pyx_CyFunctionObject *) func)->func_code);
if (!meth)
return NULL;
Py_XINCREF(func->func.func_classobj);
meth->func.func_classobj = func->func.func_classobj;
Py_XINCREF(func->__signatures__);
meth->__signatures__ = func->__signatures__;
Py_XINCREF(type);
meth->type = type;
Py_XINCREF(func->func.defaults_tuple);
meth->func.defaults_tuple = func->func.defaults_tuple;
if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD)
obj = type;
Py_XINCREF(obj);
meth->self = obj;
return (PyObject *) meth;
}
static PyObject *
_obj_to_str(PyObject *obj)
{
if (PyType_Check(obj))
return PyObject_GetAttr(obj, __pyx_n_s_name_2);
else
return PyObject_Str(obj);
}
static PyObject *
__pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
{
PyObject *signature = NULL;
PyObject *unbound_result_func;
PyObject *result_func = NULL;
if (self->__signatures__ == NULL) {
PyErr_SetString(PyExc_TypeError, "Function is not fused");
return NULL;
}
if (PyTuple_Check(idx)) {
PyObject *list = PyList_New(0);
Py_ssize_t n = PyTuple_GET_SIZE(idx);
PyObject *string = NULL;
PyObject *sep = NULL;
int i;
if (!list)
return NULL;
for (i = 0; i < n; i++) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *item = PyTuple_GET_ITEM(idx, i);
#else
PyObject *item = PySequence_ITEM(idx, i);
#endif
string = _obj_to_str(item);
#if !CYTHON_COMPILING_IN_CPYTHON
Py_DECREF(item);
#endif
if (!string || PyList_Append(list, string) < 0)
goto __pyx_err;
Py_DECREF(string);
}
sep = PyUnicode_FromString("|");
if (sep)
signature = PyUnicode_Join(sep, list);
__pyx_err:
;
Py_DECREF(list);
Py_XDECREF(sep);
} else {
signature = _obj_to_str(idx);
}
if (!signature)
return NULL;
unbound_result_func = PyObject_GetItem(self->__signatures__, signature);
if (unbound_result_func) {
if (self->self || self->type) {
__pyx_FusedFunctionObject *unbound = (__pyx_FusedFunctionObject *) unbound_result_func;
Py_CLEAR(unbound->func.func_classobj);
Py_XINCREF(self->func.func_classobj);
unbound->func.func_classobj = self->func.func_classobj;
result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
self->self, self->type);
} else {
result_func = unbound_result_func;
Py_INCREF(result_func);
}
}
Py_DECREF(signature);
Py_XDECREF(unbound_result_func);
return result_func;
}
static PyObject *
__pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
{
__pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
PyObject *result;
int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
!((__pyx_FusedFunctionObject *) func)->__signatures__);
if (cyfunc->flags & __Pyx_CYFUNCTION_CCLASS && !static_specialized) {
Py_ssize_t argc;
PyObject *new_args;
PyObject *self;
PyObject *m_self;
argc = PyTuple_GET_SIZE(args);
new_args = PyTuple_GetSlice(args, 1, argc);
if (!new_args)
return NULL;
self = PyTuple_GetItem(args, 0);
if (!self)
return NULL;
m_self = cyfunc->func.m_self;
cyfunc->func.m_self = self;
result = __Pyx_CyFunction_Call(func, new_args, kw);
cyfunc->func.m_self = m_self;
Py_DECREF(new_args);
} else {
result = __Pyx_CyFunction_Call(func, args, kw);
}
return result;
}
static PyObject *
__pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
{
__pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func;
Py_ssize_t argc = PyTuple_GET_SIZE(args);
PyObject *new_args = NULL;
__pyx_FusedFunctionObject *new_func = NULL;
PyObject *result = NULL;
PyObject *self = NULL;
int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD;
int is_classmethod = binding_func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD;
if (binding_func->self) {
Py_ssize_t i;
new_args = PyTuple_New(argc + 1);
if (!new_args)
return NULL;
self = binding_func->self;
#if !CYTHON_COMPILING_IN_CPYTHON
Py_INCREF(self);
#endif
Py_INCREF(self);
PyTuple_SET_ITEM(new_args, 0, self);
for (i = 0; i < argc; i++) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *item = PyTuple_GET_ITEM(args, i);
Py_INCREF(item);
#else
PyObject *item = PySequence_ITEM(args, i); if (unlikely(!item)) goto bad;
#endif
PyTuple_SET_ITEM(new_args, i + 1, item);
}
args = new_args;
} else if (binding_func->type) {
if (argc < 1) {
PyErr_SetString(PyExc_TypeError, "Need at least one argument, 0 given.");
return NULL;
}
#if CYTHON_COMPILING_IN_CPYTHON
self = PyTuple_GET_ITEM(args, 0);
#else
self = PySequence_ITEM(args, 0); if (unlikely(!self)) return NULL;
#endif
}
if (self && !is_classmethod && !is_staticmethod) {
int is_instance = PyObject_IsInstance(self, binding_func->type);
if (unlikely(!is_instance)) {
PyErr_Format(PyExc_TypeError,
"First argument should be of type %.200s, got %.200s.",
((PyTypeObject *) binding_func->type)->tp_name,
self->ob_type->tp_name);
goto bad;
} else if (unlikely(is_instance == -1)) {
goto bad;
}
}
#if !CYTHON_COMPILING_IN_CPYTHON
Py_XDECREF(self);
self = NULL;
#endif
if (binding_func->__signatures__) {
PyObject *tup = PyTuple_Pack(4, binding_func->__signatures__, args,
kw == NULL ? Py_None : kw,
binding_func->func.defaults_tuple);
if (!tup)
goto bad;
new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
Py_DECREF(tup);
if (!new_func)
goto bad;
Py_XINCREF(binding_func->func.func_classobj);
Py_CLEAR(new_func->func.func_classobj);
new_func->func.func_classobj = binding_func->func.func_classobj;
func = (PyObject *) new_func;
}
result = __pyx_FusedFunction_callfunction(func, args, kw);
bad:
#if !CYTHON_COMPILING_IN_CPYTHON
Py_XDECREF(self);
#endif
Py_XDECREF(new_args);
Py_XDECREF((PyObject *) new_func);
return result;
}
static PyMemberDef __pyx_FusedFunction_members[] = {
{(char *) "__signatures__",
T_OBJECT,
offsetof(__pyx_FusedFunctionObject, __signatures__),
READONLY,
0},
{0, 0, 0, 0, 0},
};
static PyMappingMethods __pyx_FusedFunction_mapping_methods = {
0,
(binaryfunc) __pyx_FusedFunction_getitem,
0,
};
static PyTypeObject __pyx_FusedFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"fused_cython_function",
sizeof(__pyx_FusedFunctionObject),
0,
(destructor) __pyx_FusedFunction_dealloc,
0,
0,
0,
#if PY_MAJOR_VERSION < 3
0,
#else
0,
#endif
0,
0,
0,
&__pyx_FusedFunction_mapping_methods,
0,
(ternaryfunc) __pyx_FusedFunction_call,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
0,
(traverseproc) __pyx_FusedFunction_traverse,
(inquiry) __pyx_FusedFunction_clear,
0,
0,
0,
0,
0,
__pyx_FusedFunction_members,
__pyx_CyFunction_getsets,
&__pyx_CyFunctionType_type,
0,
__pyx_FusedFunction_descr_get,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
#if PY_VERSION_HEX >= 0x030400a1
0,
#endif
};
static int __pyx_FusedFunction_init(void) {
__pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type);
if (__pyx_FusedFunctionType == NULL) {
return -1;
}
return 0;
}
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
int start = 0, mid = 0, end = count - 1;
if (end >= 0 && code_line > entries[end].code_line) {
return count;
}
while (start < end) {
mid = start + (end - start) / 2;
if (code_line < entries[mid].code_line) {
end = mid;
} else if (code_line > entries[mid].code_line) {
start = mid + 1;
} else {
return mid;
}
}
if (code_line <= entries[mid].code_line) {
return mid;
} else {
return mid + 1;
}
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
PyCodeObject* code_object;
int pos;
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
return NULL;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
return NULL;
}
code_object = __pyx_code_cache.entries[pos].code_object;
Py_INCREF(code_object);
return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
int pos, i;
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
if (unlikely(!code_line)) {
return;
}
if (unlikely(!entries)) {
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
if (likely(entries)) {
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = 64;
__pyx_code_cache.count = 1;
entries[0].code_line = code_line;
entries[0].code_object = code_object;
Py_INCREF(code_object);
}
return;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
PyCodeObject* tmp = entries[pos].code_object;
entries[pos].code_object = code_object;
Py_DECREF(tmp);
return;
}
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
int new_max = __pyx_code_cache.max_count + 64;
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
__pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
if (unlikely(!entries)) {
return;
}
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = new_max;
}
for (i=__pyx_code_cache.count; i>pos; i--) {
entries[i] = entries[i-1];
}
entries[pos].code_line = code_line;
entries[pos].code_object = code_object;
__pyx_code_cache.count++;
Py_INCREF(code_object);
}
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyObject *py_srcfile = 0;
PyObject *py_funcname = 0;
#if PY_MAJOR_VERSION < 3
py_srcfile = PyString_FromString(filename);
#else
py_srcfile = PyUnicode_FromString(filename);
#endif
if (!py_srcfile) goto bad;
if (c_line) {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#else
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#endif
}
else {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromString(funcname);
#else
py_funcname = PyUnicode_FromString(funcname);
#endif
}
if (!py_funcname) goto bad;
py_code = __Pyx_PyCode_New(
0,
0,
0,
0,
0,
__pyx_empty_bytes, /*PyObject *code,*/
__pyx_empty_tuple, /*PyObject *consts,*/
__pyx_empty_tuple, /*PyObject *names,*/
__pyx_empty_tuple, /*PyObject *varnames,*/
__pyx_empty_tuple, /*PyObject *freevars,*/
__pyx_empty_tuple, /*PyObject *cellvars,*/
py_srcfile, /*PyObject *filename,*/
py_funcname, /*PyObject *name,*/
py_line,
__pyx_empty_bytes /*PyObject *lnotab*/
);
Py_DECREF(py_srcfile);
Py_DECREF(py_funcname);
return py_code;
bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
py_code = __pyx_find_code_object(c_line ? c_line : py_line);
if (!py_code) {
py_code = __Pyx_CreateCodeObjectForTraceback(
funcname, c_line, py_line, filename);
if (!py_code) goto bad;
__pyx_insert_code_object(c_line ? c_line : py_line, py_code);
}
py_frame = PyFrame_New(
PyThreadState_GET(), /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
__pyx_d, /*PyObject *globals,*/
0 /*PyObject *locals*/
);
if (!py_frame) goto bad;
py_frame->f_lineno = py_line;
PyTraceBack_Here(py_frame);
bad:
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
}
static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
int i;
if (!a || !b)
return 0;
if (a == b)
return 1;
if (a->size != b->size || a->typegroup != b->typegroup ||
a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
if (a->typegroup == 'H' || b->typegroup == 'H') {
return a->size == b->size;
} else {
return 0;
}
}
if (a->ndim) {
for (i = 0; i < a->ndim; i++)
if (a->arraysize[i] != b->arraysize[i])
return 0;
}
if (a->typegroup == 'S') {
if (a->flags != b->flags)
return 0;
if (a->fields || b->fields) {
if (!(a->fields && b->fields))
return 0;
for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
__Pyx_StructField *field_a = a->fields + i;
__Pyx_StructField *field_b = b->fields + i;
if (field_a->offset != field_b->offset ||
!__pyx_typeinfo_cmp(field_a->type, field_b->type))
return 0;
}
return !a->fields[i].type && !b->fields[i].type;
}
}
return 1;
}
static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
if (buf->shape[dim] <= 1)
return 1;
if (buf->strides) {
if (spec & __Pyx_MEMVIEW_CONTIG) {
if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
if (buf->strides[dim] != sizeof(void *)) {
PyErr_Format(PyExc_ValueError,
"Buffer is not indirectly contiguous "
"in dimension %d.", dim);
goto fail;
}
} else if (buf->strides[dim] != buf->itemsize) {
PyErr_SetString(PyExc_ValueError,
"Buffer and memoryview are not contiguous "
"in the same dimension.");
goto fail;
}
}
if (spec & __Pyx_MEMVIEW_FOLLOW) {
Py_ssize_t stride = buf->strides[dim];
if (stride < 0)
stride = -stride;
if (stride < buf->itemsize) {
PyErr_SetString(PyExc_ValueError,
"Buffer and memoryview are not contiguous "
"in the same dimension.");
goto fail;
}
}
} else {
if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) {
PyErr_Format(PyExc_ValueError,
"C-contiguous buffer is not contiguous in "
"dimension %d", dim);
goto fail;
} else if (spec & (__Pyx_MEMVIEW_PTR)) {
PyErr_Format(PyExc_ValueError,
"C-contiguous buffer is not indirect in "
"dimension %d", dim);
goto fail;
} else if (buf->suboffsets) {
PyErr_SetString(PyExc_ValueError,
"Buffer exposes suboffsets but no strides");
goto fail;
}
}
return 1;
fail:
return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
if (spec & __Pyx_MEMVIEW_DIRECT) {
if (buf->suboffsets && buf->suboffsets[dim] >= 0) {
PyErr_Format(PyExc_ValueError,
"Buffer not compatible with direct access "
"in dimension %d.", dim);
goto fail;
}
}
if (spec & __Pyx_MEMVIEW_PTR) {
if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
PyErr_Format(PyExc_ValueError,
"Buffer is not indirectly accessible "
"in dimension %d.", dim);
goto fail;
}
}
return 1;
fail:
return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
int i;
if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
Py_ssize_t stride = 1;
for (i = 0; i < ndim; i++) {
if (stride * buf->itemsize != buf->strides[i] &&
buf->shape[i] > 1)
{
PyErr_SetString(PyExc_ValueError,
"Buffer not fortran contiguous.");
goto fail;
}
stride = stride * buf->shape[i];
}
} else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
Py_ssize_t stride = 1;
for (i = ndim - 1; i >- 1; i--) {
if (stride * buf->itemsize != buf->strides[i] &&
buf->shape[i] > 1) {
PyErr_SetString(PyExc_ValueError,
"Buffer not C contiguous.");
goto fail;
}
stride = stride * buf->shape[i];
}
}
return 1;
fail:
return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
int *axes_specs,
int c_or_f_flag,
int buf_flags,
int ndim,
__Pyx_TypeInfo *dtype,
__Pyx_BufFmt_StackElem stack[],
__Pyx_memviewslice *memviewslice,
PyObject *original_obj)
{
struct __pyx_memoryview_obj *memview, *new_memview;
__Pyx_RefNannyDeclarations
Py_buffer *buf;
int i, spec = 0, retval = -1;
__Pyx_BufFmt_Context ctx;
int from_memoryview = __pyx_memoryview_check(original_obj);
__Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
original_obj)->typeinfo)) {
memview = (struct __pyx_memoryview_obj *) original_obj;
new_memview = NULL;
} else {
memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
original_obj, buf_flags, 0, dtype);
new_memview = memview;
if (unlikely(!memview))
goto fail;
}
buf = &memview->view;
if (buf->ndim != ndim) {
PyErr_Format(PyExc_ValueError,
"Buffer has wrong number of dimensions (expected %d, got %d)",
ndim, buf->ndim);
goto fail;
}
if (new_memview) {
__Pyx_BufFmt_Init(&ctx, stack, dtype);
if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
}
if ((unsigned) buf->itemsize != dtype->size) {
PyErr_Format(PyExc_ValueError,
"Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
"does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
buf->itemsize,
(buf->itemsize > 1) ? "s" : "",
dtype->name,
dtype->size,
(dtype->size > 1) ? "s" : "");
goto fail;
}
for (i = 0; i < ndim; i++) {
spec = axes_specs[i];
if (!__pyx_check_strides(buf, i, ndim, spec))
goto fail;
if (!__pyx_check_suboffsets(buf, i, ndim, spec))
goto fail;
}
if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))
goto fail;
if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
new_memview != NULL) == -1)) {
goto fail;
}
retval = 0;
goto no_fail;
fail:
Py_XDECREF(new_memview);
retval = -1;
no_fail:
__Pyx_RefNannyFinishContext();
return retval;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int8_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_int8_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int16_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_int16_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int32_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_int32_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_int64_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_int64_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint8_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_uint8_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint16_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_uint16_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint32_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_uint32_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_nn_uint64_t(PyObject *obj) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT | PyBUF_WRITABLE), 1,
&__Pyx_TypeInfo_nn_uint64_t, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
if (PyObject_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
if (PyObject_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
PyObject *obj = view->obj;
if (!obj) return;
if (PyObject_CheckBuffer(obj)) {
PyBuffer_Release(view);
return;
}
Py_DECREF(obj);
view->obj = NULL;
}
#endif
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
const long neg_one = (long) -1, const_zero = (long) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(long) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(long) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(long) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(long),
little, !is_unsigned);
}
}
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
const Py_ssize_t length = PyBytes_GET_SIZE(bytes);
char* char_start = PyBytes_AS_STRING(bytes);
char* pos;
for (pos=char_start; pos < char_start+length; pos++) {
if (character == pos[0]) return 1;
}
return 0;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int8_t(int8_t value) {
const int8_t neg_one = (int8_t) -1, const_zero = (int8_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int8_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int8_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(int8_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(int8_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int8_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int8_t),
little, !is_unsigned);
}
}
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
{\
func_type value = func_value;\
if (sizeof(target_type) < sizeof(func_type)) {\
if (unlikely(value != (func_type) (target_type) value)) {\
func_type zero = 0;\
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
return (target_type) -1;\
if (is_unsigned && unlikely(value < zero))\
goto raise_neg_overflow;\
else\
goto raise_overflow;\
}\
}\
return (target_type) value;\
}
static CYTHON_INLINE int8_t __Pyx_PyInt_As_int8_t(PyObject *x) {
const int8_t neg_one = (int8_t) -1, const_zero = (int8_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int8_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int8_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int8_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int8_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(int8_t, digit, digits[0])
case 2:
if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) >= 2 * PyLong_SHIFT) {
return (int8_t) (((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) >= 3 * PyLong_SHIFT) {
return (int8_t) (((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) >= 4 * PyLong_SHIFT) {
return (int8_t) (((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int8_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int8_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int8_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(int8_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int8_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(int8_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(int8_t, digit, +digits[0])
case -2:
if (8 * sizeof(int8_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
return (int8_t) (((int8_t)-1)*(((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int8_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
return (int8_t) ((((((int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int8_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
return (int8_t) (((int8_t)-1)*(((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int8_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
return (int8_t) ((((((((int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int8_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 4 * PyLong_SHIFT) {
return (int8_t) (((int8_t)-1)*(((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int8_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int8_t) - 1 > 4 * PyLong_SHIFT) {
return (int8_t) ((((((((((int8_t)digits[3]) << PyLong_SHIFT) | (int8_t)digits[2]) << PyLong_SHIFT) | (int8_t)digits[1]) << PyLong_SHIFT) | (int8_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(int8_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int8_t, long, PyLong_AsLong(x))
} else if (sizeof(int8_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int8_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int8_t) -1;
}
} else {
int8_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (int8_t) -1;
val = __Pyx_PyInt_As_int8_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int8_t");
return (int8_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int8_t");
return (int8_t) -1;
}
static PyObject *__pyx_memview_get_nn_int8_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_int8_t(*(int8_t *) itemp);
}
static int __pyx_memview_set_nn_int8_t(const char *itemp, PyObject *obj) {
int8_t value = __Pyx_PyInt_As_int8_t(obj);
if ((value == (int8_t)-1) && PyErr_Occurred())
return 0;
*(int8_t *) itemp = value;
return 1;
}
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
const int neg_one = (int) -1, const_zero = (int) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
case -2:
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
}
#endif
if (sizeof(int) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int) -1;
}
} else {
int val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (int) -1;
val = __Pyx_PyInt_As_int(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int");
return (int) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int");
return (int) -1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value) {
const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int16_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int16_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(int16_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int16_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *x) {
const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int16_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int16_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int16_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int16_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(int16_t, digit, digits[0])
case 2:
if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) >= 2 * PyLong_SHIFT) {
return (int16_t) (((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) >= 3 * PyLong_SHIFT) {
return (int16_t) (((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) >= 4 * PyLong_SHIFT) {
return (int16_t) (((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int16_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int16_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int16_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(int16_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(int16_t, digit, +digits[0])
case -2:
if (8 * sizeof(int16_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
return (int16_t) (((int16_t)-1)*(((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
return (int16_t) ((((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
return (int16_t) (((int16_t)-1)*(((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
return (int16_t) ((((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
return (int16_t) (((int16_t)-1)*(((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
return (int16_t) ((((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(int16_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int16_t, long, PyLong_AsLong(x))
} else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int16_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int16_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int16_t) -1;
}
} else {
int16_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (int16_t) -1;
val = __Pyx_PyInt_As_int16_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int16_t");
return (int16_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int16_t");
return (int16_t) -1;
}
static PyObject *__pyx_memview_get_nn_int16_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_int16_t(*(int16_t *) itemp);
}
static int __pyx_memview_set_nn_int16_t(const char *itemp, PyObject *obj) {
int16_t value = __Pyx_PyInt_As_int16_t(obj);
if ((value == (int16_t)-1) && PyErr_Occurred())
return 0;
*(int16_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) {
const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int32_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int32_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(int32_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int32_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int32_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int32_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int32_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0])
case 2:
if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) {
return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) {
return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) {
return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int32_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int32_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int32_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, +digits[0])
case -2:
if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(int32_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
} else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int32_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int32_t) -1;
}
} else {
int32_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (int32_t) -1;
val = __Pyx_PyInt_As_int32_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int32_t");
return (int32_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int32_t");
return (int32_t) -1;
}
static PyObject *__pyx_memview_get_nn_int32_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_int32_t(*(int32_t *) itemp);
}
static int __pyx_memview_set_nn_int32_t(const char *itemp, PyObject *obj) {
int32_t value = __Pyx_PyInt_As_int32_t(obj);
if ((value == (int32_t)-1) && PyErr_Occurred())
return 0;
*(int32_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int64_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int64_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(int64_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int64_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int64_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int64_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int64_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
case 2:
if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) >= 4 * PyLong_SHIFT) {
return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int64_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int64_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int64_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(int64_t, digit, +digits[0])
case -2:
if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(int64_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
} else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int64_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int64_t) -1;
}
} else {
int64_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (int64_t) -1;
val = __Pyx_PyInt_As_int64_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int64_t");
return (int64_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int64_t");
return (int64_t) -1;
}
static PyObject *__pyx_memview_get_nn_int64_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_int64_t(*(int64_t *) itemp);
}
static int __pyx_memview_set_nn_int64_t(const char *itemp, PyObject *obj) {
int64_t value = __Pyx_PyInt_As_int64_t(obj);
if ((value == (int64_t)-1) && PyErr_Occurred())
return 0;
*(int64_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(uint8_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(uint8_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *x) {
const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(uint8_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(uint8_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (uint8_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint8_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, digits[0])
case 2:
if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) >= 2 * PyLong_SHIFT) {
return (uint8_t) (((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) >= 3 * PyLong_SHIFT) {
return (uint8_t) (((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) >= 4 * PyLong_SHIFT) {
return (uint8_t) (((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (uint8_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(uint8_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint8_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(uint8_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, +digits[0])
case -2:
if (8 * sizeof(uint8_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
return (uint8_t) (((uint8_t)-1)*(((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
return (uint8_t) ((((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
return (uint8_t) (((uint8_t)-1)*(((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
return (uint8_t) ((((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
return (uint8_t) (((uint8_t)-1)*(((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
return (uint8_t) ((((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(uint8_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint8_t, long, PyLong_AsLong(x))
} else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
uint8_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (uint8_t) -1;
}
} else {
uint8_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (uint8_t) -1;
val = __Pyx_PyInt_As_uint8_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to uint8_t");
return (uint8_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to uint8_t");
return (uint8_t) -1;
}
static PyObject *__pyx_memview_get_nn_uint8_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_uint8_t(*(uint8_t *) itemp);
}
static int __pyx_memview_set_nn_uint8_t(const char *itemp, PyObject *obj) {
uint8_t value = __Pyx_PyInt_As_uint8_t(obj);
if ((value == (uint8_t)-1) && PyErr_Occurred())
return 0;
*(uint8_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value) {
const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(uint16_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint16_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(uint16_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(uint16_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE uint16_t __Pyx_PyInt_As_uint16_t(PyObject *x) {
const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(uint16_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(uint16_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (uint16_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint16_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(uint16_t, digit, digits[0])
case 2:
if (8 * sizeof(uint16_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) >= 2 * PyLong_SHIFT) {
return (uint16_t) (((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(uint16_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) >= 3 * PyLong_SHIFT) {
return (uint16_t) (((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(uint16_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) >= 4 * PyLong_SHIFT) {
return (uint16_t) (((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (uint16_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(uint16_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint16_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint16_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint16_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(uint16_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(uint16_t, digit, +digits[0])
case -2:
if (8 * sizeof(uint16_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
return (uint16_t) (((uint16_t)-1)*(((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(uint16_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
return (uint16_t) ((((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
return (uint16_t) (((uint16_t)-1)*(((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(uint16_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
return (uint16_t) ((((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 4 * PyLong_SHIFT) {
return (uint16_t) (((uint16_t)-1)*(((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(uint16_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint16_t) - 1 > 4 * PyLong_SHIFT) {
return (uint16_t) ((((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(uint16_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint16_t, long, PyLong_AsLong(x))
} else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint16_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
uint16_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (uint16_t) -1;
}
} else {
uint16_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (uint16_t) -1;
val = __Pyx_PyInt_As_uint16_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to uint16_t");
return (uint16_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to uint16_t");
return (uint16_t) -1;
}
static PyObject *__pyx_memview_get_nn_uint16_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_uint16_t(*(uint16_t *) itemp);
}
static int __pyx_memview_set_nn_uint16_t(const char *itemp, PyObject *obj) {
uint16_t value = __Pyx_PyInt_As_uint16_t(obj);
if ((value == (uint16_t)-1) && PyErr_Occurred())
return 0;
*(uint16_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(uint32_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(uint32_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(uint32_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (uint32_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint32_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
case 2:
if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (uint32_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(uint32_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint32_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, +digits[0])
case -2:
if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(uint32_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
} else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
uint32_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (uint32_t) -1;
}
} else {
uint32_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (uint32_t) -1;
val = __Pyx_PyInt_As_uint32_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to uint32_t");
return (uint32_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to uint32_t");
return (uint32_t) -1;
}
static PyObject *__pyx_memview_get_nn_uint32_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_uint32_t(*(uint32_t *) itemp);
}
static int __pyx_memview_set_nn_uint32_t(const char *itemp, PyObject *obj) {
uint32_t value = __Pyx_PyInt_As_uint32_t(obj);
if ((value == (uint32_t)-1) && PyErr_Occurred())
return 0;
*(uint32_t *) itemp = value;
return 1;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(uint64_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(uint64_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
little, !is_unsigned);
}
}
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(uint64_t) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (uint64_t) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint64_t) 0;
case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
case 2:
if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) >= 4 * PyLong_SHIFT) {
return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (uint64_t) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(uint64_t) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (uint64_t) 0;
case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, +digits[0])
case -2:
if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
}
}
break;
}
#endif
if (sizeof(uint64_t) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
} else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(uint64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
uint64_t val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (uint64_t) -1;
}
} else {
uint64_t val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (uint64_t) -1;
val = __Pyx_PyInt_As_uint64_t(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to uint64_t");
return (uint64_t) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to uint64_t");
return (uint64_t) -1;
}
static PyObject *__pyx_memview_get_nn_uint64_t(const char *itemp) {
return (PyObject *) __Pyx_PyInt_From_uint64_t(*(uint64_t *) itemp);
}
static int __pyx_memview_set_nn_uint64_t(const char *itemp, PyObject *obj) {
uint64_t value = __Pyx_PyInt_As_uint64_t(obj);
if ((value == (uint64_t)-1) && PyErr_Occurred())
return 0;
*(uint64_t *) itemp = value;
return 1;
}
static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
char order, int ndim)
{
int i, index, step, start;
Py_ssize_t itemsize = mvs->memview->view.itemsize;
if (order == 'F') {
step = 1;
start = 0;
} else {
step = -1;
start = ndim - 1;
}
for (i = 0; i < ndim; i++) {
index = start + step * i;
if (mvs->suboffsets[index] >= 0 || mvs->strides[index] != itemsize)
return 0;
itemsize *= mvs->shape[index];
}
return 1;
}
static void
__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
void **out_start, void **out_end,
int ndim, size_t itemsize)
{
char *start, *end;
int i;
start = end = slice->data;
for (i = 0; i < ndim; i++) {
Py_ssize_t stride = slice->strides[i];
Py_ssize_t extent = slice->shape[i];
if (extent == 0) {
*out_start = *out_end = start;
return;
} else {
if (stride > 0)
end += stride * (extent - 1);
else
start += stride * (extent - 1);
}
}
*out_start = start;
*out_end = end + itemsize;
}
static int
__pyx_slices_overlap(__Pyx_memviewslice *slice1,
__Pyx_memviewslice *slice2,
int ndim, size_t itemsize)
{
void *start1, *end1, *start2, *end2;
__pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
__pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
return (start1 < end2) && (start2 < end1);
}
static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
const char *mode, int ndim,
size_t sizeof_dtype, int contig_flag,
int dtype_is_object)
{
__Pyx_RefNannyDeclarations
int i;
__Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
Py_buffer *buf = &from_memview->view;
PyObject *shape_tuple = NULL;
PyObject *temp_int = NULL;
struct __pyx_array_obj *array_obj = NULL;
struct __pyx_memoryview_obj *memview_obj = NULL;
__Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
for (i = 0; i < ndim; i++) {
if (from_mvs->suboffsets[i] >= 0) {
PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
"indirect dimensions (axis %d)", i);
goto fail;
}
}
shape_tuple = PyTuple_New(ndim);
if (unlikely(!shape_tuple)) {
goto fail;
}
__Pyx_GOTREF(shape_tuple);
for(i = 0; i < ndim; i++) {
temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
if(unlikely(!temp_int)) {
goto fail;
} else {
PyTuple_SET_ITEM(shape_tuple, i, temp_int);
temp_int = NULL;
}
}
array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
if (unlikely(!array_obj)) {
goto fail;
}
__Pyx_GOTREF(array_obj);
memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
(PyObject *) array_obj, contig_flag,
dtype_is_object,
from_mvs->memview->typeinfo);
if (unlikely(!memview_obj))
goto fail;
if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
goto fail;
if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
dtype_is_object) < 0))
goto fail;
goto no_fail;
fail:
__Pyx_XDECREF(new_mvs.memview);
new_mvs.memview = NULL;
new_mvs.data = NULL;
no_fail:
__Pyx_XDECREF(shape_tuple);
__Pyx_XDECREF(temp_int);
__Pyx_XDECREF(array_obj);
__Pyx_RefNannyFinishContext();
return new_mvs;
}
static CYTHON_INLINE PyObject *
__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
{
PyObject *cobj;
#if PY_VERSION_HEX >= 0x02070000
cobj = PyCapsule_New(p, sig, NULL);
#else
cobj = PyCObject_FromVoidPtr(p, NULL);
#endif
return cobj;
}
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
const int neg_one = (int) -1, const_zero = (int) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof(int) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int),
little, !is_unsigned);
}
}
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
const char neg_one = (char) -1, const_zero = (char) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(char) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (char) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (char) 0;
case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
case 2:
if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (char) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(char) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (char) 0;
case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0])
case -2:
if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
}
#endif
if (sizeof(char) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
} else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
char val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (char) -1;
}
} else {
char val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (char) -1;
val = __Pyx_PyInt_As_char(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to char");
return (char) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to char");
return (char) -1;
}
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
const long neg_one = (long) -1, const_zero = (long) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(long) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (long) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (long) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(long) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0])
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
case -2:
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
}
#endif
if (sizeof(long) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
long val;
PyObject *v = __Pyx_PyNumber_Int(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (long) -1;
}
} else {
long val;
PyObject *tmp = __Pyx_PyNumber_Int(x);
if (!tmp) return (long) -1;
val = __Pyx_PyInt_As_long(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to long");
return (long) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to long");
return (long) -1;
}
static int __Pyx_check_binary_version(void) {
char ctversion[4], rtversion[4];
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
char message[200];
PyOS_snprintf(message, sizeof(message),
"compiletime version %s of module '%.100s' "
"does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
return PyErr_WarnEx(NULL, message, 1);
}
return 0;
}
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
#if PY_MAJOR_VERSION < 3
if (t->is_unicode) {
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
} else if (t->intern) {
*t->p = PyString_InternFromString(t->s);
} else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
#else
if (t->is_unicode | t->is_str) {
if (t->intern) {
*t->p = PyUnicode_InternFromString(t->s);
} else if (t->encoding) {
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
} else {
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
}
} else {
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
}
#endif
if (!*t->p)
return -1;
++t;
}
return 0;
}
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
Py_ssize_t ignore;
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
__Pyx_sys_getdefaultencoding_not_ascii &&
#endif
PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
char* defenc_c;
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
if (!defenc) return NULL;
defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
{
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
char* c;
for (c = defenc_c; c < end; c++) {
if ((unsigned char) (*c) >= 128) {
PyUnicode_AsASCIIString(o);
return NULL;
}
}
}
#endif
*length = PyBytes_GET_SIZE(defenc);
return defenc_c;
#else
if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
if (PyUnicode_IS_ASCII(o)) {
*length = PyUnicode_GET_LENGTH(o);
return PyUnicode_AsUTF8(o);
} else {
PyUnicode_AsASCIIString(o);
return NULL;
}
#else
return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
} else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
if (PyByteArray_Check(o)) {
*length = PyByteArray_GET_SIZE(o);
return PyByteArray_AS_STRING(o);
} else
#endif
{
char* result;
int r = PyBytes_AsStringAndSize(o, &result, length);
if (unlikely(r < 0)) {
return NULL;
} else {
return result;
}
}
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
int is_true = x == Py_True;
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
PyNumberMethods *m;
const char *name = NULL;
PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
if (PyInt_Check(x) || PyLong_Check(x))
#else
if (PyLong_Check(x))
#endif
return __Pyx_NewRef(x);
m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
if (m && m->nb_int) {
name = "int";
res = PyNumber_Int(x);
}
else if (m && m->nb_long) {
name = "long";
res = PyNumber_Long(x);
}
#else
if (m && m->nb_int) {
name = "int";
res = PyNumber_Long(x);
}
#endif
if (res) {
#if PY_MAJOR_VERSION < 3
if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
if (!PyLong_Check(res)) {
#endif
PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)",
name, name, Py_TYPE(res)->tp_name);
Py_DECREF(res);
return NULL;
}
}
else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"an integer is required");
}
return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
Py_ssize_t ival;
PyObject *x;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(b))) {
if (sizeof(Py_ssize_t) >= sizeof(long))
return PyInt_AS_LONG(b);
else
return PyInt_AsSsize_t(x);
}
#endif
if (likely(PyLong_CheckExact(b))) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)b)->ob_digit;
const Py_ssize_t size = Py_SIZE(b);
if (likely(__Pyx_sst_abs(size) <= 1)) {
ival = likely(size) ? digits[0] : 0;
if (size == -1) ival = -ival;
return ival;
} else {
switch (size) {
case 2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
}
}
#endif
return PyLong_AsSsize_t(b);
}
x = PyNumber_Index(b);
if (!x) return -1;
ival = PyInt_AsSsize_t(x);
Py_DECREF(x);
return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return PyInt_FromSize_t(ival);
}
#endif /* Py_PYTHON_H */
| [
"[email protected]"
] | |
f333b5bbfc77892f42ca546d8b07a0454f1d5d01 | db856c6513e3917ac5ddd90cc372d882e98ea21c | /stim_control/src/State.hpp | da83b1c64aa1aba376c3e89d389665966fba2da4 | [] | no_license | dalejbarr/webcam_study | 2ae93c488db3e95bb5518d6ca2790b158dd7b8f5 | daf9bb3e44a2c755dc606654e9d19457d7e98dec | refs/heads/master | 2020-05-21T18:01:15.024049 | 2017-07-21T16:49:11 | 2017-07-21T16:49:11 | 63,344,808 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,118 | hpp | #ifndef ST_INCLUDED
#define ST_INCLUDED
#define EXP_EVENT_TIMER_RESOLUTION 3
#include <string>
using std::string;
#include <map>
using std::map;
using std::multimap;
using std::pair;
#include <boost/smart_ptr.hpp>
#include "Event.hpp"
#include "Watch.hpp"
#include "global.hpp"
typedef multimap<long, EventPtr> EventMap;
typedef pair<EventMap::iterator, EventMap::iterator> EventMapIter;
class Template;
//class EventTime;
class EventGrabAOI;
class State
{
protected:
long m_id;
string m_strName;
string m_strDebug;
long m_lSeq;
Uint32 m_nTimeout;
static SDL_Thread * s_pThread;
static bool s_bContinue;
//bool m_bVisited;
EventGrabAOI * m_pEvtMove;
int m_nWatchesLocked;
EventMap::iterator m_pCurEvent;
public:
EventMap m_mmapEvent;
vector<Uint32> m_vMsBegin;
static int s_nMouseX;
static int s_nMouseY;
static OpInt s_nMouseCurX;
static OpInt s_nMouseCurY;
static bool s_bFinished;
static bool s_bTimedOut;
WatchMap m_mmapWatch;
State(long id, const char * pcName, long seq);
virtual ~State();
int Load(Template * pTemplate);
int FinalSweep(Template * pTemplate); // do this after all states are loaded and before first trial
int LoadEvents(Template * pTemplate);
int LoadWatches(Template * pTemplate);
int Prepare();
int Start();
int Main();
int Run();
int Finish();
int PostTrial(); // when the trial ends
EventPtr FindEvent(long id);
EventPtr FindEventByCmdID(long id);
static Uint32 timeoutFn(Uint32 interval, void *param);
static int main(void * pVoid);
Watch * HandleEvent(SDL_Event * pEvt, Template * pThis);
Watch * ProcessMouseButton(SDL_Event * pEvt);
inline long GetSeq() { return m_lSeq; }
inline WatchMap GetWatches() { return m_mmapWatch; }
inline long GetID() { return m_id; }
inline bool WasVisited() { return (m_vMsBegin.size()>=1); }
ArgMMap GetArgs(string strTable, long id);
int Cleanup();
void LockWatches() { m_nWatchesLocked = 1; }
void UnlockWatches() { m_nWatchesLocked = 0; }
int WatchesLocked() { return m_nWatchesLocked; }
};
typedef boost::shared_ptr<State> StatePtr;
#endif
| [
"[email protected]"
] | |
1f7d7a8690e7e255906adc85a3ab0774c3d7bcbe | 35770dc2ef97ade440a774a814ac22064826d9be | /code/addbook.h | ad5a89624a666d8d59210c0c294de6b2fd65c19b | [] | no_license | alaeddinelajili/interface-graphique-d-un-gestionnaire-d-une-bibliotheque | 547726356576a13f7566e143ab74c38735986e8d | 1b82b47ce52e2ac691e08dc6931b09b76fd1a580 | refs/heads/master | 2020-03-29T00:54:32.248072 | 2018-09-18T23:03:07 | 2018-09-18T23:03:07 | 149,361,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 425 | h | #ifndef ADDBOOK_H
#define ADDBOOK_H
#include<database.h>
#include <QDialog>
namespace Ui {
class addbook;
}
class addbook : public QDialog, protected Database
{
Q_OBJECT
public:
explicit addbook(QWidget *parent = 0);
~addbook();
private slots:
void on_save_clicked();
void on_cancel_clicked();
void on_cover_clicked();
private:
Ui::addbook *ui;
QString imgPath;
};
#endif // ADDBOOK_H
| [
"[email protected]"
] | |
90c349958f51cffb9564e9e592903e66a5a2e2c6 | 21553f6afd6b81ae8403549467230cdc378f32c9 | /arm/cortex/Freescale/MK64F12/include/arch/reg/ewm.hpp | ccaf6d176f854707d7c9868d70bb82b31e213070 | [] | no_license | digint/openmptl-reg-arm-cortex | 3246b68dcb60d4f7c95a46423563cab68cb02b5e | 88e105766edc9299348ccc8d2ff7a9c34cddacd3 | refs/heads/master | 2021-07-18T19:56:42.569685 | 2017-10-26T11:11:35 | 2017-10-26T11:11:35 | 108,407,162 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,078 | hpp | /*
* OpenMPTL - C++ Microprocessor Template Library
*
* This program is a derivative representation of a CMSIS System View
* Description (SVD) file, and is subject to the corresponding license
* (see "Freescale CMSIS-SVD License Agreement.pdf" in the parent directory).
*
* 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.
*/
////////////////////////////////////////////////////////////////////////
//
// Import from CMSIS-SVD: "Freescale/MK64F12.svd"
//
// vendor: Freescale Semiconductor, Inc.
// vendorID: Freescale
// name: MK64F12
// series: Kinetis_K
// version: 1.6
// description: MK64F12 Freescale Microcontroller
// --------------------------------------------------------------------
//
// C++ Header file, containing architecture specific register
// declarations for use in OpenMPTL. It has been converted directly
// from a CMSIS-SVD file.
//
// https://digint.ch/openmptl
// https://github.com/posborne/cmsis-svd
//
#ifndef ARCH_REG_EWM_HPP_INCLUDED
#define ARCH_REG_EWM_HPP_INCLUDED
#warning "using untested register declarations"
#include <register.hpp>
namespace mptl {
/**
* External Watchdog Monitor
*/
struct EWM
{
static constexpr reg_addr_t base_addr = 0x40061000;
/**
* Control Register
*/
struct CTRL
: public reg< uint8_t, base_addr + 0, rw, 0 >
{
using type = reg< uint8_t, base_addr + 0, rw, 0 >;
using EWMEN = regbits< type, 0, 1 >; /**< EWM enable. */
using ASSIN = regbits< type, 1, 1 >; /**< EWM_in's Assertion State Select. */
using INEN = regbits< type, 2, 1 >; /**< Input Enable. */
using INTEN = regbits< type, 3, 1 >; /**< Interrupt Enable. */
};
/**
* Service Register
*/
struct SERV
: public reg< uint8_t, base_addr + 0x1, wo, 0 >
{
using type = reg< uint8_t, base_addr + 0x1, wo, 0 >;
using SERVICE = regbits< type, 0, 8 >; /**< The EWM service mechanism requires the CPU to write two values to the SERV register: a first data byte of 0xB4, followed by a second data byte of 0x2C */
};
/**
* Compare Low Register
*/
struct CMPL
: public reg< uint8_t, base_addr + 0x2, rw, 0 >
{
using type = reg< uint8_t, base_addr + 0x2, rw, 0 >;
using COMPAREL = regbits< type, 0, 8 >; /**< To prevent runaway code from changing this field, software should write to this field after a CPU reset even if the (default) minimum service time is required */
};
/**
* Compare High Register
*/
struct CMPH
: public reg< uint8_t, base_addr + 0x3, rw, 0xFF >
{
using type = reg< uint8_t, base_addr + 0x3, rw, 0xFF >;
using COMPAREH = regbits< type, 0, 8 >; /**< To prevent runaway code from changing this field, software should write to this field after a CPU reset even if the (default) maximum service time is required */
};
};
} // namespace mptl
#endif // ARCH_REG_EWM_HPP_INCLUDED
| [
"[email protected]"
] | |
7d7b064dba814f62ea255aebbc7b435a3ec14515 | 80a5735ba2abdee190144c6fe6cb8c88609c402e | /meshlab/MeshLabSrc_AllInc_v132/meshlab/src/plugins_experimental/io_3dcoform/io_3dcoform.h | 9d9ab2e11598963d578a6fcc178923ccdd5bf9cc | [] | no_license | quxiaofeng/python-stl | 8947bbd4645417fd76ef45c864e7e3f54d213a4c | 0929ada14c96511056b88e4f97474c1cee7ade79 | refs/heads/master | 2021-05-16T02:17:10.530607 | 2013-12-16T19:18:26 | 2013-12-16T19:18:26 | 12,635,141 | 10 | 4 | null | 2018-09-14T13:18:57 | 2013-09-06T03:38:26 | C | UTF-8 | C++ | false | false | 1,270 | h | #ifndef COFORMIOPLUGIN_H
#define COFORMIOPLUGIN_H
#include <QList>
#include <QStandardItemModel>
#include <common/interfaces.h>
#include "coformimportdialog.h"
class CoformIOPlugin : public QObject, public MeshIOInterface
{
Q_OBJECT
Q_INTERFACES(MeshIOInterface)
public:
CoformIOPlugin();
~CoformIOPlugin();
QList<Format> importFormats() const;
QList<Format> exportFormats() const;
inline QString CoformQueryFilePathParam() const { return "MeshLab::3D-COFORM::QueryFilePath" ; }
void GetExportMaskCapability(QString &format, int &capability, int &defaultBits) const;
bool open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet &par, vcg::CallBackPos *cb=0, QWidget *parent=0);
bool save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterSet &, vcg::CallBackPos *cb=0, QWidget *parent= 0);
private:
typedef QPair<QString,QString> UuidFileNamePair;
bool getUuidAndFileList(const QString hostURL,const int port,QList< UuidFileNamePair >& res) const;
void initImportingFiltersExt();
void setupModel();
QString CoformIOPlugin::computePluginsPath() const;
QString query() const;
QStandardItemModel* model;
CoformImportDialog* cofDiag;
};
#endif | [
"[email protected]"
] | |
00773b3b488993ecce80e7a26c83544f114ac7bd | 2f19e39d581eaa8298ca08192460fe3ac9f8d02b | /fhe7/fhe/core/Util.cpp | 44a0ee0dd7aeb411738d2928a1a456b8753debbd | [] | no_license | davecarr1024/libfhe | 77497b67c2ead85fc0bd6a7837a765daf6ccfe30 | 31682b423fc2255a10235f28c17cbdc7c6d7668b | refs/heads/master | 2021-05-08T05:22:02.635076 | 2016-08-22T20:11:06 | 2016-08-22T20:11:06 | 31,622,347 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,322 | cpp | #include <fhe/core/Util.h>
#include <cstdio>
#include <cstdarg>
#include <stdexcept>
namespace fhe
{
void fhe_assert( bool cond, const char* scond, const char* file, int line )
{
if ( !cond )
{
char err[1024];
snprintf( err, 1024, "FHE_ASSERT FAILED\ncond: %s\nfile: %s\nline: %d\n", scond, file, line );
throw std::runtime_error( err );
}
}
void fhe_assert_msg( bool cond, const char* scond, const char* file, int line, const char* fmt, ... )
{
if ( !cond )
{
va_list args;
va_start( args, fmt );
char buf[1024];
vsnprintf( buf, 1024, fmt, args );
va_end( args );
char err[1024];
snprintf( err, 1024, "FHE_ASSERT FAILED\ncond: %s\nfile: %s\nline: %d\nmsg: %s\n", scond, file, line, buf );
throw std::runtime_error( err );
}
}
void fhe_error( const char* file, int line, const char* fmt, ... )
{
va_list args;
va_start( args, fmt );
char buf[1024];
vsnprintf( buf, 1024, fmt, args );
va_end( args );
char err[1024];
snprintf( err, 1024, "FHE_ERROR\nfile: %s\nline: %d\nmsg: %s\n", file, line, buf );
throw std::runtime_error( err );
}
}
| [
"dave.carr.re2@a83f7b76-a30c-11de-8ba5-91705c1537ed"
] | dave.carr.re2@a83f7b76-a30c-11de-8ba5-91705c1537ed |
7830182bda5b4d7fa1ef6d57ef22c44fd889d1b2 | c05bc1c96979107eeb1d1463a7fc01b5144452c8 | /Common/Libraries/TextWindowLibrary/src/PropertyText.cpp | 32946a5fcb72d30360f81ce466efcdff891824c3 | [] | no_license | discos/discos | 1587604ae737d8301f10011d21bfa012dd3c411f | 87dc57a160f3b122af46a9927ee6abb62fdf4159 | refs/heads/master | 2023-08-30T21:39:55.339786 | 2023-06-21T13:39:20 | 2023-06-21T13:39:20 | 87,530,078 | 4 | 4 | null | 2023-09-07T07:57:43 | 2017-04-07T09:37:08 | C++ | UTF-8 | C++ | false | false | 100 | cpp | // $Id: PropertyText.cpp,v 1.1.1.1 2007-05-04 09:53:29 a.orlati Exp $
#include "TW_PropertyText.h"
| [
"[email protected]"
] | |
12443cb61d6a7f5ee1f081bf91dae94a8b06678d | ef761a03a2788832f729ee9783c23414a698c5c8 | /Common/Xml.h | b4f7cfb229525aa0776dab2dd4501ca62dcb4b22 | [
"MIT"
] | permissive | kovalexius/SSAODemo | db98a3089ab607d21084dc471e7a887b518eea16 | 56bee973b5b8fb9483918042c11ee107a262babc | refs/heads/master | 2020-12-02T05:05:26.422799 | 2016-12-07T16:09:50 | 2016-12-07T16:09:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,380 | h | /*******************************************************************************
Author: Alexey Frolov ([email protected])
This software is distributed freely under the terms of the MIT License.
See "LICENSE" or "http://copyfree.org/content/standard/licenses/mit/license.txt".
*******************************************************************************/
#pragma once
#include <Utils/ToString.h>
#include <Exception.h>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <stdint.h>
namespace XML
{
DECLARE_EXCEPTION(XmlException);
DECLARE_CHILD_EXCEPTION(NodeException, XmlException);
DECLARE_CHILD_EXCEPTION(NodeNotFoundException, NodeException);
DECLARE_CHILD_EXCEPTION(NodeExistException, NodeException);
DECLARE_CHILD_EXCEPTION(NodeIteratorException, NodeException);
DECLARE_CHILD_EXCEPTION(PropertyException, XmlException);
DECLARE_CHILD_EXCEPTION(PropertyNotFoundException, PropertyException);
DECLARE_CHILD_EXCEPTION(PropertyExistException, NodeException);
DECLARE_CHILD_EXCEPTION(XmlSyntaxException, XmlException);
class Node;
typedef std::vector<Node*> NodesSet;
typedef std::vector<const Node*> ConstNodesSet;
typedef std::map<std::string, NodesSet> NodesContainer;
typedef std::map<std::string, std::string> HeaderData;
struct NodesNamesData
{
std::string name;
size_t count;
NodesNamesData(const std::string &Name, size_t Count) : name(Name), count(Count){}
NodesNamesData() : count(0) {}
};
typedef std::vector<NodesNamesData> NodesNamesDataStorage;
template<class TNode>
class BaseNodeIterator
{
friend class Node;
private:
TNode *owner;
std::string curChildNodeName;
int curChildNodeIndex;
BaseNodeIterator(TNode *Owner, const std::string &ChildNodeName, int ChildNodeIndex)
: owner(Owner), curChildNodeName(ChildNodeName), curChildNodeIndex(ChildNodeIndex)
{}
NodesContainer::const_iterator GetCiter() const
{
if(!owner)
throw NodeIteratorException("Node iterator not initialised");
if(owner->nodes.size() == 0)
throw NodeIteratorException("Node " + owner->GetName() + " is empty");
NodesContainer::const_iterator ci = owner->nodes.find(curChildNodeName);
if(ci == owner->nodes.end())
throw NodeIteratorException("Node " + curChildNodeName + " not found in " + owner->GetName() + " node");
return ci;
}
public:
BaseNodeIterator() : owner(NULL), curChildNodeIndex(0) {}
BaseNodeIterator<TNode>& operator++() throw (Exception)
{
NodesContainer::const_iterator ci = GetCiter();
const NodesSet &nodes = ci->second;
if(++curChildNodeIndex == nodes.size()){
curChildNodeIndex = 0;
NodesContainer::const_iterator tmpCi = ci;
if(++tmpCi != owner->nodes.end())
curChildNodeName = tmpCi->first;
else
curChildNodeName = "LastFor" + Utils::to_string(owner);
}
return *this;
}
BaseNodeIterator<TNode> operator++(int Val) throw (Exception)
{
BaseNodeIterator<TNode> tmp = *this;
operator++();
return tmp;
}
TNode &operator*() const throw (Exception)
{
return *operator->();
}
TNode *operator->() const throw (Exception)
{
NodesContainer::const_iterator ci = GetCiter();
const NodesSet &nodes = ci->second;
if(!nodes.size())
throw NodeIteratorException("Node " + curChildNodeName + " is empty");
return nodes[curChildNodeIndex];
}
bool operator==(const BaseNodeIterator<TNode> &A)
{
return owner == A.owner && curChildNodeName == A.curChildNodeName && curChildNodeIndex == A.curChildNodeIndex;
}
bool operator!=(const BaseNodeIterator<TNode> &A)
{
return !operator==(A);
}
};
typedef BaseNodeIterator<Node> NodeIterator;
typedef BaseNodeIterator<const Node> ConstNodeIterator;
class XmlData;
class NodeCopyCreater;
class NodeFileWriter;
class NodeStringAppender;
template<class TStorage>
class NodeFinder;
class Node final
{
friend class XmlData;
friend class NodeCopyCreater;
friend class NodeFileWriter;
friend class NodeStringAppender;
friend class NodeFinder<NodesSet>;
friend class NodeFinder<ConstNodesSet>;
friend class BaseNodeIterator<Node>;
friend class BaseNodeIterator<const Node>;
private:
std::string name;
std::string value;
typedef std::map<std::string, std::string> PropertiesStorage;
PropertiesStorage properties;
NodesContainer nodes;
void Construct(const Node &Var);
Node * CreateCopy();
void WriteToFile(FILE * File, int32_t &Level) const throw (XmlException);
std::string ToString(int32_t &Level) const;
public:
Node(){}
~Node();
Node(const Node &Var);
Node &operator= (const Node &Var);
Node &GetNode(const std::string &NodeName, int32_t Index = 0) throw (XmlException);
const Node &GetNode(const std::string &NodeName, int32_t Index = 0) const throw (XmlException);
std::string &GetProperty (const std::string &PropertyName) throw (XmlException);
const std::string &GetProperty (const std::string &PropertyName) const throw (XmlException);
bool FindNode(const std::string &Name, ConstNodesSet &ConstNodes, bool Recursive = true) const;
bool FindNode(const std::string &Name, NodesSet &Nodes, bool Recursive = true);
bool FindNode(const std::string &PropName, const std::string &PropVal, ConstNodesSet &ConstNodes, bool Recursive = true) const;
bool FindNode(const std::string &PropName, const std::string &PropVal, NodesSet &Nodes, bool Recursive = true);
NodesNamesDataStorage GetNodesNames() const;
std::vector<std::string> GetPropertiesNames() const;
size_t GetNodesCount(const std::string &Name) const;
void SetName(const std::string &Name) {name = Name;}
const std::string &GetName() const { return name; }
void SetValue(const std::string &Value) {value = Value;}
const std::string &GetValue() const {return value;}
void AddProperty(const std::string &Name, const std::string &Value) throw (XmlException);
void RemoveProperty(const std::string &Name);
void ClearProperties(){properties.clear();}
void AddNode(const Node &NewNode);
void RemoveNode(const std::string &Name, int32_t Ind = -1) throw (XmlException);
void ClearNodes();
NodeIterator begin();
NodeIterator end();
ConstNodeIterator begin() const;
ConstNodeIterator end() const;
};
class XmlData final
{
private:
class Cursor
{
private:
int coll, line;
public:
Cursor() : coll(1), line(1){}
void ProcessChar(char Char);
void Clear(){coll = line = 1;}
XmlSyntaxException CreateException(const std::string &Message);
};
enum State
{
STATE_IDLE,
STATE_NODE_NAME,
STATE_NODE_ATTR_NAME,
STATE_NODE_ATTR_VAL
};
State state;
bool stringState, shieldChar, isSingleNode, nodeClosed, varAsEmptyStr;
enum HeaderState
{
HEADER_STATE_NOT_SET,
HEADER_STATE_BEGIN,
HEADER_STATE_END
};
HeaderState headerState;
enum StructState
{
STRUCT_STATE_NODE_DEFINITION,
STRUCT_STATE_NODE_DATA
};
StructState structState;
std::string text, varName, varData;
std::vector<Node*> processingNodes;
HeaderData header;
Node *lastNode, rootNode;
Cursor cursor;
void ProcessChar(char Char) throw (XmlException);
void ProcessNodeDefinitionStart() throw (XmlException);
void ProcessNodeDefinitionEnd() throw (XmlException);
void ProcessSlash() throw (XmlException);
void ProcessSpace() throw (XmlException);
void ProcessQuestionChar() throw (XmlException);
void ProcessEqualChar() throw (XmlException);
void Cleanup();
public:
~XmlData(){}
XmlData();
void LoadFromFile(const std::string &FilePath) throw (XmlException);
void LoadFromString(const std::string &DataString) throw (XmlException);
void SaveToFile(const std::string &FilePath) const throw (XmlException);
std::string ToString() const;
const Node &GetRoot() const { return rootNode;}
Node &GetRoot() { return rootNode;}
const HeaderData &GetHeaderData() const {return header;}
void Clear() { rootNode.ClearNodes(); header.clear();}
};
}; | [
"[email protected]"
] | |
6389490d3b08dc5d4b74366c101a7c9b4cb8dec6 | 7e37551e00fd1bdae27f2f6af25fcfe74f8d3ce6 | /test/test3_mesh.cpp | a8603b6c453d8eeb636a763304d95290f57c4177 | [] | no_license | ariannachiesa/Organic2D_project | d45de7614ddedec7024ba1bd2455df489c8d8eea | addbdc65b6e92b0c5556393486c9c147e6e3529d | refs/heads/master | 2020-03-13T14:43:05.395025 | 2018-07-03T16:00:28 | 2018-07-03T16:00:28 | 131,164,127 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 856 | cpp | /*
Arianna Chiesa
Project for the course:
"Advanced Programming for Scientific Computing"
*/
/*! \file test3_mesh.cpp
\brief Test 3: mesh creation
*/
#include "probl.h"
int main(int argc, char** argv){
MPI_Init(&argc,&argv);
clock_t tstart_probl;
tstart_probl = clock();
/// n. refinement cycles : 5
/// very dense mesh
Probl P(5);
tstart_probl = clock() - tstart_probl;
std::cout<<"Construction class Probl run time: "<<tstart_probl<<" , ("<<((float)tstart_probl)/CLOCKS_PER_SEC<<" seconds)."<<std::endl;
int nnodes = P._msh.num_global_nodes();
std::vector<double> Vguess(nnodes, P._PhiB);
/// Export nodal field Vguess to a octbin.gz file for visualization.
P._msh.octbin_export ("Vguess_visualization", Vguess, default_ord);
std::cout<<"End of program"<<std::endl;
MPI_Finalize();
return 0;
};
| [
"[email protected]"
] | |
6441f136adf8f15f533abfae49b526dd8beaef93 | 9877feda97f1a9923fc6f9bb449d0b945498a1a4 | /FinalProject/Instructor.h | 41f9772d42a621d109ece0827b6bc628e769f304 | [] | no_license | tugcekeskin/E-Learning-Platform | 9c8908d0dc9041ce01d5bcbd8f650d8c6b525612 | 147ad2b04457d25a917a7eb795d4611c5eb72770 | refs/heads/main | 2023-03-08T15:25:25.151233 | 2021-02-20T21:02:21 | 2021-02-20T21:02:21 | 340,495,673 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 172 | h | #include <string>
#include <vector>
using namespace std;
class Instructor {
public:
Instructor();
string name;
double balance;
vector<string> coursesToGive;
};
| [
"[email protected]"
] | |
2ac3abc9e24e3ea5760a4b30bc3a2ff80b750c11 | 8a2001b338d4fb854c9d99cfff1fee7d64cb4a64 | /src/hearthstone-shared/PerfCounters.h | 13f9ca77d3db01cd8c09babdb8befa1214b7eb34 | [] | no_license | Sandshroud/Sandshroud-Onyx | 06dceec3ded18013dfaf6d4ca7ff53a9af581167 | 133f92d1adcfd13bb28119bff777982690f41ff9 | refs/heads/master | 2021-01-25T05:21:26.141410 | 2013-02-19T06:10:57 | 2013-02-19T06:10:57 | 8,284,289 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,988 | h | /***
* Demonstrike Core
*/
#pragma once
#if PLATFORM == PLATFORM_WIN
#pragma pack(push,8)
#include <WinPerf.h>
#undef min
#undef max
#include <comdef.h> // for using bstr_t class
#include <vector>
#define TOTALBYTES 100 * 1024
#define BYTEINCREMENT 10 * 1024
#pragma warning(disable:4244)
template <class T>
class CPerfCounters
{
public:
CPerfCounters()
{
}
~CPerfCounters()
{
}
T GetCounterValue( PERF_DATA_BLOCK** pPerfData, DWORD dwObjectIndex, DWORD dwCounterIndex, LPCTSTR pInstanceName = NULL )
{
QueryPerformanceData( pPerfData, dwObjectIndex, dwCounterIndex );
PPERF_OBJECT_TYPE pPerfObj = NULL;
T lnValue = { 0 };
// Get the first object type.
pPerfObj = FirstObject( *pPerfData );
// Look for the given object index
for( DWORD i = 0; i < (*pPerfData)->NumObjectTypes; i++ )
{
if( pPerfObj->ObjectNameTitleIndex == dwObjectIndex )
{
lnValue = GetCounterValue(pPerfObj, dwCounterIndex, pInstanceName);
break;
}
pPerfObj = NextObject( pPerfObj );
}
return lnValue;
}
T GetCounterValueForProcessID( PERF_DATA_BLOCK** pPerfData, DWORD dwObjectIndex, DWORD dwCounterIndex, DWORD dwProcessID )
{
QueryPerformanceData( pPerfData, dwObjectIndex, dwCounterIndex );
PPERF_OBJECT_TYPE pPerfObj = NULL;
T lnValue = { 0 };
// Get the first object type.
pPerfObj = FirstObject( *pPerfData );
// Look for the given object index
for( DWORD i = 0; i < (*pPerfData)->NumObjectTypes; i++ )
{
if( pPerfObj->ObjectNameTitleIndex == dwObjectIndex )
{
lnValue = GetCounterValueForProcessID( pPerfObj, dwCounterIndex, dwProcessID );
break;
}
pPerfObj = NextObject( pPerfObj );
}
return lnValue;
}
protected:
class CBuffer
{
public:
CBuffer( UINT Size )
{
m_Size = Size;
m_pBuffer = ( LPBYTE )malloc( Size * sizeof( BYTE ) );
}
~CBuffer()
{
free( m_pBuffer );
}
void *Realloc( UINT Size )
{
m_Size = Size;
m_pBuffer = ( LPBYTE )realloc( m_pBuffer, Size );
return m_pBuffer;
}
void Reset()
{
memset( m_pBuffer, NULL, m_Size );
}
operator LPBYTE ()
{
return m_pBuffer;
}
UINT GetSize()
{
return m_Size;
}
public:
LPBYTE m_pBuffer;
private:
UINT m_Size;
};
//
// The performance data is accessed through the registry key
// HKEY_PEFORMANCE_DATA.
// However, although we use the registry to collect performance data,
// the data is not stored in the registry database.
// Instead, calling the registry functions with the HKEY_PEFORMANCE_DATA key
// causes the system to collect the data from the appropriate system
// object managers.
//
// QueryPerformanceData allocates memory block for getting the
// performance data.
//
//
void QueryPerformanceData(PERF_DATA_BLOCK **pPerfData, DWORD dwObjectIndex, DWORD dwCounterIndex)
{
//
// Since i want to use the same allocated area for each query,
// i declare CBuffer as static.
// The allocated is changed only when RegQueryValueEx return ERROR_MORE_DATA
//
static CBuffer Buffer(TOTALBYTES);
DWORD BufferSize = Buffer.GetSize();
LONG lRes;
char keyName[32];
sprintf(keyName,"%d",dwObjectIndex);
Buffer.Reset();
while( (lRes = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
keyName,
NULL,
NULL,
Buffer,
&BufferSize )) == ERROR_MORE_DATA )
{
// Get a buffer that is big enough.
BufferSize += BYTEINCREMENT;
Buffer.Realloc(BufferSize);
}
*pPerfData = (PPERF_DATA_BLOCK) Buffer.m_pBuffer;
}
//
// GetCounterValue gets performance object structure
// and returns the value of given counter index .
// This functions iterates through the counters of the input object
// structure and looks for the given counter index.
//
// For objects that have instances, this function returns the counter value
// of the instance pInstanceName.
//
T GetCounterValue(PPERF_OBJECT_TYPE pPerfObj, DWORD dwCounterIndex, LPCTSTR pInstanceName)
{
PPERF_COUNTER_DEFINITION pPerfCntr = NULL;
PPERF_INSTANCE_DEFINITION pPerfInst = NULL;
PPERF_COUNTER_BLOCK pCounterBlock = NULL;
// Get the first counter.
pPerfCntr = FirstCounter( pPerfObj );
for( DWORD j=0; j < pPerfObj->NumCounters; j++ )
{
if (pPerfCntr->CounterNameTitleIndex == dwCounterIndex)
break;
// Get the next counter.
pPerfCntr = NextCounter( pPerfCntr );
}
if( pPerfObj->NumInstances == PERF_NO_INSTANCES )
{
pCounterBlock = (PPERF_COUNTER_BLOCK) ((LPBYTE) pPerfObj + pPerfObj->DefinitionLength);
}
else
{
pPerfInst = FirstInstance( pPerfObj );
// Look for instance pInstanceName
_bstr_t bstrInstance;
_bstr_t bstrInputInstance = pInstanceName;
for( int k=0; k < pPerfObj->NumInstances; k++ )
{
bstrInstance = (wchar_t *)((PBYTE)pPerfInst + pPerfInst->NameOffset);
if (!stricmp((LPCTSTR)bstrInstance, (LPCTSTR)bstrInputInstance))
{
pCounterBlock = (PPERF_COUNTER_BLOCK) ((LPBYTE) pPerfInst + pPerfInst->ByteLength);
break;
}
// Get the next instance.
pPerfInst = NextInstance( pPerfInst );
}
}
if (pCounterBlock)
{
T *lnValue = NULL;
lnValue = (T*)((LPBYTE) pCounterBlock + pPerfCntr->CounterOffset);
return *lnValue;
}
return -1;
}
T GetCounterValueForProcessID(PPERF_OBJECT_TYPE pPerfObj, DWORD dwCounterIndex, DWORD dwProcessID)
{
int PROC_ID_COUNTER = 784;
BOOL bProcessIDExist = FALSE;
PPERF_COUNTER_DEFINITION pPerfCntr = NULL;
PPERF_COUNTER_DEFINITION pTheRequestedPerfCntr = NULL;
PPERF_COUNTER_DEFINITION pProcIDPerfCntr = NULL;
PPERF_INSTANCE_DEFINITION pPerfInst = NULL;
PPERF_COUNTER_BLOCK pCounterBlock = NULL;
// Get the first counter.
pPerfCntr = FirstCounter( pPerfObj );
for( DWORD j=0; j < pPerfObj->NumCounters; j++ )
{
if (int(pPerfCntr->CounterNameTitleIndex) == PROC_ID_COUNTER)
{
pProcIDPerfCntr = pPerfCntr;
if (pTheRequestedPerfCntr)
break;
}
if (pPerfCntr->CounterNameTitleIndex == dwCounterIndex)
{
pTheRequestedPerfCntr = pPerfCntr;
if (pProcIDPerfCntr)
break;
}
// Get the next counter.
pPerfCntr = NextCounter( pPerfCntr );
}
if( pPerfObj->NumInstances == PERF_NO_INSTANCES )
{
pCounterBlock = (PPERF_COUNTER_BLOCK) ((LPBYTE) pPerfObj + pPerfObj->DefinitionLength);
}
else
{
pPerfInst = FirstInstance( pPerfObj );
for( int k=0; k < pPerfObj->NumInstances; k++ )
{
pCounterBlock = (PPERF_COUNTER_BLOCK) ((LPBYTE) pPerfInst + pPerfInst->ByteLength);
if (pCounterBlock)
{
int processID = 0;
processID = *(T*)((LPBYTE) pCounterBlock + pProcIDPerfCntr->CounterOffset);
if (processID == int(dwProcessID))
{
bProcessIDExist = TRUE;
break;
}
}
// Get the next instance.
pPerfInst = NextInstance( pPerfInst );
}
}
if (bProcessIDExist && pCounterBlock)
{
T *lnValue = NULL;
lnValue = (T*)((LPBYTE) pCounterBlock + pTheRequestedPerfCntr->CounterOffset);
return *lnValue;
}
return -1;
}
/*****************************************************************
* *
* Functions used to navigate through the performance data. *
* *
*****************************************************************/
PPERF_OBJECT_TYPE FirstObject( PPERF_DATA_BLOCK PerfData )
{
return( (PPERF_OBJECT_TYPE)((PBYTE)PerfData + PerfData->HeaderLength) );
}
PPERF_OBJECT_TYPE NextObject( PPERF_OBJECT_TYPE PerfObj )
{
return( (PPERF_OBJECT_TYPE)((PBYTE)PerfObj + PerfObj->TotalByteLength) );
}
PPERF_COUNTER_DEFINITION FirstCounter( PPERF_OBJECT_TYPE PerfObj )
{
return( (PPERF_COUNTER_DEFINITION) ((PBYTE)PerfObj + PerfObj->HeaderLength) );
}
PPERF_COUNTER_DEFINITION NextCounter( PPERF_COUNTER_DEFINITION PerfCntr )
{
return( (PPERF_COUNTER_DEFINITION)((PBYTE)PerfCntr + PerfCntr->ByteLength) );
}
PPERF_INSTANCE_DEFINITION FirstInstance( PPERF_OBJECT_TYPE PerfObj )
{
return( (PPERF_INSTANCE_DEFINITION)((PBYTE)PerfObj + PerfObj->DefinitionLength) );
}
PPERF_INSTANCE_DEFINITION NextInstance( PPERF_INSTANCE_DEFINITION PerfInst )
{
PPERF_COUNTER_BLOCK PerfCntrBlk;
PerfCntrBlk = (PPERF_COUNTER_BLOCK)((PBYTE)PerfInst + PerfInst->ByteLength);
return( (PPERF_INSTANCE_DEFINITION)((PBYTE)PerfCntrBlk + PerfCntrBlk->ByteLength) );
}
};
#pragma pack(pop)
#include <Psapi.h>
#define SYSTEM_OBJECT_INDEX 2 // 'System' object
#define PROCESS_OBJECT_INDEX 230 // 'Process' object
#define PROCESSOR_OBJECT_INDEX 238 // 'Processor' object
#define TOTAL_PROCESSOR_TIME_COUNTER_INDEX 240 // '% Total processor time' counter (valid in WinNT under 'System' object)
#define PROCESSOR_TIME_COUNTER_INDEX 6 // '% processor time' counter (for Win2K/XP)
// Crow: Dunno if we need these.
#pragma comment(lib, "advapi32")
#pragma comment(lib, "Psapi")
#endif // PLATFORM == PLATFORM_WIN
| [
"[email protected]"
] | |
5184fd388d0eefebf01b7a8df594e2d5e77cf889 | f1b2c46797efdfc91947783903e2c0f3b008e8dc | /text-label.h | 5cbe53a43be434e87a1212dbb20743fcc4505ffe | [] | no_license | mbelicki/tower-of-au | 3b13e3f12632674ceafc97db45ef702362d68cf8 | 5cf03d44d28b0e92c4cd47137689620d73a6ec93 | refs/heads/master | 2021-01-10T07:32:51.782839 | 2017-06-11T11:52:08 | 2017-06-11T11:52:08 | 43,322,188 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 749 | h | #pragma once
#include "warp/helpers.h"
#include "warp/graphics/font.h"
namespace warp {
class controller_impl_i;
class entity_t;
class world_t;
}
enum label_flags_t {
LABEL_NONE = 0,
LABEL_LARGE = 1,
LABEL_POS_TOP = 2,
LABEL_POS_BOTTOM = 4,
LABEL_POS_LEFT = 8,
LABEL_POS_RIGHT = 16,
LABEL_PASS_MAIN = 32,
};
WARP_ENABLE_FLAGS(label_flags_t);
warp_res_id_t get_default_font(warp_resources_t *res);
warp_res_id_t get_dialog_font(warp_resources_t *res);
warp::entity_t * create_label
(warp::world_t *world, warp_res_id_t font, label_flags_t flags);
warp::entity_t *create_speech_bubble
( warp::world_t *world, warp_res_id_t font
, warp_vec3_t pos, const char *text
);
| [
"[email protected]"
] | |
0eb38bbf0130d61a6ac0248069f46cc2acff87e1 | 4d4ad4166a8148531cc652c3e6d0aa3460d011be | /src/Program.h | d6527bc0b7ac6b840538d94d27d460f3385b4057 | [] | no_license | giuluck/B1ender | d3afc0c4566e5abe35ad1e588c3bf701e67ad079 | c15d78c7dbb7707182301670ff9721f046841e08 | refs/heads/master | 2021-03-18T19:46:06.233630 | 2020-03-13T15:00:15 | 2020-03-13T15:00:15 | 247,095,705 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,297 | h | #pragma once
#include "Utils.h"
#include "Model.h"
#include "View.h"
#include "Projection.h"
#include "Shader.h"
#include <stack>
class Program
{
public:
static void initDefault();
static Model* getModel();
static View* getView();
static Projection* getProjection();
static Shader* getShader();
static void pushModel(Model* model);
static void pushView(View* view);
static void pushProjection(Projection* projection);
static void pushShader(Shader* shader);
static void popModel();
static void popView();
static void popProjection();
static void popShader();
private:
Program();
static stack<Model*> models;
static stack<View*> views;
static stack<Projection*> projections;
static stack<Shader*> shaders;
static Optional<int> selectedBody;
};
stack<Model*> Program::models;
stack<View*> Program::views;
stack<Projection*> Program::projections;
stack<Shader*> Program::shaders;
inline void Program::initDefault()
{
pushModel(new Model());
pushView(new View());
pushProjection(new Projection());
pushShader(new Shader());
}
inline Model* Program::getModel()
{
return models.top();
}
inline View* Program::getView()
{
return views.top();
}
inline Projection* Program::getProjection()
{
return projections.top();
}
inline Shader * Program::getShader()
{
return shaders.top();
}
inline void Program::pushModel(Model* model)
{
models.push(new Model(*model));
}
inline void Program::pushView(View* view)
{
views.push(new View(*view));
}
inline void Program::pushProjection(Projection* projection)
{
projections.push(new Projection(*projection));
}
inline void Program::pushShader(Shader* shader)
{
shaders.push(new Shader(*shader));
}
inline void Program::popModel()
{
delete getModel();
models.pop();
if (models.empty())
pushModel(new Model());
}
inline void Program::popView()
{
delete getView();
views.pop();
if (views.empty())
pushView(new View());
}
inline void Program::popProjection()
{
delete getProjection();
projections.pop();
if (projections.empty())
pushProjection(new Projection());
}
inline void Program::popShader()
{
delete getShader();
shaders.pop();
if (shaders.empty())
pushShader(new Shader());
} | [
"[email protected]"
] | |
124036d1fbb80cc76a56ec322c3119623aa06091 | 866eb253e717b53b63dfbf4f874b2337122b9319 | /Computacao Grafica/Atividades1BI/desenhos.h | 15587a83bd4bb2c89545aa56cc66aa4afc6e2784 | [
"MIT"
] | permissive | Mica-ely/cc-unespar | ff237e04b18c51e0d1d6a03b389f66db119facb2 | 59388b6fc17d461fc62aedcf63d30fe9d4fe6f7d | refs/heads/master | 2021-12-24T02:59:58.109979 | 2017-12-07T21:04:20 | 2017-12-07T21:04:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 327 | h | /*
* desenhos.h
*
* Created on: 5 de out de 2017
* Author: henrique.silva
*/
#ifndef DESENHOS_H_
#define DESENHOS_H_
class Desenhos
{
public:
void helice (int x, int y, float windowWidth, float windowHeight);
void teardrop(int x, int y, float windowHeight);
void bulbasaurPixel();
};
#endif /* DESENHOS_H_ */
| [
"[email protected]"
] | |
8a85831632691d46839f780a5115c508f7988e60 | a55be285cde30132f5e3df70e57cd5e0e68278ab | /2dz/libvec/vec_input.cpp | 75e7064ea4f74c9e36fdaf4d2d05ee149a6d139f | [] | no_license | ruhomor/3sem | 18db2de5fd375901b1b0c3c7e6c733d775dd22c5 | 751704e343b5e6b2e5c30ac45cdc440391df0d24 | refs/heads/master | 2023-01-24T19:08:29.634464 | 2020-12-13T22:27:31 | 2020-12-13T22:27:31 | 293,076,635 | 0 | 0 | null | 2020-11-07T01:24:23 | 2020-09-05T13:00:31 | C++ | UTF-8 | C++ | false | false | 1,143 | cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_input.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kachiote <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/22 18:44:09 by kachiote #+# #+# */
/* Updated: 2020/09/22 18:44:09 by kachiote ### ########.fr */
/* */
/* ************************************************************************** */
#include "libvec.h"
void vec_input(std::vector<int> &vc)
{
int a, m;
std::cout << "кол-во элементов: " << "\n";
std::cin >> m;
std::cout << "массив: ";
for(int j = 0; j < m; j++)
{
std::cin >> a;
vc.push_back(a);
}
}
| [
"[email protected]"
] | |
66dd6671f6da6b5cbf2e27d52a6fae68875511f7 | 42b48d20624ba0048cbfc42d54e3772af775c3c2 | /rpc_controller.h | 6faba1aca1340b65ef100ce09cd7e1d27923da23 | [] | no_license | JD-kriswu/simple_rpc | 168986694166db72278ed8d0b0945a28b1363674 | 13191ec99182ed3de7892ccd978b78281d897f59 | refs/heads/master | 2021-01-01T19:40:53.674686 | 2017-07-28T12:28:30 | 2017-07-28T12:28:30 | 98,648,913 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,836 | h | // Author: (norvallu)
#ifndef _TENCENT_PBRPC_RPC_CONTROLLER_H_
#define _TENCENT_PBRPC_RPC_CONTROLLER_H_
#include <google/protobuf/service.h>
#include "common.h"
#include "rpc_option.pb.h"
#include <deque>
#include <list>
namespace tencent {
namespace pbrpc {
#define CompressTypeAuto ((CompressType)-1)
class RpcController : public google::protobuf::RpcController
{
public:
typedef void(InternalDoneCallback)(const RpcController *) ;
RpcController();
virtual ~RpcController();
// -------- used by both client and server side ---------
// These calls can be made from both client side and server side.
// Get the local address in format of "ip:port".
//
// For client:
// This method can only be called after the call has finished. If
// IsRequestSent() is true, returns the local address used for sending
// the message; else, the return value is undefined.
//
// For server:
// This method returns the local address where the message received from.
std::string LocalAddress() const;
// Get the remote address in format of "ip:port".
//
// For client:
// This method returns the remote address where the messsage sent to.
//
// For server:
// This method returns the remote address where the message received from.
std::string RemoteAddress() const;
// -------- used only by client side ---------
virtual void Reset(){}
// Set expect timeout in milli-seconds of the call. If timeout is not set
// or set no more than 0, actual timeout will be taken from proto options.
void SetTimeout(int64 timeout_in_ms);
// Get the actual timeout in milli-seconds.
//
// The actual timeout takes effect in the following order:
// * set in RpcController (take effective only when timeout > 0)
// * set in the method proto options (default not set)
// * set in the service proto options (default value is 10 seconds)
int64 Timeout() const;
// Set compress type of the request message.
// Supported types:
// CompressTypeNone
// CompressTypeGzip
// CompressTypeZlib
// CompressTypeSnappy
// CompressTypeLZ4
void SetRequestCompressType(CompressType compress_type);
CompressType RequestCompressType();
// Set expected compress type of the response message.
// Supported types:
// CompressTypeNone
// CompressTypeGzip
// CompressTypeZlib
// CompressTypeSnappy
// CompressTypeLZ4
void SetResponseCompressType(CompressType compress_type);
CompressType ResponseCompressType();
// After a call has finished, returns true if the call failed. The possible
// reasons for failure depend on the RPC implementation. Failed() must not
// be called before a call has finished. If Failed() returns true, the
// contents of the response message are undefined.
//
// This method can only be called after the call has finished.
virtual bool Failed() const;
// If Failed() is true, returns error code which identities the reason.
// The error code is of type RpcErrorCode.
//
// This method can only be called after the call has finished.
virtual int ErrorCode() const;
// If Failed() is true, returns a human-readable description of the error.
// This can only be called after the call has finished.
//
// This method can only be called after the call has finished.
virtual std::string ErrorText() const;
// If the request has already been set to the remote server, returns true;
// otherwise returns false.
//
// This method can only be called after the call has finished.
bool IsRequestSent() const;
// If IsRequestSent() is true, returns sent bytes, including the rpc header.
//
// This method can only be called after the call has finished.
int64 SentBytes() const;
// Advises the RPC system that the caller desires that the RPC call be
// canceled. The RPC system may cancel it immediately, may wait awhile and
// then cancel it, or may not even cancel the call at all. If the call is
// canceled, the "done" callback will still be called and the RpcController
// will indicate that the call failed at that time.
//
// Not supported now.
virtual void StartCancel();
// -------- used only by server side ---------
// These calls should be made from the server side only. Their results
// are undefined on the client side (may crash).
// Causes Failed() to return true on the client side. "reason" will be
// incorporated into the message returned by ErrorText(). If you find
// you need to return machine-readable information about failures, you
// should incorporate it into your response protocol buffer and should
// NOT call SetFailed().
virtual void SetFailed(const std::string& reason);
void SetFailed(int error_code, const std::string& reason);
// If true, indicates that the client canceled the RPC, so the server may
// as well give up on replying to it. The server should still call the
// final "done" callback.
virtual bool IsCanceled() const;
// Asks that the given callback be called when the RPC is canceled. The
// callback will always be called exactly once. If the RPC completes without
// being canceled, the callback will be called after completion. If the RPC
// has already been canceled when NotifyOnCancel() is called, the callback
// will be called immediately.
//
// NotifyOnCancel() must be called no more than once per request.
virtual void NotifyOnCancel(google::protobuf::Closure* callback);
void SetRecvBuf(char *pBuf,int iSize);
const std::string& MethodId() const;
void SetMethodId(const std::string& method_id);
void SetMsg(void * p);
void * GetMsg();
void SetErrMsg(std::string &errMsg);
std::string & GetErrMsg();
void SetSequenceId(uint64 sequence_id);
uint64 SequenceId() const;
const std::string& Reason() const;
bool IsDone() const;
bool IsStartCancel() const;
void PushDoneCallback(const InternalDoneCallback * callback);
void Done(int, const std::string&);
void FillFromMethodDescriptor(const google::protobuf::MethodDescriptor*);
void SetSync();
bool IsSync() const;
std::string GetServiceType();
uint16_t GetPort();
void GetRecvBuf(char**, int*);
private:
void * m_pMsg;
uint64 _sequence_id;
std::string _method_id;
int _error_code;
std::string _reason;
std::string _errMsg;
// used only in client side
static const int NOT_DONE = 0;
static const int DONE = 1;
volatile int _is_done; // 0 means not done, 1 means aleady done
bool _is_request_sent; // if the request has been sent
int64 _sent_bytes; // sent bytes including the header
bool _is_start_cancel; // if has started canceling the call
std::deque<InternalDoneCallback *> _done_callbacks; // internal done callbacks
bool _is_sync;
uint64 _timeout_id;
std::string _servicetype;
uint16_t _port;
char * _pRecvBuf; // client assigned
int _iRecvBufSize;
struct RequestOptions {
int64 timeout;
CompressType request_compress_type;
CompressType response_compress_type;
RequestOptions() :
timeout(0),
request_compress_type(CompressTypeAuto),
response_compress_type(CompressTypeAuto) {}
};
RequestOptions _user_options; // options set by user
RequestOptions _auto_options; // options from proto
TENCENT_PBRPC_DISALLOW_EVIL_CONSTRUCTORS(RpcController);
}; // class RpcController
} // namespace pbrpc
} // namespace tencent
#endif // _TENCENT_PBRPC_RPC_CONTROLLER_H_
/* vim: set ts=4 sw=4 sts=4 tw=100 */
| [
"[email protected]"
] | |
5c1c619b0a64b57f7f7f8492b96d3fbc5196ad78 | 2605c92262d29936ab6eddbb57472a7876dd51a9 | /Project3/Project3/main.cpp | e90ea8f3e242c09608bbdcb48d54099573b851fa | [] | no_license | acsdavid97/C_BitDefender | b043b856958b86f7d8bbc4f97ec038482cdefefd | a043d012bb4e1bcd4d1f2688c570de9bbb1d82af | refs/heads/master | 2021-06-17T02:40:53.749388 | 2017-05-16T08:02:24 | 2017-05-16T08:02:24 | 73,021,839 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | cpp | #define _CRT_SECURE_NO_WARNINGS
/*
author: David
file name: main.cpp
file creation date: 2016-11-22 09:20:48
*/
#include "header.h"
int main()
{
system("pause");
return 0;
} | [
"[email protected]"
] | |
950496a89d02a3a4fa3cdd4febd5fe82280080b1 | 6e7e07d2872e9321c082db6bbf353f0f12090736 | /template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp | 04d9a13b41f82870bab57f3cb621d2bf8ce5e331 | [
"MIT"
] | permissive | haiweizhang/MyCocos2d-xV2.0 | e9a9fd7ed002db551caa391def644375095cd266 | 54759a2602f251091a3e1bce3be6b4d33ba0f15b | refs/heads/master | 2021-01-06T20:37:17.133750 | 2013-07-25T06:02:40 | 2013-07-25T06:02:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,470 | cpp | #include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::node();
// 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 ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
| [
"[email protected]"
] | |
772dcd730355722c4a9fe62eda3c4725c51c2f25 | 299648a8c633728662d0b7651cd98afdc28db902 | /src/thirdparty/cefbinary_72/libcef_dll/ctocpp/x509certificate_ctocpp.cc | f24a47685532e2f3be77a7fc803727dd58f84488 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown"
] | permissive | aardvarkxr/aardvark | 2978277b34c2c3894d6aafc4c590f3bda50f4d43 | 300d0d5e9b872ed839fae932c56eff566967d24b | refs/heads/master | 2023-01-12T18:42:10.705028 | 2021-08-18T04:09:02 | 2021-08-18T04:09:02 | 182,431,653 | 183 | 25 | BSD-3-Clause | 2023-01-07T12:42:14 | 2019-04-20T16:55:30 | TypeScript | UTF-8 | C++ | false | false | 7,526 | cc | // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1d3225e378b79ddd0f93eb3cf5e0633d9c887fa6$
//
#include "libcef_dll/ctocpp/x509certificate_ctocpp.h"
#include <algorithm>
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
#include "libcef_dll/ctocpp/x509cert_principal_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
CefRefPtr<CefX509CertPrincipal> CefX509CertificateCToCpp::GetSubject() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_subject))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_x509cert_principal_t* _retval = _struct->get_subject(_struct);
// Return type: refptr_same
return CefX509CertPrincipalCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefX509CertPrincipal> CefX509CertificateCToCpp::GetIssuer() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_issuer))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_x509cert_principal_t* _retval = _struct->get_issuer(_struct);
// Return type: refptr_same
return CefX509CertPrincipalCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefBinaryValue> CefX509CertificateCToCpp::GetSerialNumber() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_serial_number))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = _struct->get_serial_number(_struct);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall") CefTime CefX509CertificateCToCpp::GetValidStart() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_valid_start))
return CefTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_valid_start(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefX509CertificateCToCpp::GetValidExpiry() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_valid_expiry))
return CefTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_valid_expiry(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefBinaryValue> CefX509CertificateCToCpp::GetDEREncoded() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_derencoded))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = _struct->get_derencoded(_struct);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefBinaryValue> CefX509CertificateCToCpp::GetPEMEncoded() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_pemencoded))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = _struct->get_pemencoded(_struct);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall") size_t CefX509CertificateCToCpp::GetIssuerChainSize() {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_issuer_chain_size))
return 0;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
size_t _retval = _struct->get_issuer_chain_size(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall")
void CefX509CertificateCToCpp::GetDEREncodedIssuerChain(
IssuerChainBinaryList& chain) {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_derencoded_issuer_chain))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: chain; type: refptr_vec_same_byref
size_t chainSize = chain.size();
size_t chainCount = std::max(GetIssuerChainSize(), chainSize);
cef_binary_value_t** chainList = NULL;
if (chainCount > 0) {
chainList = new cef_binary_value_t*[chainCount];
DCHECK(chainList);
if (chainList) {
memset(chainList, 0, sizeof(cef_binary_value_t*) * chainCount);
}
if (chainList && chainSize > 0) {
for (size_t i = 0; i < chainSize; ++i) {
chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]);
}
}
}
// Execute
_struct->get_derencoded_issuer_chain(_struct, &chainCount, chainList);
// Restore param:chain; type: refptr_vec_same_byref
chain.clear();
if (chainCount > 0 && chainList) {
for (size_t i = 0; i < chainCount; ++i) {
chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i]));
}
delete[] chainList;
}
}
NO_SANITIZE("cfi-icall")
void CefX509CertificateCToCpp::GetPEMEncodedIssuerChain(
IssuerChainBinaryList& chain) {
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_pemencoded_issuer_chain))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: chain; type: refptr_vec_same_byref
size_t chainSize = chain.size();
size_t chainCount = std::max(GetIssuerChainSize(), chainSize);
cef_binary_value_t** chainList = NULL;
if (chainCount > 0) {
chainList = new cef_binary_value_t*[chainCount];
DCHECK(chainList);
if (chainList) {
memset(chainList, 0, sizeof(cef_binary_value_t*) * chainCount);
}
if (chainList && chainSize > 0) {
for (size_t i = 0; i < chainSize; ++i) {
chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]);
}
}
}
// Execute
_struct->get_pemencoded_issuer_chain(_struct, &chainCount, chainList);
// Restore param:chain; type: refptr_vec_same_byref
chain.clear();
if (chainCount > 0 && chainList) {
for (size_t i = 0; i < chainCount; ++i) {
chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i]));
}
delete[] chainList;
}
}
// CONSTRUCTOR - Do not edit by hand.
CefX509CertificateCToCpp::CefX509CertificateCToCpp() {}
template <>
cef_x509certificate_t* CefCToCppRefCounted<
CefX509CertificateCToCpp,
CefX509Certificate,
cef_x509certificate_t>::UnwrapDerived(CefWrapperType type,
CefX509Certificate* c) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template <>
base::AtomicRefCount CefCToCppRefCounted<CefX509CertificateCToCpp,
CefX509Certificate,
cef_x509certificate_t>::DebugObjCt
ATOMIC_DECLARATION;
#endif
template <>
CefWrapperType CefCToCppRefCounted<CefX509CertificateCToCpp,
CefX509Certificate,
cef_x509certificate_t>::kWrapperType =
WT_X509CERTIFICATE;
| [
"[email protected]"
] | |
6d65cadb3c5184a005b6f652fb1053ba4f0de8a3 | aa2ac425a8bb957a26763ae17e50d50f1cce8956 | /src/Addons/GeoWay/gwXML_StandardMetaData/type_xs.Cshort.h | 269eb716b1f65e26125256b8bf97650c59c80142 | [] | no_license | radtek/CGISS | c7289ed19d912c432aae81d0cdbb6b080b4f5458 | 3f7cfa19d8024a67a5350d51e3f2f40a5e203576 | refs/heads/master | 2023-03-16T21:23:56.948744 | 2017-06-17T14:14:09 | 2017-06-17T14:14:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 837 | h | #ifndef _ALTOVA_INCLUDED_gie_ALTOVA_xs_ALTOVA_Cshort
#define _ALTOVA_INCLUDED_gie_ALTOVA_xs_ALTOVA_Cshort
namespace gie
{
namespace xs
{
class Cshort : public TypeBase
{
public:
gie_EXPORT Cshort(xercesc::DOMNode* const& init);
gie_EXPORT Cshort(Cshort const& init);
void operator=(Cshort const& other) { m_node = other.m_node; }
static altova::meta::SimpleType StaticInfo() { return altova::meta::SimpleType(types + _altova_ti_xs_altova_Cshort); }
void operator= (const int& value)
{
altova::XmlFormatter* Formatter = static_cast<altova::XmlFormatter*>(altova::IntegerFormatter);
XercesTreeOperations::SetValue(GetNode(), Formatter->Format(value));
}
operator int()
{
return CastAs<int >::Do(GetNode(), 0);
}
};
} // namespace xs
} // namespace gie
#endif // _ALTOVA_INCLUDED_gie_ALTOVA_xs_ALTOVA_Cshort
| [
"[email protected]"
] | |
b5d9dfd9ccc296d389b0da5c652d66b9e6683b56 | 71ce57c3ac7d39ba12b8473849c00a23c1c338ac | /src/gwen/src/Controls/Layout/Splitter.h | 7a4051c4a446ff095c1923782d66c2dea4a21052 | [] | no_license | ReccaStudio/DeferredRenderer | f6a5e5ffbb36ffc79dedc295ad1ab0202251abd0 | d896de09052c5880b99737e51360641d05fe84b7 | refs/heads/master | 2020-04-07T16:35:13.954276 | 2013-12-11T23:44:42 | 2013-12-11T23:44:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,523 | h | /*
GWEN
Copyright (c) 2011 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#pragma once
#include "Gwen/Controls/Base.h"
namespace Gwen
{
namespace Controls
{
namespace Layout
{
class Splitter : public Base
{
public:
typedef Base BaseClass;
Splitter( Base* pParent ) : BaseClass( pParent )
{
for ( int i=0; i<2; i++ )
m_pPanel[i] = NULL;
}
void SetPanel( int i, Base* pPanel )
{
if ( i < 0 || i > 1 ) return;
m_pPanel[i] = pPanel;
if ( m_pPanel[i] )
{
m_pPanel[i] ->SetParent( this );
}
}
Base* GetPanel( int i ) const
{
if ( i < 0 || i > 1 ) return NULL;
return m_pPanel[i];
}
void Layout( Skin::Base* skin )
{
LayoutVertical( skin );
}
private:
void LayoutVertical( Skin::Base* skin )
{
int w = Width();
int h = Height();
if ( m_pPanel[0] )
{
const Margin& m = m_pPanel[0]->GetMargin();
m_pPanel[0]->SetBounds( m.left, m.top, w-m.left-m.right, (h * 0.5) - m.top - m.bottom );
}
if ( m_pPanel[1] )
{
const Margin& m = m_pPanel[1]->GetMargin();
m_pPanel[1]->SetBounds( m.left, m.top + (h * 0.5f), w-m.left-m.right, (h * 0.5f) - m.top - m.bottom );
}
}
void LayoutHorizontal( Skin::Base* skin )
{
// Todo.
}
Base* m_pPanel[2];
};
}
}
}
| [
"[email protected]"
] | |
cf1cd5067aa809f149005d811a6121148b06c709 | 2b59987242b85c4bc13a78ca53455ec451fc0a02 | /ios/IOSNDKHelper-C-Interface.h | 5df121814a70e74b245cbe87d2bbe71595bb85d8 | [] | no_license | boriel/EasyNDK | 0cde61ba885e77c19549865b1a6abf24e4f2ff36 | 16428d3df986948a088e5fe616affa16e9680ad8 | refs/heads/master | 2021-01-15T10:40:58.431470 | 2013-07-11T11:21:04 | 2013-07-11T11:21:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | h | //
// IOSNDKHelper-C-Interface.h
// EasyNDK-for-cocos2dx
//
// Created by Amir Ali Jiwani on 23/02/2013.
//
//
#ifndef EasyNDK_for_cocos2dx_IOSNDKHelper_C_Interface_h
#define EasyNDK_for_cocos2dx_IOSNDKHelper_C_Interface_h
#include <iostream>
#include "cocos2d.h"
#include "jansson.h"
#include <string>
USING_NS_CC;
using namespace std;
class IOSNDKHelperImpl
{
public :
static json_t * receiveCPPMessage(json_t *methodName, json_t* methodParams);
static void setNDKReceiver(void*receiver);
};
#endif
| [
"[email protected]"
] | |
66e393e272e077ba4a3c111b40b6c12a82420af4 | 4b5c9bccb1930d0d5cdbcd8c6834d7dd80374841 | /Bank.cpp | 86773d73ee4c649a1b73b0244b1e14112edeeb4d | [] | no_license | peperontino39/9gatusinsakai | ee5c10395429d44d319ae6b84047d0e820f629f3 | f28ccc5b7caeb4ee7dd284d15d8965dae98b46d2 | refs/heads/master | 2021-01-10T05:33:00.026928 | 2015-10-11T19:48:44 | 2015-10-11T19:48:44 | 44,066,925 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 5,804 | cpp | #include "Bank.h"
//メインで使う関数
void Bank(Player& player){
BANK b;
b.Bank_main(player);
}
void BANK::Bank_main(Player& player){
player.deposit *= (player.day - player.deposit_day)*0.001 + 1;
bgm.looping(1);
bgm.play();
while (player.place == Place::BANK_)
{
if (!env.isOpen()) exit(0);
env.begin();
Update(player);
Draw(player);
env.end();
}
}
void BANK::Key(){
//std::cout << (is_select2 == 0 && is_select2 == 0) << std::endl;
if (is_select2 == 0 && is_select1 == 0){
if (env.isPushKey('W')){
text = ' ';
text2 = ' ';
select--;
sele.play();
}
if (env.isPushKey('S')){
text = ' ';
text2 = ' ';
sele.play();
select++;
}
}
// env.flushInput();
if (is_select2 == 1 || is_select1 == 1){
//std::cin >> how;
if (env.isPressKey('W')){
sele.play();
increment_amount++;
if (increment_amount < 50)
how++;
else if (increment_amount < 100)
how+=100;
else if (increment_amount < 150)
how += 10000;
else if (increment_amount < 200)
how += 1000000;
}
if (env.isPressKey('S')){
increment_amount++;
sele.play();
if (increment_amount < 50)
how--;
else if (increment_amount < 100)
how -= 100;
else if (increment_amount < 150)
how -= 10000;
else if (increment_amount < 200)
how -= 1000000;
}
if (env.isPullKey('W') || env.isPullKey('S')){
increment_amount = 0;
}
if (env.isPushKey('A')){
is_select1 = 0;
is_select2 = 0;
how = 0;
}
}
}
void BANK::Enter(Player& player){
if (env.isPushKey(GLFW_KEY_ENTER)){
if (is_select2 == 0 && is_select1 == 0)
{
//std::cout << select << std::endl;
switch (select)
{
case 0:
ok.play();
is_select2 = 1;
break;
case 1:
ok.play();
is_select1 = 1;
break;
case 2:
player.place = Place::WORLD;
player.deposit_day = player.day;
ok.play();
break;
}
}
else if (is_select2 == 1){
player.have_money -= how;
player.deposit += how;
is_select2 = 0;
how = 0;
kane.play();
}
else if (is_select1 == 1){
player.have_money += how;
player.deposit -= how;
is_select1 = 0;
how = 0;
kane.play();
}
}
}
void BANK::Font_Color(){
for (int i = 0; i < 3; i++)
{
select_color[i] = Color::white;
}
switch (select)
{
case 0:
select_color[0] = Color::red;
break;
case 1:
select_color[1] = Color::red;
break;
case 2:
select_color[2] = Color::red;
break;
}
}
void BANK::Stop(Player& player){
if (select > 2)select = 2;
if (select < 0)select = 0;
if (is_select2 == 1){
if (how > player.have_money)how = player.have_money;
if (how < 0)how = 0;
}
if (is_select1 == 1){
if (how > player.deposit)how = player.deposit;
if (how < 0)how = 0;
}
}
//処理多数
void BANK::Update(Player& player){
Key();
Enter(player);
Stop(player);
Font_Color();
}
//描画
void BANK::Draw(Player& player){
drawTextureBox(-WIDTH / 2, -HEIGHT / 2, WIDTH, HEIGHT, 0, 0, 2048, 1024, bg, Color::white);
font.size(70);
font.draw(" 歳 月 日", Vec2f(-WIDTH / 2, HEIGHT / 2 - 100), Color::black);
font.draw(std::to_string(player.age = (player.day / 360) + 20
) + " " +
std::to_string(player.month = ((player.day / 30 + 3)) % 12 + 1
) + " " +
std::to_string(player.day % 30 + 1), Vec2f(-WIDTH / 2, HEIGHT / 2 - 100), Color::white);
font.draw("村の発展度 " + std::to_string(player.battle_reaching * 2 - 2) + '%', Vec2f(-WIDTH / 2, HEIGHT / 2 - 200), Color::black);
font.draw("カネー " + std::to_string(player.have_money), Vec2f(-WIDTH / 2, HEIGHT / 2 - 300), Color::black);
font.draw("現在の預金額 " + std::to_string(player.deposit), Vec2f(-WIDTH / 2, HEIGHT / 2 - 400), Color::black);
drawTextureBox(-WIDTH / 2, -HEIGHT / 2 - 30, 500, 350, 0, 0, 2048, 512, message2);
font.draw("預金する", Vec2f(-WIDTH / 2, -HEIGHT / 2 + 200), select_color[0]);
font.draw("引き出す", Vec2f(-WIDTH / 2, -HEIGHT / 2 + 100), select_color[1]);
font.draw("出る", Vec2f(-WIDTH / 2, -HEIGHT / 2 + 000), select_color[2]);
if (is_select2 == 1){
drawTextureBox(-100, HEIGHT / 2 - 600, 800, 550, 0, 0, 2048, 512, message2);
font.draw("いくら預ける?", Vec2f(00, HEIGHT / 2 - 200), Color::cyan);
font.draw("カネー " + std::to_string(how), Vec2f(00, HEIGHT / 2 - 300), Color::red);
}
if (is_select1 == 1){
drawTextureBox(-100, HEIGHT / 2 - 600, 800, 550, 0, 0, 2048, 512, message2);
font.draw("いくら引き出す?", Vec2f(00, HEIGHT / 2 - 200), Color::cyan);
font.draw("カネー " + std::to_string(how), Vec2f(00, HEIGHT / 2 - 300), Color::red);
}
font.draw(text, Vec2f(-500, -300), Color::cyan);
font.draw(text2, Vec2f(-500, -200), Color::cyan);
}
| [
"[email protected]"
] | |
e6eca823d60a1b0fda334b578e8a7dde74c77007 | 5267859ecefb61358dff5eb3e91940270d4a2fe7 | /FramworkZero/Framework/Tools/Viewer/UIProjection.cpp | 7a260ff2631d12fa41a33906ce74694d42ffcc8d | [] | no_license | kini5766/ChangeFramwork | 143cd5cc6bbd95a0b9bd96785c79442d2bb200c4 | 932aafbd3622cfd27977fe497835079e268a94ba | refs/heads/main | 2023-04-22T09:13:35.564938 | 2021-05-11T00:48:06 | 2021-05-11T00:48:06 | 309,881,063 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 614 | cpp | #include "Framework.h"
#include "UIProjection.h"
UIProjection::UIProjection(float width, float height)
{
Set(width, height, 0.0f, 0.0f, 0.0f);
}
UIProjection::~UIProjection()
{
}
void UIProjection::Resize(float width, float height)
{
Super::Resize(width, height);
D3DXMatrixScaling(&matrix, 2.0f / width, -2.0f / height, 1.0f);
matrix._41 -= 1.0f;
matrix._42 += 1.0f;
}
void UIProjection::Set(float width, float height, float zn, float zf, float fov)
{
Super::Set(width, height, zn, zf, fov);
D3DXMatrixScaling(&matrix, 2.0f / width, -2.0f / height, 1.0f);
matrix._41 -= 1.0f;
matrix._42 += 1.0f;
}
| [
"[email protected]"
] | |
c3623cd5461df81d35fd94e228d64a9575f99aaf | 2b958f68852101e43ca0af4481a14cfb7dfd5d61 | /MAT-File/src/Header.cpp | 526d99c4dca494436ab600b8996c8bb99fb7b57d | [
"MIT"
] | permissive | MattEding/MAT-File | 29973e5aab352d1afbc282d34c9913f33eef5576 | 1371c538899c6d6b3b9e51562daf565adc51a66b | refs/heads/main | 2023-08-11T09:09:04.718668 | 2021-08-29T17:09:31 | 2021-08-29T17:09:31 | 401,088,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 452 | cpp | #include "Header.h"
#include "Utils.hpp"
namespace mat {
auto Header::text_sv( ) const noexcept -> std::string_view
{
return make_string_view( text );
}
auto Header::endian_sv( ) const noexcept -> std::string_view
{
return make_string_view( endian );
}
auto Header::magic_number( ) noexcept -> std::string_view
{
static Bytes< 2 > constexpr endian_indicator{ 'M', 'I' };
return make_string_view( endian_indicator );
}
} /* mat */
| [
"[email protected]"
] | |
2dbfa007292a8076736a3b1ef0ce05ace05a817f | 086b914d43c9ae8d0d4d5fc4080079eeddd2bd8c | /src/net/capture/gcapture.h | f3adbf26c9fed32c821204cb1f3d340db91f45e6 | [] | no_license | snoopspy/g-backup-20210607 | 850f6093c7f193d2a06e07076d2a59c0eb5be00d | 8407616696850e41a0fec655b6cf9ca7a3ef2b73 | refs/heads/master | 2023-05-14T02:53:34.409111 | 2021-06-07T13:49:33 | 2021-06-07T13:49:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,836 | h | // ----------------------------------------------------------------------------
//
// G Library
//
// http://gilgil.net
//
// Copyright (c) Gilbert Lee All rights reserved
//
// ----------------------------------------------------------------------------
#pragma once
#include "base/gstateobj.h"
#include "base/sys/gthread.h"
#include "net/packet/gpacket.h"
#include "net/packet/gethpacket.h"
#include "net/packet/gippacket.h"
#include "net/packet/gdot11packet.h"
#include "net/packet/gnullpacket.h"
// ----------------------------------------------------------------------------
// GCapture
// ----------------------------------------------------------------------------
struct G_EXPORT GCapture : GStateObj {
Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled_)
Q_PROPERTY(bool autoParse MEMBER autoParse_)
// Q_PROPERTY(GParser*) // gilgil temp 2019.05.14
public:
bool enabled_{true};
bool autoParse_{true};
protected:
bool autoRead_{true};
typedef enum {
InPath,
OutOfPath
} PathType;
public:
GCapture(QObject* parent = nullptr) : GStateObj(parent) {}
~GCapture() override;
protected:
bool doOpen() override;
bool doClose() override;
public:
virtual GPacket::Result read(GPacket* packet);
virtual GPacket::Result write(GBuf buf);
virtual GPacket::Result write(GPacket* packet);
virtual GPacket::Result relay(GPacket* packet);
virtual GPacket::Result drop(GPacket* packet);
virtual GPacket::Dlt dlt() { return GPacket::Null; }
virtual PathType pathType() { return OutOfPath; }
protected:
struct Thread : GThread {
Thread(GCapture* capture) : GThread(capture) {}
protected:
void run() override {
GCapture* capture = dynamic_cast<GCapture*>(parent());
Q_ASSERT(capture != nullptr);
capture->run();
}
} thread_{this};
virtual void run();
signals:
void captured(GPacket* packet);
};
| [
"[email protected]"
] | |
af33844c626ed405db7b60bc582ebcf4d40388c8 | 24cb74052f95d275dfb8599ea342cadd5e312fa1 | /Graph/Graph Traversals(BFS & DFS)/BFS/Knight moves problem using BFS.cpp | 6e2088d47f7ff762f0138ab27be6449709e5e3c9 | [
"MIT"
] | permissive | Datta2901/Algorithmic-Implementations | 44ccd6b1996fac660ec1c268a5fa44fda59abb0e | 9e1afe97d54d4dc50be9170bc1a155562e0aafa6 | refs/heads/master | 2023-08-31T17:25:52.391313 | 2021-10-15T17:46:56 | 2021-10-15T17:46:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,028 | cpp | // PROBLEM LINK: https://www.geeksforgeeks.org/minimum-steps-reach-target-knight/
/***********************************************************************************************************/
// NOTE: Both the below codes ARE CORRECT and got AC on UVa OJ
// https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=380
/**********************************************************************************************************/
// METHOD - 1 (Using std::set as visited in BFS)
// Problem: 439 - Knight Moves
// Contest: UVa Online Judge
// URL: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=380
// Memory Limit: 32 MB
// Time Limit: 3000 ms
// Parsed on: 04-12-2020 16:07:30 IST (UTC+05:30)
// Author: kapil_choudhary
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
uniform_int_distribution<int> uid(0,lim-1);
return uid(rang);
}
const int mod = 1e9+7;
vi dx{2, 2, -2, -2, 1, 1, -1, -1};
vi dy{-1, 1, 1, -1, 2, -2, 2, -2};
struct Node{
int x, y, dist;
Node(int x, int y, int dist = 0): x(x), y(y), dist(dist) {}
bool operator < (const Node &n) const{
return (x < n.x) || ((x == n.x) && (y < n.y));
}
};
bool is_valid(int i, int j){
if(i < 1 || i > 8 || j < 1 || j > 8) return false;
return true;
}
inline size_t key(int i,int j){
return (size_t) i << 32 | (unsigned int) j;
}
int bfs(Node start, Node end){
unordered_map<size_t, bool> visited;
queue<Node> q;
q.push(start);
visited[key(start.x, start.y)] = true;
while(!q.empty()){
Node curr = q.front();
int x = curr.x, y = curr.y, dist = curr.dist;
q.pop();
if((x == end.x) && (y == end.y)) return dist;
for(int i = 0; i < 8; i++){
int x1 = x + dx[i], y1 = y + dy[i];
if(is_valid(x1, y1)){
if(visited.find(key(x1, y1)) == visited.end()){
visited[key(x1, y1)] = true;;
q.push({x1, y1, dist+1});
}
}
}
}
return INT_MAX;
}
void solve(string s, string e)
{
int si = s[1] - '0';
int sj = s[0] - 'a' + 1;
Node start = {si, sj};
int ei = e[1] - '0';
int ej = e[0] - 'a' + 1;
Node end = {ei, ej};
cout << "To get from " << s << " to " << e << " takes ";
cout << bfs(start, end) << " knight moves.\n";
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
// int t = 1;
// cin >> t;
string s, e;
while(cin >> s >> e) {
solve(s, e);
}
return 0;
}
/***********************************************************************************************************/
// METHOD - 2 (Using custom made unordered_map as visited in BFS)
// For the custom hash function used below visit --->
// https://stackoverflow.com/questions/32685540/why-cant-i-compile-an-unordered-map-with-a-pair-as-key
// Problem: 439 - Knight Moves
// Contest: UVa Online Judge
// URL: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=380
// Memory Limit: 32 MB
// Time Limit: 3000 ms
// Parsed on: 04-12-2020 16:07:30 IST (UTC+05:30)
// Author: kapil_choudhary
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
uniform_int_distribution<int> uid(0,lim-1);
return uid(rang);
}
const int mod = 1e9+7;
vi dx{2, 2, -2, -2, 1, 1, -1, -1};
vi dy{-1, 1, 1, -1, 2, -2, 2, -2};
struct Node{
int x, y, dist;
Node(int x, int y, int dist = 0): x(x), y(y), dist(dist) {}
bool operator < (const Node &n) const{
return (x < n.x) || ((x == n.x) && (y < n.y));
}
};
bool is_valid(int i, int j){
if(i < 1 || i > 8 || j < 1 || j > 8) return false;
return true;
}
int bfs(Node start, Node end){
set<pii> visited;
queue<Node> q;
q.push(start);
visited.insert({start.x, start.y});
while(!q.empty()){
Node curr = q.front();
int x = curr.x, y = curr.y, dist = curr.dist;
q.pop();
if((x == end.x) && (y == end.y)) return dist;
for(int i = 0; i < 8; i++){
int x1 = x + dx[i], y1 = y + dy[i];
if(is_valid(x1, y1)){
if(visited.count({x1, y1}) == 0){
visited.insert({x1, y1});
q.push({x1, y1, dist+1});
}
}
}
}
return INT_MAX;
}
void solve(string s, string e)
{
int si = s[1] - '0';
int sj = s[0] - 'a' + 1;
Node start = {si, sj};
int ei = e[1] - '0';
int ej = e[0] - 'a' + 1;
Node end = {ei, ej};
cout << "To get from " << s << " to " << e << " takes ";
cout << bfs(start, end) << " knight moves.\n";
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
// int t = 1;
// cin >> t;
string s, e;
while(cin >> s >> e) {
solve(s, e);
}
return 0;
}
// For both the above methods ---->
// Time complexity: O(n^2).
// At worst case, all the cells will be visited so time complexity is O(n^2).
// Auxiliary Space: O(n^2).
// where n = size of chess board (here it is = 8) | [
"[email protected]"
] | |
b25c5e58300dd9cf22402d8dfafa5050e11cd9b9 | 24176b2bdfb3aa0131d66c38df5069f241da521f | /DreamSkin/DreamSkinScrollBar.cpp | 67c71e6079cf8cbd654842cfb05266b49d7b21ac | [] | no_license | zephyrer/dreamskin | 236d6253468bcbc01d55ade7f4df5607c6c415c1 | 6641157627757a05827fff0c03ab94ecdd4ca847 | refs/heads/master | 2021-01-01T05:30:42.503024 | 2013-09-25T08:06:46 | 2013-09-25T08:06:46 | 40,067,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 63,079 | cpp | //DreamSkinScrollBar.cpp
#include <windows.h>
#include "WinGdiEx.h"
#include "DreamSkinMain.h"
#include "DreamSkinLoader.h"
#include "DreamSkinWindow.h"
#include "DreamSkinScrollBar.h"
#define DEFAULT_SCROLLBAR_BUTTON_XY 17
//static member declaration
WNDPROC CDreamSkinScrollBar::s_DefaultWindowProc = NULL;
SKINSCROLLBAR CDreamSkinScrollBar::s_SkinScrollBar;
typedef int (WINAPI *SETSCROLLINFO)(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL fRedraw);
typedef int (WINAPI *SETSCROLLPOS)(HWND hWnd, int nBar, int nPos, BOOL bRedraw);
typedef BOOL (WINAPI *GETSCROLLINFO)(HWND hWnd, int fnBar, LPSCROLLINFO lpsi);
int WINAPI CDreamSkinScrollBar::SetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL fRedraw)
{
int nResult = 0;
if (theSkinMain.m_HookSetScrollInfo.OrgAddr)
{
//send this message only when we hooked this window
CDreamSkinWindow *pSkinWindow = theSkinMain.GetHookedWindow(hWnd);
if (pSkinWindow)
{
nResult = ((SETSCROLLINFO)theSkinMain.m_HookSetScrollInfo.OrgAddr)(hWnd, fnBar, lpsi, FALSE);
if (fRedraw)
{
if (pSkinWindow->GetType() == DREAMSKIN_SCROLLBAR)
{
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
{
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
}
}
}
else
{
nResult = ((SETSCROLLINFO)theSkinMain.m_HookSetScrollInfo.OrgAddr)(hWnd, fnBar, lpsi, fRedraw);
}
}
return nResult;
}
int WINAPI CDreamSkinScrollBar::SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
{
int nResult = 0;
if (theSkinMain.m_HookSetScrollPos.OrgAddr)
{
//send this message only when we hooked this window
CDreamSkinWindow *pSkinWindow = theSkinMain.GetHookedWindow(hWnd);
if (pSkinWindow)
{
nResult = ((SETSCROLLPOS)theSkinMain.m_HookSetScrollPos.OrgAddr)(hWnd, nBar, nPos, FALSE);
if (bRedraw)
{
if (pSkinWindow->GetType() == DREAMSKIN_SCROLLBAR)
{
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
{
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
}
}
}
else
{
nResult = ((SETSCROLLPOS)theSkinMain.m_HookSetScrollPos.OrgAddr)(hWnd, nBar, nPos, bRedraw);
}
}
return nResult;
}
BOOL WINAPI CDreamSkinScrollBar::GetScrollInfo(HWND hWnd, int fnBar, LPSCROLLINFO lpsi)
{
int nResult = 0;
if (theSkinMain.m_HookGetScrollInfo.OrgAddr)
{
nResult = ((GETSCROLLINFO)theSkinMain.m_HookGetScrollInfo.OrgAddr)(hWnd, fnBar, lpsi);
//send this message only when we hooked this window
if (theSkinMain.GetHookedWindow(hWnd))
{
if (lpsi->fMask & SIF_TRACKPOS)
{
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_TRACKPOS;
if (::SendMessage(hWnd, SBM_GETSCROLLINFO, (WPARAM)fnBar, (LPARAM)&ScrollInfo))
lpsi->nTrackPos = ScrollInfo.nTrackPos;
}
}
}
return nResult;
}
CDreamSkinScrollBar::CDreamSkinScrollBar(HWND hWnd, WNDPROC OrgWndProc)
: CDreamSkinWindow(hWnd, OrgWndProc)
{
m_pSkinScrollBar = &s_SkinScrollBar;
m_ScrollBarTrackInfo.nSBLButtonDown = 0;
m_ScrollBarTrackInfo.bIsTracking = FALSE;
m_ScrollBarTrackInfo.nTrackPos = 0;
m_nSBHover = 0;
}
CDreamSkinScrollBar::~CDreamSkinScrollBar()
{
if (m_pSkinScrollBar != &s_SkinScrollBar)
delete m_pSkinScrollBar;
}
void CDreamSkinScrollBar::Reload()
{
if (m_hWnd && ::IsWindow(m_hWnd))
{
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
m_bCreateRegion = TRUE;
::InvalidateRect(m_hWnd, &rcClient, TRUE);
}
}
BOOL CDreamSkinScrollBar::ApplySkin(CDreamSkinLoader *pLoader)
{
BOOL bResult = TRUE;
InitialClass();
SKINSCROLLBAR SkinScrollBar;
pLoader->GetSkinScrollBar(&SkinScrollBar);
s_SkinScrollBar = SkinScrollBar;
return bResult;
}
CDreamSkinScrollBar* CDreamSkinScrollBar::CreateInstance(HWND hWnd, WNDPROC OrgWndProc)
{
CDreamSkinScrollBar *pSkinScrollBar = new CDreamSkinScrollBar(hWnd, OrgWndProc);
return pSkinScrollBar;
}
LRESULT WINAPI CDreamSkinScrollBar::DefWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
CDreamSkinWindow *pHookedWindow = theSkinMain.GetHookedWindow(hWnd);
if (message == WM_NCDESTROY)
{
return CDreamSkinWindow::DefWindowProc(hWnd, message, wParam, lParam);
}
else
{
if(pHookedWindow != NULL)
return pHookedWindow->DefWindowProc(message, wParam, lParam);
if (s_DefaultWindowProc)
return CallWindowProc(s_DefaultWindowProc, hWnd, message, wParam, lParam);
return 0;
}
}
BOOL CDreamSkinScrollBar::InitialClass()
{
//Get the default window proc for this class
WNDCLASSW clsScrollBarDefault;
if(!GetClassInfoW(GetModuleHandle(NULL), DEFAULT_SCROLLBAR_CLASSNAME_W, &clsScrollBarDefault))
{
//Get class info failed
//TODO: add error handle code
return FALSE;
}
s_DefaultWindowProc = clsScrollBarDefault.lpfnWndProc;
GetDefaultSkin(&s_SkinScrollBar);
return TRUE;
}
void CDreamSkinScrollBar::DestroyClass()
{
}
BOOL CDreamSkinScrollBar::GetDefaultSkin(SKINSCROLLBAR *pSkinScrollBar)
{
if (pSkinScrollBar)
{
GetDefaultBackground(&pSkinScrollBar->skinBkNormal, RGB(236, 233, 216));
GetDefaultBackground(&pSkinScrollBar->skinBkDisable, RGB(236, 233, 216));
GetDefaultBackground(&pSkinScrollBar->skinHBkNormal, RGB(255, 255, 255));
GetDefaultBackground(&pSkinScrollBar->skinHBkDisable, RGB(236, 233, 216));
GetDefaultBackground(&pSkinScrollBar->skinVBkNormal, RGB(255, 255, 255));
GetDefaultBackground(&pSkinScrollBar->skinVBkDisable, RGB(236, 233, 216));
GetDefaultSysButton(&pSkinScrollBar->skinBtnLeftNormal, RGB(236, 233, 216), RGB(0, 0, 0) , RGB(172, 168, 153)); //COLOR_BTNFACE
GetDefaultSysButton(&pSkinScrollBar->skinBtnRightNormal, RGB(236, 233, 216), RGB(0, 0, 0), RGB(172, 168, 153)); //COLOR_BTNFACE
GetDefaultSysButton(&pSkinScrollBar->skinBtnTopNormal, RGB(236, 233, 216), RGB(0, 0, 0), RGB(172, 168, 153)); //COLOR_BTNFACE
GetDefaultSysButton(&pSkinScrollBar->skinBtnBottomNormal, RGB(236, 233, 216), RGB(0, 0, 0), RGB(172, 168, 153)); //COLOR_BTNFACE
GetDefaultSysButton(&pSkinScrollBar->skinBtnLeftHover, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153)); //COLOR_3DLIGHT
GetDefaultSysButton(&pSkinScrollBar->skinBtnRightHover, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnTopHover, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnBottomHover, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnLeftPress, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnRightPress, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnTopPress, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnBottomPress, RGB(241, 239, 226), RGB(0, 0, 0), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnLeftDisable, RGB(236, 233, 216), RGB(172, 168, 153), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnRightDisable, RGB(236, 233, 216), RGB(172, 168, 153), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnTopDisable, RGB(236, 233, 216), RGB(172, 168, 153), RGB(172, 168, 153));
GetDefaultSysButton(&pSkinScrollBar->skinBtnBottomDisable, RGB(236, 233, 216), RGB(172, 168, 153), RGB(172, 168, 153));
GetDefaultItem(&pSkinScrollBar->skinHItemNormal, RGB(0, 0, 128), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinHItemDisabled, RGB(113, 111, 100), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinHItemHover, RGB(0, 0, 255), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinHItemPress, RGB(113, 111, 100), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinVItemNormal, RGB(0, 0, 128), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinVItemDisabled, RGB(113, 111, 100), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinVItemHover, RGB(0, 0, 255), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultItem(&pSkinScrollBar->skinVItemPress, RGB(113, 111, 100), RGB(255, 255, 255), RGB(0, 0, 0), 0);
GetDefaultBorder(&pSkinScrollBar->skinHLBorderNormal, RGB(172, 168, 153), 0); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinHRBorderNormal, RGB(172, 168, 153), 0); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinHTBorderNormal, RGB(172, 168, 153), 1);
GetDefaultBorder(&pSkinScrollBar->skinHBBorderNormal, RGB(172, 168, 153), 1);
GetDefaultBorder(&pSkinScrollBar->skinVLBorderNormal, RGB(172, 168, 153), 1); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinVRBorderNormal, RGB(172, 168, 153), 1); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinVTBorderNormal, RGB(172, 168, 153), 0);
GetDefaultBorder(&pSkinScrollBar->skinVBBorderNormal, RGB(172, 168, 153), 0);
GetDefaultBorder(&pSkinScrollBar->skinHLBorderDisable, RGB(172, 168, 153), 0); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinHRBorderDisable, RGB(172, 168, 153), 0);
GetDefaultBorder(&pSkinScrollBar->skinHTBorderDisable, RGB(172, 168, 153), 1);
GetDefaultBorder(&pSkinScrollBar->skinHBBorderDisable, RGB(172, 168, 153), 1);
GetDefaultBorder(&pSkinScrollBar->skinVLBorderDisable, RGB(172, 168, 153), 1); //COLOR_GRAYTEXT
GetDefaultBorder(&pSkinScrollBar->skinVRBorderDisable, RGB(172, 168, 153), 1);
GetDefaultBorder(&pSkinScrollBar->skinVTBorderDisable, RGB(172, 168, 153), 0);
GetDefaultBorder(&pSkinScrollBar->skinVBBorderDisable, RGB(172, 168, 153), 0);
pSkinScrollBar->nBtnBottomIncludeBorder = 1;
pSkinScrollBar->nBtnLeftIncludeBorder = 1;
pSkinScrollBar->nBtnRightIncludeBorder = 1;
pSkinScrollBar->nBtnTopIncludeBorder = 1;
pSkinScrollBar->nHThumbIncludeBorder = 0;
pSkinScrollBar->nVThumbIncludeBorder = 0;
}
return TRUE;
}
void CDreamSkinScrollBar::DrawWindowScrollBar(HWND hWnd, HDC hDC, UINT nSBLButtonDown, UINT nSBHover)
{
DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
if (dwStyle & WS_VSCROLL)
{
DrawVertScrollBar(hWnd, hDC, nSBLButtonDown, nSBHover);
}
if (dwStyle & WS_HSCROLL)
{
DrawHorzScrollBar(hWnd, hDC, nSBLButtonDown, nSBHover);
}
}
int CDreamSkinScrollBar::ScrollBarHitTest(HWND hWnd, int fnBar, POINTS point)
{
POINT pt;
pt.x = point.x;
pt.y = point.y;
return ScrollBarHitTest(hWnd, fnBar, pt);
}
int CDreamSkinScrollBar::ScrollBarHitTest(HWND hWnd, int fnBar, POINT point)
{
SCROLLBARINFO ScrollBarInfo;
ScrollBarInfo.cbSize = sizeof(SCROLLBARINFO);
if (fnBar == SB_HORZ)
{
::GetScrollBarInfo(hWnd, OBJID_HSCROLL, &ScrollBarInfo);
}
else if (fnBar == SB_VERT)
{
::GetScrollBarInfo(hWnd, OBJID_VSCROLL, &ScrollBarInfo);
}
else
{
::GetScrollBarInfo(hWnd, OBJID_CLIENT, &ScrollBarInfo);
DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
if ((dwStyle & 0x01) == SBS_HORZ)
fnBar = SB_HORZ;
else
fnBar = SB_VERT;
}
return ScrollBarHitTest(&ScrollBarInfo, fnBar, point);
}
int CDreamSkinScrollBar::ScrollBarHitTest(LPSCROLLBARINFO psbi, int fnBar, POINT point)
{
int nResult = SBHT_NOWHERE;
if (fnBar == SB_HORZ)
{
if (::PtInRect(&psbi->rcScrollBar, point))
{
point.x = point.x - psbi->rcScrollBar.left;
point.y = point.y - psbi->rcScrollBar.top;
if (point.x < psbi->dxyLineButton)
nResult = SBHT_ARROW_TOP;
else if (point.x < psbi->xyThumbTop)
nResult = SBHT_REGION_UP;
else if (point.x < psbi->xyThumbBottom)
nResult = SBHT_THUMB;
else if (point.x < (psbi->rcScrollBar.right - psbi->rcScrollBar.left - psbi->dxyLineButton))
nResult = SBHT_REGION_DOWN;
else
nResult = SBHT_ARROW_BOTTOM;
}
}
else
{
if (::PtInRect(&psbi->rcScrollBar, point))
{
point.x = point.x - psbi->rcScrollBar.left;
point.y = point.y - psbi->rcScrollBar.top;
if (point.y < psbi->dxyLineButton)
nResult = SBHT_ARROW_TOP;
else if (point.y < psbi->xyThumbTop)
nResult = SBHT_REGION_UP;
else if (point.y < psbi->xyThumbBottom)
nResult = SBHT_THUMB;
else if (point.y < (psbi->rcScrollBar.bottom - psbi->rcScrollBar.top - psbi->dxyLineButton))
nResult = SBHT_REGION_DOWN;
else
nResult = SBHT_ARROW_BOTTOM;
}
}
return nResult;
}
void CDreamSkinScrollBar::TrackScrollBar(HWND hWnd, int fnBar, int nSBHitTest, SCROLLBARTRACKINFO *psbti)
{
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(hWnd, fnBar, &ScrollInfo);
UINT nScrollMsg;
int nMsgCode;
int rnBar = fnBar;
if (fnBar == SB_CTL)
{
DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
if ((dwStyle & 0x01) == SBS_HORZ)
fnBar = SB_HORZ;
else
fnBar = SB_VERT;
}
if (fnBar == SB_HORZ)
{
nScrollMsg = WM_HSCROLL;
switch(nSBHitTest)
{
case SBHT_REGION_DOWN:
nMsgCode = SB_PAGERIGHT;
break;
case SBHT_REGION_UP:
nMsgCode = SB_PAGELEFT;
break;
case SBHT_ARROW_TOP:
nMsgCode = SB_LINELEFT;
break;
case SBHT_ARROW_BOTTOM:
nMsgCode = SB_LINERIGHT;
break;
default:
nMsgCode = SB_THUMBTRACK;
break;
}
}
else
{
nScrollMsg = WM_VSCROLL;
switch(nSBHitTest)
{
case SBHT_REGION_DOWN:
nMsgCode = SB_PAGEDOWN;
break;
case SBHT_REGION_UP:
nMsgCode = SB_PAGEUP;
break;
case SBHT_ARROW_TOP:
nMsgCode = SB_LINEUP;
break;
case SBHT_ARROW_BOTTOM:
nMsgCode = SB_LINEDOWN;
break;
default:
nMsgCode = SB_THUMBTRACK;
break;
}
}
MSG Msg;
POINT point;
psbti->bIsTracking = TRUE;
psbti->nTrackPos = ScrollInfo.nPos;
::SetCapture(hWnd);
if (nSBHitTest == SBHT_REGION_DOWN || nSBHitTest == SBHT_REGION_UP || nSBHitTest == SBHT_ARROW_TOP || nSBHitTest == SBHT_ARROW_BOTTOM)
{
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
if (rnBar == SB_CTL)
{
::SendMessage(hWnd, nScrollMsg, nMsgCode, (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
::SendMessage(hWnd, nScrollMsg, nMsgCode, 0);
int nTimer1 = ::SetTimer(0, 0, 500, NULL);
int nTimer2 = 0;
int nNewSBHitTest;
while (::GetCapture() == hWnd && psbti->bIsTracking)
{
if (!::GetMessage(&Msg, NULL, 0, 0))
break;
switch(Msg.message)
{
case WM_LBUTTONUP:
if (nTimer2 > 0)
KillTimer(0, nTimer2);
psbti->bIsTracking = FALSE;
if (psbti->nSBLButtonDown)
psbti->nSBLButtonDown = 0;
if (rnBar == SB_CTL)
{
::SendMessage(hWnd, nScrollMsg, SB_ENDSCROLL, (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
{
::SendMessage(hWnd, nScrollMsg, SB_ENDSCROLL, 0);
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
}
break;
case WM_TIMER:
if (Msg.wParam == nTimer1)
{
::KillTimer(0, nTimer1);
::GetCursorPos(&point);
nNewSBHitTest = ScrollBarHitTest(hWnd, rnBar, point);
if (nNewSBHitTest == nSBHitTest)
if (rnBar == SB_CTL)
{
::SendMessage(hWnd, nScrollMsg, nMsgCode, (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
::SendMessage(hWnd, nScrollMsg, nMsgCode, 0);
nTimer2 = ::SetTimer(0, 0, 100, NULL);
}
else if (Msg.wParam == nTimer2)
{
::GetCursorPos(&point);
nNewSBHitTest = ScrollBarHitTest(hWnd, rnBar, point);
if (nNewSBHitTest == nSBHitTest)
if (rnBar == SB_CTL)
{
::SendMessage(hWnd, nScrollMsg, nMsgCode, (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
::SendMessage(hWnd, nScrollMsg, nMsgCode, 0);
}
else
{
::DispatchMessage(&Msg);
}
break;
default:
::DispatchMessage(&Msg);
break;
}
}
}
else
{
::GetCursorPos(&point);
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
CDreamSkinWindow *pSkinWindow = NULL;
if (rnBar == SB_CTL)
{
pSkinWindow = theSkinMain.GetHookedWindow(hWnd);
if (pSkinWindow && pSkinWindow->GetType() != DREAMSKIN_SCROLLBAR)
pSkinWindow = NULL;
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
SCROLLBARINFO ScrollBarInfo;
ScrollBarInfo.cbSize = sizeof(SCROLLBARINFO);
if (rnBar == SB_CTL)
{
::GetScrollBarInfo(hWnd, OBJID_CLIENT, &ScrollBarInfo);
}
else
{
if (fnBar == SB_HORZ)
{
::GetScrollBarInfo(hWnd, OBJID_HSCROLL, &ScrollBarInfo);
}
else
{
::GetScrollBarInfo(hWnd, OBJID_VSCROLL, &ScrollBarInfo);
}
}
int nOffSet;
if (fnBar == SB_HORZ)
nOffSet = point.x - (ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.xyThumbTop);
else
nOffSet = point.y - (ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.xyThumbTop);
while (::GetCapture() == hWnd && psbti->bIsTracking)
{
if (!::GetMessage(&Msg, NULL, 0, 0))
break;
switch(Msg.message)
{
case WM_LBUTTONUP:
psbti->bIsTracking = FALSE;
::GetCursorPos(&point);
psbti->nTrackPos = ScrollBarDragPos(fnBar, &ScrollInfo, &ScrollBarInfo, point, nOffSet, &psbti->nSBLButtonDown);
if (psbti->nSBLButtonDown)
psbti->nSBLButtonDown = 0;
if (rnBar == SB_CTL)
{
if (pSkinWindow)
pSkinWindow->DefWindowProc(nScrollMsg, MAKEWPARAM(SB_THUMBPOSITION, (unsigned short)psbti->nTrackPos), (LPARAM)hWnd);
else
::SendMessage(hWnd, nScrollMsg, MAKEWPARAM(SB_THUMBPOSITION, (unsigned short)psbti->nTrackPos), (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
{
::SendMessage(hWnd, nScrollMsg, MAKEWPARAM(SB_THUMBPOSITION, (unsigned short)psbti->nTrackPos), 0);
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
}
break;
case WM_MOUSEMOVE:
::GetCursorPos(&point);
psbti->nTrackPos = ScrollBarDragPos(fnBar, &ScrollInfo, &ScrollBarInfo, point, nOffSet, &psbti->nSBLButtonDown);
if (rnBar == SB_CTL)
{
if (pSkinWindow)
pSkinWindow->DefWindowProc(nScrollMsg, MAKEWPARAM(SB_THUMBTRACK, (unsigned short)psbti->nTrackPos), (LPARAM)hWnd);
else
::SendMessage(hWnd, nScrollMsg, MAKEWPARAM(SB_THUMBTRACK, (unsigned short)psbti->nTrackPos), (LPARAM)hWnd);
::InvalidateRect(hWnd, &rcClient, FALSE);
}
else
{
::SendMessage(hWnd, nScrollMsg, MAKEWPARAM(SB_THUMBTRACK, (unsigned short)psbti->nTrackPos), 0);
::SendMessage(hWnd, WM_NCPAINT, 1, 0);
}
break;
default:
DispatchMessage(&Msg);
break;
}
}
}
if (psbti->nSBLButtonDown)
psbti->nSBLButtonDown = 0;
if (::IsWindow(hWnd) && ::GetCapture() == hWnd)
::ReleaseCapture();
}
void CDreamSkinScrollBar::DrawBackground(HDC hDC, SKINBACKGROUND* pBackground, RECT rcDraw)
{
if (pBackground->nDrawType == DRAWTYPE_STRETCHBITMAP && pBackground->imgDraw.hImage)
::DrawStretchBitmap(hDC, rcDraw.left, rcDraw.top, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top, pBackground->imgDraw.hImage, pBackground->imgDraw.x, pBackground->imgDraw.y, pBackground->imgDraw.nWidth, pBackground->imgDraw.nHeight);
else
::FillSolidRect(hDC, &rcDraw, pBackground->clrDraw.clrStart);
}
void CDreamSkinScrollBar::DrawBorder(HDC hDC, RECT rcWindow, int fnBar, int nStatus)
{
SKINBORDER *pLBorder, *pRBorder, *pTBorder, *pBBorder;
if (fnBar == SB_HORZ)
{
if (nStatus == DRAWSTATUS_DISABLE)
{
pLBorder = &s_SkinScrollBar.skinHLBorderDisable;
pRBorder = &s_SkinScrollBar.skinHRBorderDisable;
pTBorder = &s_SkinScrollBar.skinHTBorderDisable;
pBBorder = &s_SkinScrollBar.skinHBBorderDisable;
}
else
{
pLBorder = &s_SkinScrollBar.skinHLBorderNormal;
pRBorder = &s_SkinScrollBar.skinHRBorderNormal;
pTBorder = &s_SkinScrollBar.skinHTBorderNormal;
pBBorder = &s_SkinScrollBar.skinHBBorderNormal;
}
}
else
{
if (nStatus == DRAWSTATUS_DISABLE)
{
pLBorder = &s_SkinScrollBar.skinVLBorderDisable;
pRBorder = &s_SkinScrollBar.skinVRBorderDisable;
pTBorder = &s_SkinScrollBar.skinVTBorderDisable;
pBBorder = &s_SkinScrollBar.skinVBBorderDisable;
}
else
{
pLBorder = &s_SkinScrollBar.skinVLBorderNormal;
pRBorder = &s_SkinScrollBar.skinVRBorderNormal;
pTBorder = &s_SkinScrollBar.skinVTBorderNormal;
pBBorder = &s_SkinScrollBar.skinVBBorderNormal;
}
}
CDreamSkinWindow::DrawBorder(hDC, pLBorder, pRBorder, pTBorder, pBBorder, rcWindow);
}
void CDreamSkinScrollBar::DrawButton(HDC hDC, RECT rcDraw, int fnBar, int nType, int nStatus)
{
SKINSYSBUTTON *pSysButton;
HBRUSH hDrawBrush;
HRGN hRgn;
HPEN hDrawPen, hOldPen;
if (fnBar == SB_HORZ)
{
if (nType == SBHT_ARROW_TOP)
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pSysButton = &s_SkinScrollBar.skinBtnLeftPress;
break;
case DRAWSTATUS_HOVER:
pSysButton = &s_SkinScrollBar.skinBtnLeftHover;
break;
case DRAWSTATUS_DISABLE:
pSysButton = &s_SkinScrollBar.skinBtnLeftDisable;
break;
default:
pSysButton = &s_SkinScrollBar.skinBtnLeftNormal;
break;
}
}
else
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pSysButton = &s_SkinScrollBar.skinBtnRightPress;
break;
case DRAWSTATUS_HOVER:
pSysButton = &s_SkinScrollBar.skinBtnRightHover;
break;
case DRAWSTATUS_DISABLE:
pSysButton = &s_SkinScrollBar.skinBtnRightDisable;
break;
default:
pSysButton = &s_SkinScrollBar.skinBtnRightNormal;
break;
}
}
}
else
{
if (nType == SBHT_ARROW_TOP)
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pSysButton = &s_SkinScrollBar.skinBtnTopPress;
break;
case DRAWSTATUS_HOVER:
pSysButton = &s_SkinScrollBar.skinBtnTopHover;
break;
case DRAWSTATUS_DISABLE:
pSysButton = &s_SkinScrollBar.skinBtnTopDisable;
break;
default:
pSysButton = &s_SkinScrollBar.skinBtnTopNormal;
break;
}
}
else
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pSysButton = &s_SkinScrollBar.skinBtnBottomPress;
break;
case DRAWSTATUS_HOVER:
pSysButton = &s_SkinScrollBar.skinBtnBottomHover;
break;
case DRAWSTATUS_DISABLE:
pSysButton = &s_SkinScrollBar.skinBtnBottomDisable;
break;
default:
pSysButton = &s_SkinScrollBar.skinBtnBottomNormal;
break;
}
}
}
if (pSysButton->nDrawType == DRAWTYPE_STRETCHBITMAP && pSysButton->imgDraw.hImage)
{
::DrawStretchBitmap(hDC, rcDraw.left, rcDraw.top, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top, pSysButton->imgDraw.hImage, pSysButton->imgDraw.x, pSysButton->imgDraw.y, pSysButton->imgDraw.nWidth, pSysButton->imgDraw.nHeight);
}
else
{
::FillSolidRect(hDC, &rcDraw, pSysButton->clrBk.clrStart);
POINT pt[3];
int nWidth = rcDraw.right - rcDraw.left;
int nHeight = rcDraw.bottom - rcDraw.top;
hDrawBrush = ::CreateSolidBrush(pSysButton->clrTxt);
hDrawPen = ::CreatePen(PS_SOLID, 1, pSysButton->clrTxt);
hOldPen = (HPEN)::SelectObject(hDC, hDrawPen);
int nTemp;
if (fnBar == SB_HORZ)
{
if (nType == SBHT_ARROW_TOP) //draw lef button
{
pt[0].x = rcDraw.left + nWidth * 3 / 8;
pt[0].y = rcDraw.top + nHeight / 2;
nTemp = min(nHeight / 4, nWidth / 4);
pt[1].x = pt[0].x + nTemp;
pt[1].y = pt[0].y - nTemp;
pt[2].x = pt[0].x + nTemp;
pt[2].y = pt[0].y + nTemp;
}//draw left button
else //draw right button
{
pt[0].x = rcDraw.right - nWidth * 3 / 8;
pt[0].y = rcDraw.top + nHeight / 2;
nTemp = min(nHeight / 4, nWidth / 4);
pt[1].x = pt[0].x - nTemp;
pt[1].y = pt[0].y - nTemp;
pt[2].x = pt[0].x - nTemp;
pt[2].y = pt[0].y + nTemp;
}//draw right button
}
else
{
if (nType == SBHT_ARROW_TOP) //draw top button
{
pt[0].x = rcDraw.left + nWidth / 2;
pt[0].y = rcDraw.top + nHeight * 3 / 8;
nTemp = min(nHeight / 4, nWidth / 4);
pt[1].x = pt[0].x - nTemp;
pt[1].y = pt[0].y + nTemp;
pt[2].x = pt[0].x + nTemp;
pt[2].y = pt[0].y + nTemp;
}//draw top button
else //draw bottom button
{
pt[0].x = rcDraw.left + nWidth / 2;
pt[0].y = rcDraw.bottom - nHeight * 3 / 8;
nTemp = min(nHeight / 4, nWidth / 4);
pt[1].x = pt[0].x - nTemp;
pt[1].y = pt[0].y - nTemp;
pt[2].x = pt[0].x + nTemp;
pt[2].y = pt[0].y - nTemp;
}//draw bottom button
}
hRgn = ::CreatePolygonRgn(pt, 3, ALTERNATE);
::FillRgn(hDC, hRgn, hDrawBrush);
::MoveToEx(hDC, pt[0].x, pt[0].y, NULL);
::LineTo(hDC, pt[1].x, pt[1].y);
::LineTo(hDC, pt[2].x, pt[2].y);
::LineTo(hDC, pt[0].x, pt[0].y);
::Draw3dRect(hDC, &rcDraw, pSysButton->clrBd, pSysButton->clrBd);
::SelectObject(hDC, hOldPen);
::DeleteObject(hDrawPen);
::DeleteObject(hRgn);
::DeleteObject(hDrawBrush);
}
}
void CDreamSkinScrollBar::DrawThumb(HDC hDC, RECT rcDraw, int fnBar, int nStatus)
{
SKINITEM *pItem;
if (fnBar == SB_HORZ)
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pItem = &s_SkinScrollBar.skinHItemPress;
break;
case DRAWSTATUS_HOVER:
pItem = &s_SkinScrollBar.skinHItemHover;
break;
case DRAWSTATUS_DISABLE:
pItem = &s_SkinScrollBar.skinHItemDisabled;
break;
default:
pItem = &s_SkinScrollBar.skinHItemNormal;
break;
}
}
else
{
switch(nStatus)
{
case DRAWSTATUS_PRESS:
pItem = &s_SkinScrollBar.skinVItemPress;
break;
case DRAWSTATUS_HOVER:
pItem = &s_SkinScrollBar.skinVItemHover;
break;
case DRAWSTATUS_DISABLE:
pItem = &s_SkinScrollBar.skinVItemDisabled;
break;
default:
pItem = &s_SkinScrollBar.skinVItemNormal;
break;
}
}
DrawItem(hDC, pItem, rcDraw, NULL);
}
void CDreamSkinScrollBar::DrawItem(HDC hDC, SKINITEM *pItem, RECT rcItem, WCHAR *wstrTitle)
{
RECT rcClient = GetItemRectClient(pItem, rcItem);
DrawBackground(hDC, &pItem->skinBk, rcClient);
CDreamSkinWindow::DrawBorder(hDC, &pItem->skinLBorder, &pItem->skinRBorder, &pItem->skinTBorder, &pItem->skinBBorder, rcItem);
if (((rcClient.bottom - rcClient.top) >= pItem->skinIcon.nHeight) && ((rcClient.right - rcClient.left) >= pItem->skinIcon.nWidth))
{
RECT rcIcon = GetItemRectIcon(pItem, rcClient, 0);
DrawIcon(hDC, rcIcon, &pItem->skinIcon);
}
}
void CDreamSkinScrollBar::DrawVertScrollBar(HWND hWnd, HDC hDC, UINT nSBLButtonDown, UINT nSBHover)
{
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
RECT rcTop, rcBottom, rcClient, rcItem;
int nStatus;
ScrollBarInfo.cbSize = sizeof(SCROLLBARINFO);
::GetScrollBarInfo(hWnd, OBJID_VSCROLL, &ScrollBarInfo);
if (ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.rcScrollBar.left > 0)
{
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(hWnd, SB_VERT, &ScrollInfo);
RECT rcWindow;
::GetWindowRect(hWnd, &rcWindow);
::OffsetRect(&ScrollBarInfo.rcScrollBar, 0 - rcWindow.left, 0 - rcWindow.top);
DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
SKINBACKGROUND *pBackground;
if(dwStyle & WS_DISABLED)
pBackground = &s_SkinScrollBar.skinBkDisable; //Disabled
else
pBackground = &s_SkinScrollBar.skinBkNormal; //Normal
DrawBackground(hDC, pBackground, ScrollBarInfo.rcScrollBar);
if (ScrollInfo.nMax != ScrollInfo.nMin)
{
rcTop.left = ScrollBarInfo.rcScrollBar.left;
rcTop.top = ScrollBarInfo.rcScrollBar.top;
rcTop.bottom = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.dxyLineButton;
rcTop.right = ScrollBarInfo.rcScrollBar.right;
if (!s_SkinScrollBar.nBtnTopIncludeBorder)
{
rcTop.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcTop.top += s_SkinScrollBar.skinVTBorderNormal.nWidth;
rcTop.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
}
rcBottom.left = ScrollBarInfo.rcScrollBar.left;
rcBottom.top = ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.dxyLineButton;
rcBottom.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcBottom.right = ScrollBarInfo.rcScrollBar.right;
if (!s_SkinScrollBar.nBtnBottomIncludeBorder)
{
rcBottom.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcBottom.bottom -= s_SkinScrollBar.skinVBBorderNormal.nWidth;
rcBottom.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
}
rcClient.left = ScrollBarInfo.rcScrollBar.left;
rcClient.top = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.dxyLineButton;
rcClient.bottom = ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.dxyLineButton;
rcClient.right = ScrollBarInfo.rcScrollBar.right;
rcItem.left = ScrollBarInfo.rcScrollBar.left;
rcItem.right = ScrollBarInfo.rcScrollBar.right;
rcItem.top = ScrollBarInfo.xyThumbTop + ScrollBarInfo.rcScrollBar.top;
rcItem.bottom = ScrollBarInfo.xyThumbBottom + ScrollBarInfo.rcScrollBar.top;
if (!s_SkinScrollBar.nVThumbIncludeBorder)
{
rcItem.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcItem.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
}
//draw top button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_VERT) && ((nSBHover & 0x0000FFFF) == SBHT_ARROW_TOP))
if(((nSBLButtonDown >> 16) == SB_VERT) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_TOP))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcTop, SB_VERT, SBHT_ARROW_TOP, nStatus);
//draw bottom button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_VERT) && ((nSBHover & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
if(((nSBLButtonDown >> 16) == SB_VERT) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcBottom, SB_VERT, SBHT_ARROW_BOTTOM, nStatus);
//draw client area
if(dwStyle & WS_DISABLED)
pBackground = &s_SkinScrollBar.skinVBkDisable; //Disabled
else
pBackground = &s_SkinScrollBar.skinVBkNormal; //Normal
DrawBackground(hDC, pBackground, rcClient);
//draw thumb
if ((rcClient.bottom - rcClient.top) > 5)
{
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_VERT) && ((nSBHover & 0x0000FFFF) == SBHT_THUMB))
if(((nSBLButtonDown >> 16) == SB_VERT) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
if(((nSBLButtonDown >> 16) == SB_VERT) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Drag
else
nStatus = DRAWSTATUS_NORMAL; //normal
DrawThumb(hDC, rcItem, SB_VERT, nStatus);
}
//draw border
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else
nStatus = DRAWSTATUS_NORMAL; //Normal
rcWindow = ScrollBarInfo.rcScrollBar;
if (s_SkinScrollBar.nBtnTopIncludeBorder)
{
rcWindow.top = rcTop.bottom;
}
if (s_SkinScrollBar.nBtnBottomIncludeBorder)
{
rcWindow.bottom = rcBottom.top;
}
DrawBorder(hDC, rcWindow, SB_VERT, nStatus);
}
}
}
void CDreamSkinScrollBar::DrawHorzScrollBar(HWND hWnd, HDC hDC, UINT nSBLButtonDown, UINT nSBHover)
{
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
RECT rcTop, rcBottom, rcClient, rcItem;
int nStatus;
ScrollBarInfo.cbSize = sizeof(SCROLLBARINFO);
::GetScrollBarInfo(hWnd, OBJID_HSCROLL, &ScrollBarInfo);
if (ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.rcScrollBar.top > 0)
{
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(hWnd, SB_HORZ, &ScrollInfo);
RECT rcWindow;
::GetWindowRect(hWnd, &rcWindow);
::OffsetRect(&ScrollBarInfo.rcScrollBar, 0 - rcWindow.left, 0 - rcWindow.top);
DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE);
SKINBACKGROUND *pBackground;
if(dwStyle & WS_DISABLED)
pBackground = &s_SkinScrollBar.skinBkDisable; //Disabled
else
pBackground = &s_SkinScrollBar.skinBkNormal; //Normal
DrawBackground(hDC, pBackground, ScrollBarInfo.rcScrollBar);
if (ScrollInfo.nMax != ScrollInfo.nMin)
{
rcTop.left = ScrollBarInfo.rcScrollBar.left;
rcTop.top = ScrollBarInfo.rcScrollBar.top;
rcTop.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcTop.right = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.dxyLineButton;
if (!s_SkinScrollBar.nBtnLeftIncludeBorder)
{
rcTop.left += s_SkinScrollBar.skinHLBorderNormal.nWidth;
rcTop.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcTop.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
rcBottom.left = ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.dxyLineButton;
rcBottom.top = ScrollBarInfo.rcScrollBar.top;
rcBottom.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcBottom.right = ScrollBarInfo.rcScrollBar.right;
if (!s_SkinScrollBar.nBtnRightIncludeBorder)
{
rcBottom.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcBottom.right -= s_SkinScrollBar.skinHRBorderNormal.nWidth;
rcBottom.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
rcClient.left = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.dxyLineButton;
rcClient.top = ScrollBarInfo.rcScrollBar.top;
rcClient.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcClient.right = ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.dxyLineButton;
rcItem.left = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.xyThumbTop;
rcItem.right = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.xyThumbBottom;
rcItem.top = ScrollBarInfo.rcScrollBar.top;
rcItem.bottom = ScrollBarInfo.rcScrollBar.bottom;
if (!s_SkinScrollBar.nHThumbIncludeBorder)
{
rcItem.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcItem.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
//draw top button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_HORZ) && ((nSBHover & 0x0000FFFF) == SBHT_ARROW_TOP))
if(((nSBLButtonDown >> 16) == SB_HORZ) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_TOP))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcTop, SB_HORZ, SBHT_ARROW_TOP, nStatus);
//draw bottom button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_HORZ) && ((nSBHover & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
if(((nSBLButtonDown >> 16) == SB_HORZ) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcBottom, SB_HORZ, SBHT_ARROW_BOTTOM, nStatus);
//draw client area
if(dwStyle & WS_DISABLED)
pBackground = &s_SkinScrollBar.skinHBkDisable; //Disabled
else
pBackground = &s_SkinScrollBar.skinHBkNormal; //Normal
DrawBackground(hDC, pBackground, rcClient);
//draw thumb
if ((rcClient.right - rcClient.left) > 5)
{
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((nSBHover >> 16) == SB_HORZ) && ((nSBHover & 0x0000FFFF) == SBHT_THUMB))
if(((nSBLButtonDown >> 16) == SB_HORZ) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
if(((nSBLButtonDown >> 16) == SB_HORZ) && ((nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Drag
else
nStatus = DRAWSTATUS_NORMAL; //normal
DrawThumb(hDC, rcItem, SB_HORZ, nStatus);
}
//draw border
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else
nStatus = DRAWSTATUS_NORMAL; //Normal
rcWindow = ScrollBarInfo.rcScrollBar;
if (s_SkinScrollBar.nBtnLeftIncludeBorder)
{
rcWindow.left = rcTop.right;
}
if (s_SkinScrollBar.nBtnRightIncludeBorder)
{
rcWindow.right = rcBottom.left;
}
DrawBorder(hDC, rcWindow, SB_HORZ, nStatus);
}
}
}
int CDreamSkinScrollBar::ScrollBarDragPos(int fnBar, LPSCROLLINFO lpsi, LPSCROLLBARINFO psbi, POINT point, int nOffSet, UINT *pSBLButtonDown)
{
BOOL bIsDrag = TRUE;
int nPos;
if (fnBar == SB_HORZ)
{
if (abs(point.y - (psbi->rcScrollBar.bottom + psbi->rcScrollBar.top) / 2) >= 150)
bIsDrag = FALSE;
else if ((psbi->rcScrollBar.left - point.x >= 10) || (point.x - psbi->rcScrollBar.right) >= 10)
bIsDrag = FALSE;
}
else
{
if (abs(point.x - (psbi->rcScrollBar.right + psbi->rcScrollBar.left) / 2) >= 150)
bIsDrag = FALSE;
else if ((psbi->rcScrollBar.top - point.y >= 10) || (point.y - psbi->rcScrollBar.bottom) >= 10)
bIsDrag = FALSE;
}
if (bIsDrag)
{
if (pSBLButtonDown)
*pSBLButtonDown = ((*pSBLButtonDown) >> 16 << 16) | SBHT_THUMB;
int nTop, nBottom;
if (fnBar == SB_HORZ)
{
point.x -= nOffSet;
nTop = psbi->rcScrollBar.left + psbi->dxyLineButton;
nBottom = psbi->rcScrollBar.right - psbi->dxyLineButton;
if (point.x <= nTop)
nPos = lpsi->nMin;
else if (point.x >= nBottom)
nPos = lpsi->nMax;
else
nPos = (nBottom * lpsi->nMin - nTop * lpsi->nMax + lpsi->nMax * point.x - lpsi->nMin * point.x) / (nBottom - nTop);
}
else
{
point.y -= nOffSet;
nTop = psbi->rcScrollBar.top + psbi->dxyLineButton;
nBottom = psbi->rcScrollBar.bottom - psbi->dxyLineButton;
if (point.y <= nTop)
nPos = lpsi->nMin;
else if (point.y >= nBottom)
nPos = lpsi->nMax;
else
nPos = (nBottom * lpsi->nMin - nTop * lpsi->nMax + lpsi->nMax * point.y - lpsi->nMin * point.y) / (nBottom - nTop);
}
}
else
{
if (pSBLButtonDown)
*pSBLButtonDown = *pSBLButtonDown & 0xFFFF0000;
nPos = lpsi->nPos;
}
return nPos;
}
LRESULT CDreamSkinScrollBar::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT nResult = ERROR_SUCCESS;
switch(message)
{
case SBM_GETSCROLLBARINFO :
nResult = OnGetScrollBarInfo((LPSCROLLBARINFO)lParam);
break;
case SBM_GETSCROLLINFO:
nResult = OnGetScrollInfo(wParam, (LPSCROLLINFO)lParam);
break;
case WM_HSCROLL:
nResult = OnHScroll(wParam, (HWND)lParam);
break;
case WM_LBUTTONDBLCLK:
nResult = ::SendMessageW(m_hWnd, WM_LBUTTONDOWN, wParam, lParam);
break;
case WM_LBUTTONDOWN:
nResult = OnLButtonDown(wParam, MAKEPOINTS(lParam));
break;
case WM_LBUTTONUP:
m_ScrollBarTrackInfo.nSBLButtonDown = 0;
m_ScrollBarTrackInfo.bIsTracking = FALSE;
break;
case WM_MOUSELEAVE:
nResult = OnMouseLeave();
break;
case WM_MOUSEMOVE:
nResult = OnMouseMove(wParam, MAKEPOINTS(lParam));
break;
case WM_PAINT:
nResult = OnPaint();
break;
case WM_VSCROLL:
nResult = OnVScroll(wParam, (HWND)lParam);
break;
default:
nResult = CDreamSkinWindow::DefWindowProc(message, wParam, lParam);
break;
}
return nResult;
}
LRESULT CDreamSkinScrollBar::OnGetScrollBarInfo(LPSCROLLBARINFO psbi)
{
RECT rcWindow;
::GetWindowRect(m_hWnd, &rcWindow);
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
return GetScrollBarInfo(rcWindow, (dwStyle & 0x01) == SBS_HORZ ? SB_HORZ : SB_VERT, &ScrollInfo, psbi);
}
LRESULT CDreamSkinScrollBar::OnGetScrollInfo(int fnBar, LPSCROLLINFO lpsi)
{
BOOL bResult = FALSE;
if (lpsi->fMask == SIF_TRACKPOS)
{
if (m_ScrollBarTrackInfo.bIsTracking)
{
lpsi->nTrackPos = m_ScrollBarTrackInfo.nTrackPos;
bResult = TRUE;
}
}
else
{
bResult = CDreamSkinWindow::DefWindowProc(SBM_GETSCROLLINFO, fnBar, (LPARAM)lpsi);
}
return bResult;
}
LRESULT CDreamSkinScrollBar::OnHScroll(UINT nSBCode, HWND hWndCtrl)
{
LRESULT lResult = 0;
if (hWndCtrl == m_hWnd)
{
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
switch(nSBCode & 0x0000FFFF)
{
case SB_LINELEFT:
if (ScrollInfo.nPos > ScrollInfo.nMin)
{
ScrollInfo.nPos -= 1;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
break;
case SB_LINERIGHT:
if (ScrollInfo.nPos < ScrollInfo.nMax)
{
ScrollInfo.nPos += 1;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
break;
case SB_PAGELEFT:
if (ScrollInfo.nPos > ScrollInfo.nMin)
{
ScrollInfo.nPos -= ScrollInfo.nPage;
if (ScrollInfo.nPos < ScrollInfo.nMin)
ScrollInfo.nPos = ScrollInfo.nMin;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
break;
case SB_PAGERIGHT:
if (ScrollInfo.nPos < ScrollInfo.nMax)
{
ScrollInfo.nPos += ScrollInfo.nPage;
if (ScrollInfo.nPos > ScrollInfo.nMax)
ScrollInfo.nPos = ScrollInfo.nMax;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
break;
case SB_THUMBPOSITION:
if (m_ScrollBarTrackInfo.nTrackPos != ScrollInfo.nPos)
{
ScrollInfo.nPos = m_ScrollBarTrackInfo.nTrackPos;
if (ScrollInfo.nPos > ScrollInfo.nMax)
ScrollInfo.nPos = ScrollInfo.nMax;
if (ScrollInfo.nPos < ScrollInfo.nMin)
ScrollInfo.nPos = ScrollInfo.nMin;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
nSBCode = SB_ENDSCROLL;
break;
}
HWND hWndParent = ::GetParent(hWndCtrl);
if (hWndParent)
lResult = ::SendMessage(hWndParent, WM_HSCROLL, nSBCode, (LPARAM)hWndCtrl);
else
lResult = CDreamSkinWindow::DefWindowProc(m_hWnd, WM_HSCROLL, nSBCode, (LPARAM)hWndCtrl);
}
return lResult;
}
LRESULT CDreamSkinScrollBar::OnLButtonDown(UINT nFlags, POINTS point)
{
LRESULT nResult = 0;
POINT pt;
pt.x = point.x;
pt.y = point.y;
int nSBHover = 0;
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
int fnBar = SB_HORZ;
if ((dwStyle & 0x01) == SBS_VERT)
fnBar = SB_VERT;
GetScrollBarInfo(rcClient, fnBar, &ScrollInfo, &ScrollBarInfo);
switch(ScrollBarHitTest(&ScrollBarInfo, fnBar, pt))
{
case SBHT_THUMB:
m_ScrollBarTrackInfo.nSBLButtonDown = fnBar << 16 | SBHT_THUMB;
TrackScrollBar(m_hWnd, SB_CTL, SBHT_THUMB, &m_ScrollBarTrackInfo);
break;
case SBHT_REGION_UP:
m_ScrollBarTrackInfo.nSBLButtonDown = fnBar << 16 | SBHT_REGION_UP;
TrackScrollBar(m_hWnd, SB_CTL, SBHT_REGION_UP, &m_ScrollBarTrackInfo);
break;
case SBHT_REGION_DOWN:
m_ScrollBarTrackInfo.nSBLButtonDown = fnBar << 16 | SBHT_REGION_DOWN;
TrackScrollBar(m_hWnd, SB_CTL, SBHT_REGION_DOWN, &m_ScrollBarTrackInfo);
break;
case SBHT_ARROW_TOP:
m_ScrollBarTrackInfo.nSBLButtonDown = fnBar << 16 | SBHT_ARROW_TOP;
TrackScrollBar(m_hWnd, SB_CTL, SBHT_ARROW_TOP, &m_ScrollBarTrackInfo);
break;
case SBHT_ARROW_BOTTOM:
m_ScrollBarTrackInfo.nSBLButtonDown = fnBar << 16 | SBHT_ARROW_BOTTOM;
TrackScrollBar(m_hWnd, SB_CTL, SBHT_ARROW_BOTTOM, &m_ScrollBarTrackInfo);
break;
default:
m_ScrollBarTrackInfo.nSBLButtonDown = 0;
::InvalidateRect(m_hWnd, &rcClient, FALSE);
break;
}
return nResult;
}
LRESULT CDreamSkinScrollBar::OnMouseLeave()
{
if (m_nSBHover > 0)
{
POINT point;
::GetCursorPos(&point);
int nSBHover = 0;
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
int fnBar = SB_HORZ;
if ((dwStyle & 0x01) == SBS_VERT)
fnBar = SB_VERT;
GetScrollBarInfo(rcClient, fnBar, &ScrollInfo, &ScrollBarInfo);
nSBHover = ScrollBarHitTest(&ScrollBarInfo, fnBar, point);
if (nSBHover > 0)
nSBHover = fnBar << 16 | nSBHover;
if (nSBHover != m_nSBHover)
{
m_nSBHover = nSBHover;
::InvalidateRect(m_hWnd, &rcClient, FALSE);
}
}
return 0;
}
LRESULT CDreamSkinScrollBar::OnMouseMove(UINT nFlags, POINTS point)
{
TRACKMOUSEEVENT EventTrack;
EventTrack.cbSize = sizeof(TRACKMOUSEEVENT);
EventTrack.dwFlags = TME_LEAVE;
EventTrack.hwndTrack = m_hWnd;
EventTrack.dwHoverTime = 0;
TrackMouseEvent(&EventTrack);
POINT pt;
pt.x = point.x;
pt.y = point.y;
int nSBHover = 0;
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
int fnBar = SB_HORZ;
if ((dwStyle & 0x01) == SBS_VERT)
fnBar = SB_VERT;
GetScrollBarInfo(rcClient, fnBar, &ScrollInfo, &ScrollBarInfo);
nSBHover = ScrollBarHitTest(&ScrollBarInfo, fnBar, pt);
if (nSBHover > 0)
nSBHover = fnBar << 16 | nSBHover;
if (nSBHover != m_nSBHover)
{
m_nSBHover = nSBHover;
::InvalidateRect(m_hWnd, &rcClient, FALSE);
}
return 0;
}
LRESULT CDreamSkinScrollBar::OnPaint()
{
PAINTSTRUCT ps;
HDC hPaintDC = ::BeginPaint(m_hWnd, &ps);
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
if ((dwStyle & 0x01) == SBS_HORZ)
{
DrawHorzScrollBar(hPaintDC, dwStyle);
}
else
{
DrawVertScrollBar(hPaintDC, dwStyle);
}
::EndPaint(m_hWnd, &ps);
return 0;
}
LRESULT CDreamSkinScrollBar::OnVScroll(UINT nSBCode, HWND hWndCtrl)
{
LRESULT lResult = 0;
if (hWndCtrl == m_hWnd)
{
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
switch(nSBCode & 0x0000FFFF)
{
case SB_LINEUP:
if (ScrollInfo.nPos > ScrollInfo.nMin)
{
ScrollInfo.nPos -= 1;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, TRUE);
}
break;
case SB_LINEDOWN:
if (ScrollInfo.nPos < ScrollInfo.nMax)
{
ScrollInfo.nPos += 1;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, TRUE);
}
break;
case SB_PAGEUP:
if (ScrollInfo.nPos > ScrollInfo.nMin)
{
ScrollInfo.nPos -= ScrollInfo.nPage;
if (ScrollInfo.nPos < ScrollInfo.nMin)
ScrollInfo.nPos = ScrollInfo.nMin;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, TRUE);
}
break;
case SB_PAGEDOWN:
if (ScrollInfo.nPos < ScrollInfo.nMax)
{
ScrollInfo.nPos += ScrollInfo.nPage;
if (ScrollInfo.nPos > ScrollInfo.nMax)
ScrollInfo.nPos = ScrollInfo.nMax;
m_ScrollBarTrackInfo.nTrackPos = ScrollInfo.nPos;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, TRUE);
}
break;
case SB_THUMBPOSITION:
if (m_ScrollBarTrackInfo.nTrackPos != ScrollInfo.nPos)
{
ScrollInfo.nPos = m_ScrollBarTrackInfo.nTrackPos;
if (ScrollInfo.nPos > ScrollInfo.nMax)
ScrollInfo.nPos = ScrollInfo.nMax;
if (ScrollInfo.nPos < ScrollInfo.nMin)
ScrollInfo.nPos = ScrollInfo.nMin;
ScrollInfo.fMask = SIF_POS;
::SetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo, FALSE);
}
nSBCode = SB_ENDSCROLL;
break;
}
HWND hWndParent = ::GetParent(hWndCtrl);
if (hWndParent)
lResult = ::SendMessage(hWndParent, WM_VSCROLL, nSBCode, (LPARAM)hWndCtrl);
else
lResult = CDreamSkinWindow::DefWindowProc(m_hWnd, WM_VSCROLL, nSBCode, (LPARAM)hWndCtrl);
}
return lResult;
}
void CDreamSkinScrollBar::DrawHorzScrollBar(HDC hDC, DWORD dwStyle)
{
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
RECT rcTop, rcBottom, rcClient, rcItem;
int nStatus;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
RECT rcWindow;
::GetClientRect(m_hWnd, &rcWindow);
GetScrollBarInfo(rcWindow, SB_HORZ, &ScrollInfo, &ScrollBarInfo);
if (ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.rcScrollBar.top > 0)
{
SKINBACKGROUND *pBackground;
if(dwStyle & WS_DISABLED)
pBackground = &m_pSkinScrollBar->skinBkDisable; //Disabled
else
pBackground = &m_pSkinScrollBar->skinHBkNormal; //Normal
DrawBackground(hDC, pBackground, rcWindow);
if (ScrollInfo.nMax != ScrollInfo.nMin)
{
rcTop.left = ScrollBarInfo.rcScrollBar.left;
rcTop.top = ScrollBarInfo.rcScrollBar.top;
rcTop.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcTop.right = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.dxyLineButton;
if (!m_pSkinScrollBar->nBtnLeftIncludeBorder)
{
rcTop.left += s_SkinScrollBar.skinHLBorderNormal.nWidth;
rcTop.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcTop.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
rcBottom.left = ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.dxyLineButton;
rcBottom.top = ScrollBarInfo.rcScrollBar.top;
rcBottom.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcBottom.right = ScrollBarInfo.rcScrollBar.right;
if (!m_pSkinScrollBar->nBtnRightIncludeBorder)
{
rcBottom.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcBottom.right -= s_SkinScrollBar.skinHRBorderNormal.nWidth;
rcBottom.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
rcClient.left = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.dxyLineButton;
rcClient.top = ScrollBarInfo.rcScrollBar.top;
rcClient.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcClient.right = ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.dxyLineButton;
rcItem.left = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.xyThumbTop;
rcItem.right = ScrollBarInfo.rcScrollBar.left + ScrollBarInfo.xyThumbBottom;
rcItem.top = ScrollBarInfo.rcScrollBar.top;
rcItem.bottom = ScrollBarInfo.rcScrollBar.bottom;
if (!m_pSkinScrollBar->nHThumbIncludeBorder)
{
rcItem.top += s_SkinScrollBar.skinHTBorderNormal.nWidth;
rcItem.bottom -= s_SkinScrollBar.skinHBBorderNormal.nWidth;
}
//draw top button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_HORZ) && ((m_nSBHover & 0x0000FFFF) == SBHT_ARROW_TOP))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_HORZ) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_TOP))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcTop, SB_HORZ, SBHT_ARROW_TOP, nStatus);
//draw bottom button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_HORZ) && ((m_nSBHover & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_HORZ) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcBottom, SB_HORZ, SBHT_ARROW_BOTTOM, nStatus);
//draw client area
if(dwStyle & WS_DISABLED)
pBackground = &m_pSkinScrollBar->skinHBkDisable; //Disabled
else
pBackground = &m_pSkinScrollBar->skinHBkNormal; //Normal
DrawBackground(hDC, pBackground, rcClient);
//draw thumb
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_HORZ) && ((m_nSBHover & 0x0000FFFF) == SBHT_THUMB))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_HORZ) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_HORZ) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Drag
else
nStatus = DRAWSTATUS_NORMAL; //normal
DrawThumb(hDC, rcItem, SB_HORZ, nStatus);
//draw border
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else
nStatus = DRAWSTATUS_NORMAL; //Normal
RECT rcWindow = ScrollBarInfo.rcScrollBar;
if (m_pSkinScrollBar->nBtnLeftIncludeBorder)
{
rcWindow.left = rcTop.right;
}
if (m_pSkinScrollBar->nBtnRightIncludeBorder)
{
rcWindow.right = rcBottom.left;
}
DrawBorder(hDC, rcWindow, SB_HORZ, nStatus);
}
}
}
void CDreamSkinScrollBar::DrawVertScrollBar(HDC hDC, DWORD dwStyle)
{
SCROLLINFO ScrollInfo;
SCROLLBARINFO ScrollBarInfo;
RECT rcTop, rcBottom, rcClient, rcItem;
int nStatus;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_ALL;
::GetScrollInfo(m_hWnd, SB_CTL, &ScrollInfo);
RECT rcWindow;
::GetClientRect(m_hWnd, &rcWindow);
GetScrollBarInfo(rcWindow, SB_VERT, &ScrollInfo, &ScrollBarInfo);
if (ScrollBarInfo.rcScrollBar.right - ScrollBarInfo.rcScrollBar.left > 0)
{
SKINBACKGROUND *pBackground;
if(dwStyle & WS_DISABLED)
pBackground = &m_pSkinScrollBar->skinBkDisable; //Disabled
else
pBackground = &m_pSkinScrollBar->skinHBkNormal; //Normal
DrawBackground(hDC, pBackground, rcWindow);
if (ScrollInfo.nMax != ScrollInfo.nMin)
{
rcTop.left = ScrollBarInfo.rcScrollBar.left;
rcTop.top = ScrollBarInfo.rcScrollBar.top;
rcTop.bottom = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.dxyLineButton;;
rcTop.right = ScrollBarInfo.rcScrollBar.right;
if (!m_pSkinScrollBar->nBtnTopIncludeBorder)
{
rcTop.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcTop.top += s_SkinScrollBar.skinVTBorderNormal.nWidth;
rcTop.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
}
rcBottom.left = ScrollBarInfo.rcScrollBar.left;
rcBottom.top = ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.dxyLineButton;
rcBottom.bottom = ScrollBarInfo.rcScrollBar.bottom;
rcBottom.right = ScrollBarInfo.rcScrollBar.right;
if (!m_pSkinScrollBar->nBtnBottomIncludeBorder)
{
rcBottom.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcBottom.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
rcBottom.bottom -= s_SkinScrollBar.skinVBBorderNormal.nWidth;
}
rcClient.left = ScrollBarInfo.rcScrollBar.left;
rcClient.top = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.dxyLineButton;
rcClient.bottom = ScrollBarInfo.rcScrollBar.bottom - ScrollBarInfo.dxyLineButton;
rcClient.right = ScrollBarInfo.rcScrollBar.right;
rcItem.left = ScrollBarInfo.rcScrollBar.left;
rcItem.right = ScrollBarInfo.rcScrollBar.right;
rcItem.top = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.xyThumbTop;
rcItem.bottom = ScrollBarInfo.rcScrollBar.top + ScrollBarInfo.xyThumbBottom;
if (!m_pSkinScrollBar->nVThumbIncludeBorder)
{
rcItem.left += s_SkinScrollBar.skinVLBorderNormal.nWidth;
rcItem.right -= s_SkinScrollBar.skinVRBorderNormal.nWidth;
}
//draw top button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_VERT) && ((m_nSBHover & 0x0000FFFF) == SBHT_ARROW_TOP))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_VERT) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_TOP))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcTop, SB_VERT, SBHT_ARROW_TOP, nStatus);
//draw bottom button
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_VERT) && ((m_nSBHover & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_VERT) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_ARROW_BOTTOM))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
nStatus = DRAWSTATUS_NORMAL; //Normal
DrawButton(hDC, rcBottom, SB_VERT, SBHT_ARROW_BOTTOM, nStatus);
//draw client area
if(dwStyle & WS_DISABLED)
pBackground = &m_pSkinScrollBar->skinVBkDisable; //Disabled
else
pBackground = &m_pSkinScrollBar->skinVBkNormal; //Normal
DrawBackground(hDC, pBackground, rcClient);
//draw thumb
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else if(((m_nSBHover >> 16) == SB_VERT) && ((m_nSBHover & 0x0000FFFF) == SBHT_THUMB))
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_VERT) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Pressed
else
nStatus = DRAWSTATUS_HOVER; //Hover
else
if(((m_ScrollBarTrackInfo.nSBLButtonDown >> 16) == SB_VERT) && ((m_ScrollBarTrackInfo.nSBLButtonDown & 0x0000FFFF) == SBHT_THUMB))
nStatus = DRAWSTATUS_PRESS; //Drag
else
nStatus = DRAWSTATUS_NORMAL; //normal
DrawThumb(hDC, rcItem, SB_VERT, nStatus);
//draw border
if(dwStyle & WS_DISABLED)
nStatus = DRAWSTATUS_DISABLE; //Disabled
else
nStatus = DRAWSTATUS_NORMAL; //Normal
RECT rcWindow = ScrollBarInfo.rcScrollBar;
if (m_pSkinScrollBar->nBtnTopIncludeBorder)
{
rcWindow.top = rcTop.bottom;
}
if (m_pSkinScrollBar->nBtnBottomIncludeBorder)
{
rcWindow.bottom = rcBottom.top;
}
DrawBorder(hDC, rcWindow, SB_VERT, nStatus);
}
}
}
BOOL CDreamSkinScrollBar::GetScrollBarInfo(RECT rcWindow, int fnBar, LPSCROLLINFO lpsi, PSCROLLBARINFO psbi)
{
int nClient, nThumb;
psbi->rcScrollBar = rcWindow;
RECT rcClient = rcWindow;
::OffsetRect(&rcClient, 0 - rcWindow.left, 0 - rcWindow.top);
if (lpsi->nMax == lpsi->nMin)
{
psbi->dxyLineButton = 0;
psbi->xyThumbBottom = 0;
psbi->xyThumbTop = 0;
}
else
{
if (fnBar == SB_HORZ)
{
if (m_pSkinScrollBar->skinBtnLeftNormal.nDrawType == DRAWTYPE_STRETCHBITMAP && m_pSkinScrollBar->skinBtnLeftNormal.imgDraw.hImage)
psbi->dxyLineButton = m_pSkinScrollBar->skinBtnLeftNormal.imgDraw.nWidth;
else
psbi->dxyLineButton = DEFAULT_SCROLLBAR_BUTTON_XY; //Hardcode value
if ((rcClient.right - rcClient.left) <= (psbi->dxyLineButton * 2))
psbi->dxyLineButton = (rcClient.right - rcClient.left) / 2;
nClient = rcClient.right - rcClient.left - psbi->dxyLineButton * 2;
nThumb = lpsi->nPage * nClient / (lpsi->nMax - lpsi->nMin);
if (m_ScrollBarTrackInfo.bIsTracking && (lpsi->fMask & SIF_TRACKPOS))
{
if (m_ScrollBarTrackInfo.nTrackPos > lpsi->nMin)
psbi->xyThumbTop = psbi->dxyLineButton + (m_ScrollBarTrackInfo.nTrackPos - lpsi->nMin) * nClient / (lpsi->nMax - lpsi->nMin);
else
psbi->xyThumbTop = psbi->dxyLineButton;
}
else
{
if (lpsi->nPos > lpsi->nMin)
psbi->xyThumbTop = psbi->dxyLineButton + (lpsi->nPos - lpsi->nMin) * nClient / (lpsi->nMax - lpsi->nMin);
else
psbi->xyThumbTop = psbi->dxyLineButton;
}
if ((psbi->xyThumbTop + nThumb) > (psbi->dxyLineButton + nClient))
psbi->xyThumbTop = psbi->dxyLineButton + nClient - nThumb;
psbi->xyThumbBottom = psbi->xyThumbTop + nThumb;
if (psbi->xyThumbTop < psbi->dxyLineButton)
psbi->xyThumbTop = psbi->dxyLineButton;
}
else
{
if (m_pSkinScrollBar->skinBtnTopNormal.nDrawType == DRAWTYPE_STRETCHBITMAP && m_pSkinScrollBar->skinBtnTopNormal.imgDraw.hImage)
psbi->dxyLineButton = m_pSkinScrollBar->skinBtnTopNormal.imgDraw.nHeight;
else
psbi->dxyLineButton = DEFAULT_SCROLLBAR_BUTTON_XY; //Hardcode value
if ((rcClient.bottom - rcClient.top) <= (psbi->dxyLineButton * 2))
psbi->dxyLineButton = (rcClient.bottom - rcClient.top) / 2;
nClient = rcClient.bottom - rcClient.top - psbi->dxyLineButton * 2;
nThumb = lpsi->nPage * nClient / (lpsi->nMax - lpsi->nMin);
if (m_ScrollBarTrackInfo.bIsTracking && (lpsi->fMask & SIF_TRACKPOS))
{
if (m_ScrollBarTrackInfo.nTrackPos > lpsi->nMin)
psbi->xyThumbTop = psbi->dxyLineButton + (m_ScrollBarTrackInfo.nTrackPos - lpsi->nMin) * nClient / (lpsi->nMax - lpsi->nMin);
else
psbi->xyThumbTop = psbi->dxyLineButton;
}
else
{
if (lpsi->nPos > lpsi->nMin)
psbi->xyThumbTop = psbi->dxyLineButton + (lpsi->nPos - lpsi->nMin) * nClient / (lpsi->nMax - lpsi->nMin);
else
psbi->xyThumbTop = psbi->dxyLineButton;
}
if ((psbi->xyThumbTop + nThumb) > (psbi->dxyLineButton + nClient))
psbi->xyThumbTop = psbi->dxyLineButton + nClient - nThumb;
psbi->xyThumbBottom = psbi->xyThumbTop + nThumb;
if (psbi->xyThumbTop < psbi->dxyLineButton)
psbi->xyThumbTop = psbi->dxyLineButton;
}
}
for (int i = 0; i <= CCHILDREN_SCROLLBAR; i++)
psbi->rgstate[i] = 0;
psbi->reserved = 0;
return TRUE;
} | [
"[email protected]"
] | |
607e263a0e83a795e51ed6e6bca605b26dd4ea90 | 299648a8c633728662d0b7651cd98afdc28db902 | /src/thirdparty/sentry-native/external/crashpad/util/linux/memory_map_test.cc | 0ee908001249f3170aa49c1110bd37120a37fa8c | [
"MIT",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | aardvarkxr/aardvark | 2978277b34c2c3894d6aafc4c590f3bda50f4d43 | 300d0d5e9b872ed839fae932c56eff566967d24b | refs/heads/master | 2023-01-12T18:42:10.705028 | 2021-08-18T04:09:02 | 2021-08-18T04:09:02 | 182,431,653 | 183 | 25 | BSD-3-Clause | 2023-01-07T12:42:14 | 2019-04-20T16:55:30 | TypeScript | UTF-8 | C++ | false | false | 23,390 | cc | // Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/linux/memory_map.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "base/files/file_path.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/file.h"
#include "test/linux/fake_ptrace_connection.h"
#include "test/multiprocess.h"
#include "test/scoped_temp_dir.h"
#include "third_party/lss/lss.h"
#include "util/file/file_io.h"
#include "util/file/scoped_remove_file.h"
#include "util/linux/direct_ptrace_connection.h"
#include "util/misc/clock.h"
#include "util/misc/from_pointer_cast.h"
#include "util/posix/scoped_mmap.h"
namespace crashpad {
namespace test {
namespace {
TEST(MemoryMap, SelfLargeFiles) {
// This test is meant to test the handler's ability to understand files
// mapped from large offsets, even if the handler wasn't built with
// _FILE_OFFSET_BITS=64. ScopedTempDir needs to stat files to determine
// whether to recurse into directories, which may will fail without large file
// support. ScopedRemoveFile doesn't have that restriction.
ScopedTempDir dir;
ScopedRemoveFile large_file_path(dir.path().Append("crashpad_test_file"));
ScopedFileHandle handle(
LoggingOpenFileForReadAndWrite(large_file_path.get(),
FileWriteMode::kCreateOrFail,
FilePermissions::kWorldReadable));
ASSERT_TRUE(handle.is_valid());
// sys_fallocate supports large files as long as the kernel supports them,
// regardless of _FILE_OFFSET_BITS.
off64_t off = 1llu + UINT32_MAX;
ASSERT_EQ(sys_fallocate(handle.get(), 0, off, getpagesize()), 0)
<< ErrnoMessage("fallocate");
ScopedMmap mapping;
void* addr = sys_mmap(
nullptr, getpagesize(), PROT_READ, MAP_SHARED, handle.get(), off);
ASSERT_TRUE(addr);
ASSERT_TRUE(mapping.ResetAddrLen(addr, getpagesize()));
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
}
TEST(MemoryMap, SelfBasic) {
ScopedMmap mmapping;
ASSERT_TRUE(mmapping.ResetMmap(nullptr,
getpagesize(),
PROT_EXEC | PROT_READ,
MAP_SHARED | MAP_ANON,
-1,
0));
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
auto stack_address = FromPointerCast<LinuxVMAddress>(&map);
const MemoryMap::Mapping* mapping = map.FindMapping(stack_address);
ASSERT_TRUE(mapping);
EXPECT_GE(stack_address, mapping->range.Base());
EXPECT_LT(stack_address, mapping->range.End());
EXPECT_TRUE(mapping->readable);
EXPECT_TRUE(mapping->writable);
auto code_address = FromPointerCast<LinuxVMAddress>(getpid);
mapping = map.FindMapping(code_address);
ASSERT_TRUE(mapping);
EXPECT_GE(code_address, mapping->range.Base());
EXPECT_LT(code_address, mapping->range.End());
#if !defined(OS_ANDROID)
// Android Q+ supports execute only memory.
EXPECT_TRUE(mapping->readable);
#endif
EXPECT_FALSE(mapping->writable);
EXPECT_TRUE(mapping->executable);
auto mapping_address = mmapping.addr_as<LinuxVMAddress>();
mapping = map.FindMapping(mapping_address);
ASSERT_TRUE(mapping);
mapping = map.FindMapping(mapping_address + mmapping.len() - 1);
ASSERT_TRUE(mapping);
EXPECT_EQ(mapping_address, mapping->range.Base());
EXPECT_EQ(mapping_address + mmapping.len(), mapping->range.End());
EXPECT_TRUE(mapping->readable);
EXPECT_FALSE(mapping->writable);
EXPECT_TRUE(mapping->executable);
EXPECT_TRUE(mapping->shareable);
}
void InitializeFile(const base::FilePath& path,
size_t size,
ScopedFileHandle* handle) {
ASSERT_FALSE(FileExists(path));
handle->reset(LoggingOpenFileForReadAndWrite(
path, FileWriteMode::kReuseOrCreate, FilePermissions::kOwnerOnly));
ASSERT_TRUE(handle->is_valid());
std::string file_contents(size, std::string::value_type());
CheckedWriteFile(handle->get(), file_contents.c_str(), file_contents.size());
}
class MapChildTest : public Multiprocess {
public:
MapChildTest() : Multiprocess(), page_size_(getpagesize()) {}
~MapChildTest() {}
private:
void MultiprocessParent() override {
LinuxVMAddress code_address;
CheckedReadFileExactly(
ReadPipeHandle(), &code_address, sizeof(code_address));
LinuxVMAddress stack_address;
CheckedReadFileExactly(
ReadPipeHandle(), &stack_address, sizeof(stack_address));
LinuxVMAddress mapped_address;
CheckedReadFileExactly(
ReadPipeHandle(), &mapped_address, sizeof(mapped_address));
LinuxVMAddress mapped_file_address;
CheckedReadFileExactly(
ReadPipeHandle(), &mapped_file_address, sizeof(mapped_file_address));
LinuxVMSize path_length;
CheckedReadFileExactly(ReadPipeHandle(), &path_length, sizeof(path_length));
std::string mapped_file_name(path_length, std::string::value_type());
CheckedReadFileExactly(ReadPipeHandle(), &mapped_file_name[0], path_length);
DirectPtraceConnection connection;
ASSERT_TRUE(connection.Initialize(ChildPID()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
const MemoryMap::Mapping* mapping = map.FindMapping(code_address);
ASSERT_TRUE(mapping);
EXPECT_GE(code_address, mapping->range.Base());
EXPECT_LT(code_address, mapping->range.End());
#if !defined(OS_ANDROID)
// Android Q+ supports execute only memory.
EXPECT_TRUE(mapping->readable);
#endif
EXPECT_TRUE(mapping->executable);
EXPECT_FALSE(mapping->writable);
mapping = map.FindMapping(stack_address);
ASSERT_TRUE(mapping);
EXPECT_GE(stack_address, mapping->range.Base());
EXPECT_LT(stack_address, mapping->range.End());
EXPECT_TRUE(mapping->readable);
EXPECT_TRUE(mapping->writable);
mapping = map.FindMapping(mapped_address);
ASSERT_TRUE(mapping);
EXPECT_EQ(mapped_address, mapping->range.Base());
EXPECT_EQ(mapped_address + page_size_, mapping->range.End());
EXPECT_FALSE(mapping->readable);
EXPECT_FALSE(mapping->writable);
EXPECT_FALSE(mapping->executable);
EXPECT_TRUE(mapping->shareable);
mapping = map.FindMapping(mapped_file_address);
ASSERT_TRUE(mapping);
EXPECT_EQ(mapped_file_address, mapping->range.Base());
EXPECT_EQ(mapping->offset, static_cast<int64_t>(page_size_));
EXPECT_TRUE(mapping->readable);
EXPECT_TRUE(mapping->writable);
EXPECT_FALSE(mapping->executable);
EXPECT_FALSE(mapping->shareable);
EXPECT_EQ(mapping->name, mapped_file_name);
struct stat file_stat;
ASSERT_EQ(stat(mapped_file_name.c_str(), &file_stat), 0)
<< ErrnoMessage("stat");
EXPECT_EQ(mapping->device, file_stat.st_dev);
EXPECT_EQ(mapping->inode, file_stat.st_ino);
EXPECT_EQ(map.FindMappingWithName(mapping->name), mapping);
}
void MultiprocessChild() override {
auto code_address = FromPointerCast<LinuxVMAddress>(getpid);
CheckedWriteFile(WritePipeHandle(), &code_address, sizeof(code_address));
auto stack_address = FromPointerCast<LinuxVMAddress>(&code_address);
CheckedWriteFile(WritePipeHandle(), &stack_address, sizeof(stack_address));
ScopedMmap mapping;
ASSERT_TRUE(mapping.ResetMmap(
nullptr, page_size_, PROT_NONE, MAP_SHARED | MAP_ANON, -1, 0));
auto mapped_address = mapping.addr_as<LinuxVMAddress>();
CheckedWriteFile(
WritePipeHandle(), &mapped_address, sizeof(mapped_address));
ScopedTempDir temp_dir;
base::FilePath path =
temp_dir.path().Append(FILE_PATH_LITERAL("test_file"));
ScopedFileHandle handle;
ASSERT_NO_FATAL_FAILURE(InitializeFile(path, page_size_ * 2, &handle));
ScopedMmap file_mapping;
ASSERT_TRUE(file_mapping.ResetMmap(nullptr,
page_size_,
PROT_READ | PROT_WRITE,
MAP_PRIVATE,
handle.get(),
page_size_));
auto mapped_file_address = file_mapping.addr_as<LinuxVMAddress>();
CheckedWriteFile(
WritePipeHandle(), &mapped_file_address, sizeof(mapped_file_address));
LinuxVMSize path_length = path.value().size();
CheckedWriteFile(WritePipeHandle(), &path_length, sizeof(path_length));
CheckedWriteFile(WritePipeHandle(), path.value().c_str(), path_length);
CheckedReadFileAtEOF(ReadPipeHandle());
}
const size_t page_size_;
DISALLOW_COPY_AND_ASSIGN(MapChildTest);
};
TEST(MemoryMap, MapChild) {
MapChildTest test;
test.Run();
}
// Some systems optimize mappings by allocating new mappings inside existing
// mappings with matching permissions. Work around this by allocating one large
// mapping and then switching up the permissions of individual pages to force
// populating more entries in the maps file.
void InitializeMappings(ScopedMmap* mappings,
size_t num_mappings,
size_t mapping_size) {
ASSERT_TRUE(mappings->ResetMmap(nullptr,
mapping_size * num_mappings,
PROT_READ,
MAP_PRIVATE | MAP_ANON,
-1,
0));
auto region = mappings->addr_as<LinuxVMAddress>();
for (size_t index = 0; index < num_mappings; index += 2) {
ASSERT_EQ(mprotect(reinterpret_cast<void*>(region + index * mapping_size),
mapping_size,
PROT_READ | PROT_WRITE),
0)
<< ErrnoMessage("mprotect");
}
}
void ExpectMappings(const MemoryMap& map,
LinuxVMAddress region_addr,
size_t num_mappings,
size_t mapping_size) {
for (size_t index = 0; index < num_mappings; ++index) {
SCOPED_TRACE(base::StringPrintf("index %zu", index));
auto mapping_address = region_addr + index * mapping_size;
const MemoryMap::Mapping* mapping = map.FindMapping(mapping_address);
ASSERT_TRUE(mapping);
EXPECT_EQ(mapping_address, mapping->range.Base());
EXPECT_EQ(mapping_address + mapping_size, mapping->range.End());
EXPECT_TRUE(mapping->readable);
EXPECT_FALSE(mapping->shareable);
EXPECT_FALSE(mapping->executable);
if (index % 2 == 0) {
EXPECT_TRUE(mapping->writable);
} else {
EXPECT_FALSE(mapping->writable);
}
}
}
TEST(MemoryMap, SelfLargeMapFile) {
constexpr size_t kNumMappings = 1024;
const size_t page_size = getpagesize();
ScopedMmap mappings;
ASSERT_NO_FATAL_FAILURE(
InitializeMappings(&mappings, kNumMappings, page_size));
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
ExpectMappings(
map, mappings.addr_as<LinuxVMAddress>(), kNumMappings, page_size);
}
class MapRunningChildTest : public Multiprocess {
public:
MapRunningChildTest() : Multiprocess(), page_size_(getpagesize()) {}
~MapRunningChildTest() {}
private:
void MultiprocessParent() override {
// Let the child get started
LinuxVMAddress region_addr;
CheckedReadFileExactly(ReadPipeHandle(), ®ion_addr, sizeof(region_addr));
for (int iter = 0; iter < 8; ++iter) {
SCOPED_TRACE(base::StringPrintf("iter %d", iter));
// Let the child get back to its work
SleepNanoseconds(1000);
DirectPtraceConnection connection;
ASSERT_TRUE(connection.Initialize(ChildPID()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
// We should at least find the original mappings. The extra mappings may
// or not be found depending on scheduling.
ExpectMappings(map, region_addr, kNumMappings, page_size_);
}
}
void MultiprocessChild() override {
ASSERT_EQ(fcntl(ReadPipeHandle(), F_SETFL, O_NONBLOCK), 0)
<< ErrnoMessage("fcntl");
ScopedMmap mappings;
ASSERT_NO_FATAL_FAILURE(
InitializeMappings(&mappings, kNumMappings, page_size_));
// Let the parent start mapping us
auto region_addr = mappings.addr_as<LinuxVMAddress>();
CheckedWriteFile(WritePipeHandle(), ®ion_addr, sizeof(region_addr));
// But don't stop there!
constexpr size_t kNumExtraMappings = 256;
ScopedMmap extra_mappings;
while (true) {
ASSERT_NO_FATAL_FAILURE(
InitializeMappings(&extra_mappings, kNumExtraMappings, page_size_));
// Quit when the parent is done
char c;
FileOperationResult res = ReadFile(ReadPipeHandle(), &c, sizeof(c));
if (res == 0) {
break;
}
ASSERT_EQ(errno, EAGAIN);
}
}
static constexpr size_t kNumMappings = 1024;
const size_t page_size_;
DISALLOW_COPY_AND_ASSIGN(MapRunningChildTest);
};
TEST(MemoryMap, MapRunningChild) {
MapRunningChildTest test;
test.Run();
}
// Expects first and third pages from mapping_start to refer to the same mapped
// file. The second page should not.
void ExpectFindFilePossibleMmapStarts(LinuxVMAddress mapping_start,
LinuxVMSize page_size) {
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
auto mapping1 = map.FindMapping(mapping_start);
ASSERT_TRUE(mapping1);
auto mapping2 = map.FindMapping(mapping_start + page_size);
ASSERT_TRUE(mapping2);
auto mapping3 = map.FindMapping(mapping_start + page_size * 2);
ASSERT_TRUE(mapping3);
ASSERT_NE(mapping1, mapping2);
ASSERT_NE(mapping2, mapping3);
auto mappings = map.FindFilePossibleMmapStarts(*mapping1);
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
mappings = map.FindFilePossibleMmapStarts(*mapping2);
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping2);
mappings = map.FindFilePossibleMmapStarts(*mapping3);
#if defined(OS_ANDROID)
EXPECT_EQ(mappings->Count(), 2u);
#else
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
#endif
}
TEST(MemoryMap, FindFilePossibleMmapStarts) {
const size_t page_size = getpagesize();
ScopedTempDir temp_dir;
base::FilePath path = temp_dir.path().Append(
FILE_PATH_LITERAL("FindFilePossibleMmapStartsTestFile"));
ScopedFileHandle handle;
size_t file_length = page_size * 3;
ASSERT_NO_FATAL_FAILURE(InitializeFile(path, file_length, &handle));
ScopedMmap file_mapping;
ASSERT_TRUE(file_mapping.ResetMmap(
nullptr, file_length, PROT_READ, MAP_PRIVATE, handle.get(), 0));
auto mapping_start = file_mapping.addr_as<LinuxVMAddress>();
// Change the permissions on the second page to split the mapping into three
// parts.
ASSERT_EQ(mprotect(file_mapping.addr_as<char*>() + page_size,
page_size,
PROT_READ | PROT_WRITE),
0);
// Basic
{
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
auto mapping1 = map.FindMapping(mapping_start);
ASSERT_TRUE(mapping1);
auto mapping2 = map.FindMapping(mapping_start + page_size);
ASSERT_TRUE(mapping2);
auto mapping3 = map.FindMapping(mapping_start + page_size * 2);
ASSERT_TRUE(mapping3);
ASSERT_NE(mapping1, mapping2);
ASSERT_NE(mapping2, mapping3);
#if defined(OS_ANDROID)
auto mappings = map.FindFilePossibleMmapStarts(*mapping1);
EXPECT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
EXPECT_EQ(mappings->Next(), nullptr);
mappings = map.FindFilePossibleMmapStarts(*mapping2);
EXPECT_EQ(mappings->Count(), 2u);
mappings = map.FindFilePossibleMmapStarts(*mapping3);
EXPECT_EQ(mappings->Count(), 3u);
#else
auto mappings = map.FindFilePossibleMmapStarts(*mapping1);
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
EXPECT_EQ(mappings->Next(), nullptr);
mappings = map.FindFilePossibleMmapStarts(*mapping2);
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
mappings = map.FindFilePossibleMmapStarts(*mapping3);
ASSERT_EQ(mappings->Count(), 1u);
EXPECT_EQ(mappings->Next(), mapping1);
#endif
#if defined(ARCH_CPU_64_BITS)
constexpr bool is_64_bit = true;
#else
constexpr bool is_64_bit = false;
#endif
MemoryMap::Mapping bad_mapping;
bad_mapping.range.SetRange(is_64_bit, 0, 1);
mappings = map.FindFilePossibleMmapStarts(bad_mapping);
EXPECT_EQ(mappings->Count(), 0u);
EXPECT_EQ(mappings->Next(), nullptr);
}
// Make the second page an anonymous mapping
file_mapping.ResetAddrLen(file_mapping.addr_as<void*>(), page_size);
ScopedMmap page2_mapping;
ASSERT_TRUE(page2_mapping.ResetMmap(file_mapping.addr_as<char*>() + page_size,
page_size,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON | MAP_FIXED,
-1,
0));
ScopedMmap page3_mapping;
ASSERT_TRUE(
page3_mapping.ResetMmap(file_mapping.addr_as<char*>() + page_size * 2,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
page_size * 2));
ExpectFindFilePossibleMmapStarts(mapping_start, page_size);
// Map the second page to another file.
ScopedFileHandle handle2;
base::FilePath path2 = temp_dir.path().Append(
FILE_PATH_LITERAL("FindFilePossibleMmapStartsTestFile2"));
ASSERT_NO_FATAL_FAILURE(InitializeFile(path2, page_size, &handle2));
page2_mapping.ResetMmap(file_mapping.addr_as<char*>() + page_size,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle2.get(),
0);
ExpectFindFilePossibleMmapStarts(mapping_start, page_size);
}
TEST(MemoryMap, FindFilePossibleMmapStarts_MultipleStarts) {
ScopedTempDir temp_dir;
base::FilePath path =
temp_dir.path().Append(FILE_PATH_LITERAL("MultipleStartsTestFile"));
const size_t page_size = getpagesize();
ScopedFileHandle handle;
ASSERT_NO_FATAL_FAILURE(InitializeFile(path, page_size * 2, &handle));
// Locate a sequence of pages to setup a test in.
char* seq_addr;
{
ScopedMmap whole_mapping;
ASSERT_TRUE(whole_mapping.ResetMmap(
nullptr, page_size * 8, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0));
seq_addr = whole_mapping.addr_as<char*>();
}
// Arrange file and anonymous mappings in the sequence.
ScopedMmap file_mapping0;
ASSERT_TRUE(file_mapping0.ResetMmap(seq_addr,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
page_size));
ScopedMmap file_mapping1;
ASSERT_TRUE(file_mapping1.ResetMmap(seq_addr + page_size,
page_size * 2,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
0));
ScopedMmap file_mapping2;
ASSERT_TRUE(file_mapping2.ResetMmap(seq_addr + page_size * 3,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
0));
// Skip a page
ScopedMmap file_mapping3;
ASSERT_TRUE(file_mapping3.ResetMmap(seq_addr + page_size * 5,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
0));
ScopedMmap anon_mapping;
ASSERT_TRUE(anon_mapping.ResetMmap(seq_addr + page_size * 6,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_ANON | MAP_FIXED,
-1,
0));
ScopedMmap file_mapping4;
ASSERT_TRUE(file_mapping4.ResetMmap(seq_addr + page_size * 7,
page_size,
PROT_READ,
MAP_PRIVATE | MAP_FIXED,
handle.get(),
0));
FakePtraceConnection connection;
ASSERT_TRUE(connection.Initialize(getpid()));
MemoryMap map;
ASSERT_TRUE(map.Initialize(&connection));
auto mapping = map.FindMapping(file_mapping0.addr_as<VMAddress>());
ASSERT_TRUE(mapping);
auto possible_starts = map.FindFilePossibleMmapStarts(*mapping);
#if defined(OS_ANDROID)
EXPECT_EQ(possible_starts->Count(), 1u);
#else
EXPECT_EQ(possible_starts->Count(), 0u);
#endif
mapping = map.FindMapping(file_mapping1.addr_as<VMAddress>());
ASSERT_TRUE(mapping);
possible_starts = map.FindFilePossibleMmapStarts(*mapping);
#if defined(OS_ANDROID)
EXPECT_EQ(possible_starts->Count(), 2u);
#else
EXPECT_EQ(possible_starts->Count(), 1u);
#endif
mapping = map.FindMapping(file_mapping2.addr_as<VMAddress>());
ASSERT_TRUE(mapping);
possible_starts = map.FindFilePossibleMmapStarts(*mapping);
#if defined(OS_ANDROID)
EXPECT_EQ(possible_starts->Count(), 3u);
#else
EXPECT_EQ(possible_starts->Count(), 2u);
#endif
mapping = map.FindMapping(file_mapping3.addr_as<VMAddress>());
ASSERT_TRUE(mapping);
possible_starts = map.FindFilePossibleMmapStarts(*mapping);
#if defined(OS_ANDROID)
EXPECT_EQ(possible_starts->Count(), 4u);
#else
EXPECT_EQ(possible_starts->Count(), 3u);
#endif
mapping = map.FindMapping(file_mapping4.addr_as<VMAddress>());
ASSERT_TRUE(mapping);
possible_starts = map.FindFilePossibleMmapStarts(*mapping);
#if defined(OS_ANDROID)
EXPECT_EQ(possible_starts->Count(), 5u);
#else
EXPECT_EQ(possible_starts->Count(), 4u);
#endif
}
} // namespace
} // namespace test
} // namespace crashpad
| [
"[email protected]"
] | |
7f64db84adb1b66f215764437ddd080dfdd8d1f0 | 69784e105ddc2aca3699b6b07dbcb1834d7c242c | /Classes/Native/Newtonsoft_Json_Newtonsoft_Json_Utilities_ThreadSa2258736631.h | 8be1fa91267c61a409213d58f8d95395d34a0b10 | [] | no_license | ryanmcgrail95/CRHC-iOS | 7e72139100b2140143deb424d21fdc69b2959ed1 | 1b00260e6c59f552d9a8b94e42fcae5e657a6c46 | refs/heads/master | 2021-06-12T11:21:33.461817 | 2017-03-04T01:08:34 | 2017-03-04T01:08:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,636 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// System.Object
struct Il2CppObject;
// System.Collections.Generic.Dictionary`2<System.Type,Newtonsoft.Json.Utilities.BidirectionalDictionary`2<System.String,System.String>>
struct Dictionary_2_t516892991;
// System.Func`2<System.Type,Newtonsoft.Json.Utilities.BidirectionalDictionary`2<System.String,System.String>>
struct Func_2_t1060887749;
#include "mscorlib_System_Object2689449295.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Newtonsoft.Json.Utilities.ThreadSafeStore`2<System.Type,Newtonsoft.Json.Utilities.BidirectionalDictionary`2<System.String,System.String>>
struct ThreadSafeStore_2_t2258736631 : public Il2CppObject
{
public:
// System.Object Newtonsoft.Json.Utilities.ThreadSafeStore`2::_lock
Il2CppObject * ____lock_0;
// System.Collections.Generic.Dictionary`2<TKey,TValue> Newtonsoft.Json.Utilities.ThreadSafeStore`2::_store
Dictionary_2_t516892991 * ____store_1;
// System.Func`2<TKey,TValue> Newtonsoft.Json.Utilities.ThreadSafeStore`2::_creator
Func_2_t1060887749 * ____creator_2;
public:
inline static int32_t get_offset_of__lock_0() { return static_cast<int32_t>(offsetof(ThreadSafeStore_2_t2258736631, ____lock_0)); }
inline Il2CppObject * get__lock_0() const { return ____lock_0; }
inline Il2CppObject ** get_address_of__lock_0() { return &____lock_0; }
inline void set__lock_0(Il2CppObject * value)
{
____lock_0 = value;
Il2CppCodeGenWriteBarrier(&____lock_0, value);
}
inline static int32_t get_offset_of__store_1() { return static_cast<int32_t>(offsetof(ThreadSafeStore_2_t2258736631, ____store_1)); }
inline Dictionary_2_t516892991 * get__store_1() const { return ____store_1; }
inline Dictionary_2_t516892991 ** get_address_of__store_1() { return &____store_1; }
inline void set__store_1(Dictionary_2_t516892991 * value)
{
____store_1 = value;
Il2CppCodeGenWriteBarrier(&____store_1, value);
}
inline static int32_t get_offset_of__creator_2() { return static_cast<int32_t>(offsetof(ThreadSafeStore_2_t2258736631, ____creator_2)); }
inline Func_2_t1060887749 * get__creator_2() const { return ____creator_2; }
inline Func_2_t1060887749 ** get_address_of__creator_2() { return &____creator_2; }
inline void set__creator_2(Func_2_t1060887749 * value)
{
____creator_2 = value;
Il2CppCodeGenWriteBarrier(&____creator_2, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"[email protected]"
] | |
8f622827fff9aaded8766a40a227940f92171f8e | 13da20e5c120466de53eb6e06ce166e6a5704d61 | /CPP_04/before/ex02/Squad.hpp | 9f397484fe0cca15b8eda51bae1459c56ed03fd2 | [] | no_license | hyungraelee/CPP_Module | dccbb0b88d6d8debe917c8caa17274668a8e1d04 | 7b8b5f6efdde6d980499e51ed62108d15b99276c | refs/heads/main | 2023-07-13T06:22:46.019891 | 2021-08-21T08:59:26 | 2021-08-21T08:59:26 | 378,877,009 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 350 | hpp | #ifndef SQUAD_HPP
# define SQUAD_HPP
# include "ISquad.hpp"
class Squad : public ISquad
{
private:
int count;
ISpaceMarine** member;
public:
Squad();
virtual ~Squad();
Squad(const Squad&);
Squad& operator=(const Squad&);
virtual int getCount() const;
virtual ISpaceMarine* getUnit(int) const;
virtual int push(ISpaceMarine*);
};
#endif
| [
"[email protected]"
] | |
1f90ed31e4bec9b158e3bd2db8ddb604631cb138 | a92b18defb50c5d1118a11bc364f17b148312028 | /src/prod/src/Common/SecurityUtility.h | 139a9350f2e44afb16b50c96f8e3fb04d08528e2 | [
"MIT"
] | permissive | KDSBest/service-fabric | 34694e150fde662286e25f048fb763c97606382e | fe61c45b15a30fb089ad891c68c893b3a976e404 | refs/heads/master | 2023-01-28T23:19:25.040275 | 2020-11-30T11:11:58 | 2020-11-30T11:11:58 | 301,365,601 | 1 | 0 | MIT | 2020-11-30T11:11:59 | 2020-10-05T10:05:53 | null | UTF-8 | C++ | false | false | 7,658 | h | // ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
#pragma once
namespace Common
{
struct SecurityUtility
{
public:
static Common::ErrorCode UpdateFolderAcl(
Common::SidSPtr const & sid,
std::wstring const & folderName,
DWORD const accessMask,
Common::TimeSpan const timeout);
static Common::ErrorCode UpdateFolderAcl(
std::vector<Common::SidSPtr> const & sids,
std::wstring const & folderName,
DWORD const accessMask,
Common::TimeSpan const timeout,
bool removeInvalidSids = false);
static Common::ErrorCode UpdateFolderAclWithStampFile(
std::wstring const & folderName,
std::vector<std::pair<Common::SidSPtr, DWORD>> const & principalPermissions,
bool removeInvalidSids,
Common::TimeSpan const timeout);
static Common::ErrorCode UpdateFileAcl(
std::vector<Common::SidSPtr> const & sids,
std::wstring const & fileName,
DWORD const accessMask,
Common::TimeSpan const timeout);
static Common::ErrorCode UpdateProcessAcl(
ProcessHandle const & processHandle,
Common::SidSPtr const & sid,
ACCESS_MASK accessMask);
static Common::ErrorCode UpdateProcessAcl(
HANDLE const & processHandle,
Common::SidSPtr const & sid,
ACCESS_MASK accessMask);
static Common::ErrorCode RemoveFolderAcl(
Common::SidSPtr const & sid,
std::wstring const & folderName,
bool const disableInheritence,
Common::TimeSpan const timeout);
static Common::ErrorCode RemoveFileAcl(
Common::SidSPtr const & sid,
std::wstring const & folderName,
bool const disableInheritence,
Common::TimeSpan const timeout);
static Common::ErrorCode RemoveInvalidFolderAcls(
std::wstring const & folderName,
Common::TimeSpan const timeout);
static Common::ErrorCode RemoveInvalidFileAcls(
std::wstring const & fileName,
Common::TimeSpan const timeout);
static Common::ErrorCode EnsurePrivilege(
std::wstring const & privilege);
static Common::ErrorCode GetCertificatePrivateKeyFile(
std::wstring const & x509FindValue,
std::wstring const & x509StoreName,
X509FindType::Enum findType,
std::wstring & privateKeyFileName);
static Common::ErrorCode GetCertificatePrivateKeyFile(
std::wstring const & x509FindValue,
std::wstring const & x509StoreName,
X509FindType::Enum findType,
vector<std::wstring> & privateKeyFileNames);
static Common::ErrorCode SetCertificateAcls(
std::wstring const & x509FindValue,
std::wstring const & x509StoreName,
X509FindType::Enum findType,
std::vector<SidSPtr> const & sids,
DWORD accessMask,
Common::TimeSpan const & timeout);
static Common::ErrorCode OverwriteFolderACL(
std::wstring const & folderName,
std::vector<std::pair<SidSPtr, DWORD>> const & principalPermissions,
bool disableInheritence,
bool ignoreInheritence,
Common::TimeSpan const & timeout);
static Common::ErrorCode OverwriteFileAcl(
vector<SidSPtr> const & sids,
wstring const & fileName,
DWORD const accessMask,
TimeSpan const timeout);
static Common::ErrorCode UpdateRegistryKeyAcl(
Common::SidSPtr const & sid,
std::wstring const & registryKeyName,
DWORD const accessMask,
Common::TimeSpan const timeout);
static Common::ErrorCode GetRegistryKeyAcl(
Common::SidSPtr const & sid,
std::wstring const & registryKeyName,
DWORD & accessMask);
static Common::ErrorCode UpdateServiceAcl(
Common::SidSPtr const & sid,
std::wstring const & serviceName,
DWORD const accessMask,
Common::TimeSpan const timeout);
static Common::ErrorCode ContainsACE(
std::wstring const & folderName,
Common::SidSPtr const & sid,
DWORD accessMask,
bool & containsAce);
static Common::ErrorCode CheckACE(
std::wstring const & folderName,
std::vector<std::pair<Common::SidSPtr, DWORD>> const & principalPermissions,
std::vector<std::pair<Common::SidSPtr, DWORD>> & nonExistentPrincipalPermissions);
static Common::ErrorCode IsCurrentUserAdmin(bool & isAdminUser);
#ifdef PLATFORM_UNIX
static int GetPwByUid(uid_t uid, passwd & pwd);
static int GetGrByGid(gid_t gid, group & grp);
static Common::ErrorCode SetCertificateAcls(
CertContextUPtr & certContextUPtr,
std::vector<std::string> const & userNames,
vector<SidSPtr> const & sids,
DWORD accessMask,
TimeSpan const & timeout);
static Common::ErrorCode InstallCoreFxCertificate(
std::wstring const & userName,
std::wstring const & x509FindValue,
std::wstring const & x509StoreName,
X509FindType::Enum findType);
static Common::ErrorCode SetCertificateAcls(
std::wstring const & x509FindValue,
std::wstring const & x509StoreName,
X509FindType::Enum findType,
std::vector<std::string> const & userNames, //List of usernames to acl certificates in there corefx directory
std::vector<SidSPtr> const & sids,
DWORD accessMask,
Common::TimeSpan const & timeout);
#endif
private:
#ifndef PLATFORM_UNIX
static Common::ErrorCode UpdateAcl(
SE_OBJECT_TYPE const objectType,
std::wstring const & resourceName,
std::vector<std::pair<SidSPtr, DWORD>> const & principalPermissions,
Common::TimeSpan const timeout,
bool callerHoldsLock = false,
std::wstring const & lockFile = L"",
bool removeInvalidSids = false,
bool overwriteAcl = false);
static Common::ErrorCode UpdateAcl(
SE_OBJECT_TYPE const objectType,
std::wstring const & resourceName,
std::vector<Dacl::ACEInfo> additionalACEs,
bool removeInvalidSids = false);
static Common::ErrorCode OverwriteAcl(
SE_OBJECT_TYPE const objectType,
wstring const & objectName,
vector<Dacl::ACEInfo> additionalACEs);
static Common::ErrorCode SetPrivateKeyFileAcls(
wstring const & privateKeyFile,
vector<SidSPtr> const & sids,
DWORD accessMask,
TimeSpan const & timeout);
#endif
static Common::ErrorCode RemoveAcl(std::wstring const & resourceName, std::vector<Common::SidSPtr> const & removeACLsOn, bool const disableInheritence);
static Common::ErrorCode RemoveInvalidAcl(std::wstring const & resourceName);
static Common::ErrorCode IsDACLProtected(std::wstring const & resourceName, bool & isProtected);
static Common::ErrorCode WriteACLStampFile(std::wstring const & fileLocation);
static std::wstring const DaclLockFileName;
static std::wstring const DaclStampFileName;
};
}
| [
"[email protected]"
] | |
b9ed770cd69a336935316653790dee71116f8d71 | 472dd83c050404e08c85b965bed0e4752c795b9a | /第五章类的组合和类的依赖/example5_03_1.cpp | 0452ff1492718fc20580b5595b1967fdfab8dc36 | [] | no_license | 974605417/homework | 9596ada8a923034cd8064c85cee0b24e6efbfdfc | d2617ad9a6e7cecb987d5dff548f9e63a2b96080 | refs/heads/master | 2020-03-30T06:08:21.865657 | 2018-11-22T14:25:05 | 2018-11-22T14:25:05 | 150,841,183 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 804 | cpp | //example5_03_1.cpp:用类的依赖实现掷骰子
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
class Dice //骰子类
{
public:
int run()
{
return (rand() % 6 + 1);
}
};
class Gambler //赌徒类
{
public:
void play(Dice a, Dice b, Dice c)
{
int num1, num2, num3;
num1 = a.run();
num2 = b.run();
num3 = c.run();
if (num1 == num2 &&num1 == num3)
cout << num1 << " " << num2 << " " << num3 << "豹子" << endl;
else if (num1 + num2 + num3 > 10)
cout << num1 << " " << num2 << " " << num3 << "大" << endl;
else
cout << num1 << " " << num2 << " " << num3 << "小" << endl;
}
};
int main()
{
Dice d1, d2, d3;
Gambler Jack;
srand(time(NULL));
Jack.play(d1, d2, d3);
system("pause");
return 0;
}
| [
"[email protected]"
] | |
0648d9ff568710492f97b04f1d1a77316592988a | ba96d7f21540bd7504e61954f01a6d77f88dea6f | /build/Android/Debug/app/src/main/jni/_root.BasicSwipeToggleBigTest.cpp | faf123abac0dadd3c74c9ad2b800fe850e8b8082 | [] | no_license | GetSomefi/haslaamispaivakirja | 096ff35fe55e3155293e0030c91b4bbeafd512c7 | 9ba6766987da4af3b662e33835231b5b88a452b3 | refs/heads/master | 2020-03-21T19:54:24.148074 | 2018-11-09T06:44:18 | 2018-11-09T06:44:18 | 138,976,977 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,654 | cpp | // This file was generated based on '/Users/petervirtanen/OneDrive/Fuse projektit/Häsläämispäiväkirja/.uno/ux15/BasicSwipeToggleBigTest.g.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#include <_root.BasicSwipeToggleBigTest.h>
#include <Uno.Bool.h>
#include <Uno.String.h>
#include <Uno.UX.PropertyObject.h>
#include <Uno.UX.Selector.h>
static uString* STRINGS[9];
namespace g{
// public partial sealed class BasicSwipeToggleBigTest :2
// {
// static BasicSwipeToggleBigTest() :91
static void BasicSwipeToggleBigTest__cctor_4_fn(uType* __type)
{
BasicSwipeToggleBigTest::__selector0_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[0/*"IsActive"*/]);
BasicSwipeToggleBigTest::__selector1_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[1/*"Color"*/]);
BasicSwipeToggleBigTest::__selector2_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[2/*"Value"*/]);
BasicSwipeToggleBigTest::__selector3_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[3/*"Sendable"*/]);
BasicSwipeToggleBigTest::__selector4_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[4/*"swipe"*/]);
BasicSwipeToggleBigTest::__selector5_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[5/*"handle"*/]);
BasicSwipeToggleBigTest::__selector6_ = ::g::Uno::UX::Selector__op_Implicit1(::STRINGS[6/*"background"*/]);
}
static void BasicSwipeToggleBigTest_build(uType* type)
{
::STRINGS[0] = uString::Const("IsActive");
::STRINGS[1] = uString::Const("Color");
::STRINGS[2] = uString::Const("Value");
::STRINGS[3] = uString::Const("Sendable");
::STRINGS[4] = uString::Const("swipe");
::STRINGS[5] = uString::Const("handle");
::STRINGS[6] = uString::Const("background");
::STRINGS[7] = uString::Const("PrimaryColor");
::STRINGS[8] = uString::Const("SecondaryColor");
type->SetInterfaces(
::g::Uno::Collections::IList_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface0),
::g::Fuse::Scripting::IScriptObject_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface1),
::g::Fuse::IProperties_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface2),
::g::Fuse::INotifyUnrooted_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface3),
::g::Fuse::ISourceLocation_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface4),
::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface5),
::g::Uno::Collections::IEnumerable_typeof()->MakeType(::g::Fuse::Binding_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface6),
::g::Uno::Collections::IList_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface7),
::g::Uno::UX::IPropertyListener_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface8),
::g::Fuse::ITemplateSource_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface9),
::g::Uno::Collections::IEnumerable_typeof()->MakeType(::g::Fuse::Visual_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface10),
::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface11),
::g::Uno::Collections::IEnumerable_typeof()->MakeType(::g::Fuse::Node_typeof(), NULL), offsetof(::g::Fuse::Controls::Panel_type, interface12),
::g::Fuse::Triggers::Actions::IShow_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface13),
::g::Fuse::Triggers::Actions::IHide_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface14),
::g::Fuse::Triggers::Actions::ICollapse_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface15),
::g::Fuse::IActualPlacement_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface16),
::g::Fuse::Animations::IResize_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface17),
::g::Fuse::Drawing::ISurfaceDrawable_typeof(), offsetof(::g::Fuse::Controls::Panel_type, interface18));
type->SetFields(115,
::g::Uno::Bool_typeof(), offsetof(BasicSwipeToggleBigTest, _field_Sendable), 0,
::g::Uno::Float4_typeof(), offsetof(BasicSwipeToggleBigTest, _field_PrimaryColor), 0,
::g::Uno::Float4_typeof(), offsetof(BasicSwipeToggleBigTest, _field_SecondaryColor), 0,
::g::Uno::Bool_typeof(), offsetof(BasicSwipeToggleBigTest, _field_IsActive), 0,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector0_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector1_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector2_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector3_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector4_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector5_, uFieldFlagsStatic,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&BasicSwipeToggleBigTest::__selector6_, uFieldFlagsStatic);
}
::g::Fuse::Controls::Panel_type* BasicSwipeToggleBigTest_typeof()
{
static uSStrong< ::g::Fuse::Controls::Panel_type*> type;
if (type != NULL) return type;
uTypeOptions options;
options.BaseDefinition = ::g::Fuse::Controls::Panel_typeof();
options.FieldCount = 126;
options.InterfaceCount = 19;
options.ObjectSize = sizeof(BasicSwipeToggleBigTest);
options.TypeSize = sizeof(::g::Fuse::Controls::Panel_type);
type = (::g::Fuse::Controls::Panel_type*)uClassType::New("BasicSwipeToggleBigTest", options);
type->fp_build_ = BasicSwipeToggleBigTest_build;
type->fp_cctor_ = BasicSwipeToggleBigTest__cctor_4_fn;
type->interface18.fp_Draw = (void(*)(uObject*, ::g::Fuse::Drawing::Surface*))::g::Fuse::Controls::Panel__FuseDrawingISurfaceDrawableDraw_fn;
type->interface18.fp_get_IsPrimary = (void(*)(uObject*, bool*))::g::Fuse::Controls::Panel__FuseDrawingISurfaceDrawableget_IsPrimary_fn;
type->interface18.fp_get_ElementSize = (void(*)(uObject*, ::g::Uno::Float2*))::g::Fuse::Controls::Panel__FuseDrawingISurfaceDrawableget_ElementSize_fn;
type->interface13.fp_Show = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsIShowShow_fn;
type->interface15.fp_Collapse = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsICollapseCollapse_fn;
type->interface14.fp_Hide = (void(*)(uObject*))::g::Fuse::Elements::Element__FuseTriggersActionsIHideHide_fn;
type->interface17.fp_SetSize = (void(*)(uObject*, ::g::Uno::Float2*))::g::Fuse::Elements::Element__FuseAnimationsIResizeSetSize_fn;
type->interface16.fp_get_ActualSize = (void(*)(uObject*, ::g::Uno::Float3*))::g::Fuse::Elements::Element__FuseIActualPlacementget_ActualSize_fn;
type->interface16.fp_add_Placed = (void(*)(uObject*, uDelegate*))::g::Fuse::Elements::Element__add_Placed_fn;
type->interface16.fp_remove_Placed = (void(*)(uObject*, uDelegate*))::g::Fuse::Elements::Element__remove_Placed_fn;
type->interface10.fp_GetEnumerator = (void(*)(uObject*, uObject**))::g::Fuse::Visual__UnoCollectionsIEnumerableFuseVisualGetEnumerator_fn;
type->interface11.fp_Clear = (void(*)(uObject*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeClear_fn;
type->interface11.fp_Contains = (void(*)(uObject*, void*, bool*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeContains_fn;
type->interface7.fp_RemoveAt = (void(*)(uObject*, int32_t*))::g::Fuse::Visual__UnoCollectionsIListFuseNodeRemoveAt_fn;
type->interface12.fp_GetEnumerator = (void(*)(uObject*, uObject**))::g::Fuse::Visual__UnoCollectionsIEnumerableFuseNodeGetEnumerator_fn;
type->interface11.fp_get_Count = (void(*)(uObject*, int32_t*))::g::Fuse::Visual__UnoCollectionsICollectionFuseNodeget_Count_fn;
type->interface7.fp_get_Item = (void(*)(uObject*, int32_t*, uTRef))::g::Fuse::Visual__UnoCollectionsIListFuseNodeget_Item_fn;
type->interface7.fp_Insert = (void(*)(uObject*, int32_t*, void*))::g::Fuse::Visual__Insert1_fn;
type->interface8.fp_OnPropertyChanged = (void(*)(uObject*, ::g::Uno::UX::PropertyObject*, ::g::Uno::UX::Selector*))::g::Fuse::Controls::Control__OnPropertyChanged2_fn;
type->interface9.fp_FindTemplate = (void(*)(uObject*, uString*, ::g::Uno::UX::Template**))::g::Fuse::Visual__FindTemplate_fn;
type->interface11.fp_Add = (void(*)(uObject*, void*))::g::Fuse::Visual__Add1_fn;
type->interface11.fp_Remove = (void(*)(uObject*, void*, bool*))::g::Fuse::Visual__Remove1_fn;
type->interface5.fp_Clear = (void(*)(uObject*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingClear_fn;
type->interface5.fp_Contains = (void(*)(uObject*, void*, bool*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingContains_fn;
type->interface0.fp_RemoveAt = (void(*)(uObject*, int32_t*))::g::Fuse::Node__UnoCollectionsIListFuseBindingRemoveAt_fn;
type->interface6.fp_GetEnumerator = (void(*)(uObject*, uObject**))::g::Fuse::Node__UnoCollectionsIEnumerableFuseBindingGetEnumerator_fn;
type->interface1.fp_SetScriptObject = (void(*)(uObject*, uObject*, ::g::Fuse::Scripting::Context*))::g::Fuse::Node__FuseScriptingIScriptObjectSetScriptObject_fn;
type->interface5.fp_get_Count = (void(*)(uObject*, int32_t*))::g::Fuse::Node__UnoCollectionsICollectionFuseBindingget_Count_fn;
type->interface0.fp_get_Item = (void(*)(uObject*, int32_t*, uTRef))::g::Fuse::Node__UnoCollectionsIListFuseBindingget_Item_fn;
type->interface1.fp_get_ScriptObject = (void(*)(uObject*, uObject**))::g::Fuse::Node__FuseScriptingIScriptObjectget_ScriptObject_fn;
type->interface1.fp_get_ScriptContext = (void(*)(uObject*, ::g::Fuse::Scripting::Context**))::g::Fuse::Node__FuseScriptingIScriptObjectget_ScriptContext_fn;
type->interface4.fp_get_SourceNearest = (void(*)(uObject*, uObject**))::g::Fuse::Node__FuseISourceLocationget_SourceNearest_fn;
type->interface3.fp_add_Unrooted = (void(*)(uObject*, uDelegate*))::g::Fuse::Node__FuseINotifyUnrootedadd_Unrooted_fn;
type->interface3.fp_remove_Unrooted = (void(*)(uObject*, uDelegate*))::g::Fuse::Node__FuseINotifyUnrootedremove_Unrooted_fn;
type->interface0.fp_Insert = (void(*)(uObject*, int32_t*, void*))::g::Fuse::Node__Insert_fn;
type->interface2.fp_get_Properties = (void(*)(uObject*, ::g::Fuse::Properties**))::g::Fuse::Node__get_Properties_fn;
type->interface4.fp_get_SourceLineNumber = (void(*)(uObject*, int32_t*))::g::Fuse::Node__get_SourceLineNumber_fn;
type->interface4.fp_get_SourceFileName = (void(*)(uObject*, uString**))::g::Fuse::Node__get_SourceFileName_fn;
type->interface5.fp_Add = (void(*)(uObject*, void*))::g::Fuse::Node__Add_fn;
type->interface5.fp_Remove = (void(*)(uObject*, void*, bool*))::g::Fuse::Node__Remove_fn;
return type;
}
// public bool get_IsActive() :68
void BasicSwipeToggleBigTest__get_IsActive_fn(BasicSwipeToggleBigTest* __this, bool* __retval)
{
*__retval = __this->IsActive();
}
// public void set_IsActive(bool value) :69
void BasicSwipeToggleBigTest__set_IsActive_fn(BasicSwipeToggleBigTest* __this, bool* value)
{
__this->IsActive(*value);
}
// public float4 get_PrimaryColor() :23
void BasicSwipeToggleBigTest__get_PrimaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* __retval)
{
*__retval = __this->PrimaryColor();
}
// public void set_PrimaryColor(float4 value) :24
void BasicSwipeToggleBigTest__set_PrimaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* value)
{
__this->PrimaryColor(*value);
}
// public float4 get_SecondaryColor() :38
void BasicSwipeToggleBigTest__get_SecondaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* __retval)
{
*__retval = __this->SecondaryColor();
}
// public void set_SecondaryColor(float4 value) :39
void BasicSwipeToggleBigTest__set_SecondaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* value)
{
__this->SecondaryColor(*value);
}
// public bool get_Sendable() :8
void BasicSwipeToggleBigTest__get_Sendable_fn(BasicSwipeToggleBigTest* __this, bool* __retval)
{
*__retval = __this->Sendable();
}
// public void set_Sendable(bool value) :9
void BasicSwipeToggleBigTest__set_Sendable_fn(BasicSwipeToggleBigTest* __this, bool* value)
{
__this->Sendable(*value);
}
// public void SetIsActive(bool value, Uno.UX.IPropertyListener origin) :71
void BasicSwipeToggleBigTest__SetIsActive_fn(BasicSwipeToggleBigTest* __this, bool* value, uObject* origin)
{
__this->SetIsActive(*value, origin);
}
// public void SetPrimaryColor(float4 value, Uno.UX.IPropertyListener origin) :26
void BasicSwipeToggleBigTest__SetPrimaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* value, uObject* origin)
{
__this->SetPrimaryColor(*value, origin);
}
// public void SetSecondaryColor(float4 value, Uno.UX.IPropertyListener origin) :41
void BasicSwipeToggleBigTest__SetSecondaryColor_fn(BasicSwipeToggleBigTest* __this, ::g::Uno::Float4* value, uObject* origin)
{
__this->SetSecondaryColor(*value, origin);
}
// public void SetSendable(bool value, Uno.UX.IPropertyListener origin) :11
void BasicSwipeToggleBigTest__SetSendable_fn(BasicSwipeToggleBigTest* __this, bool* value, uObject* origin)
{
__this->SetSendable(*value, origin);
}
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector0_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector1_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector2_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector3_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector4_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector5_;
::g::Uno::UX::Selector BasicSwipeToggleBigTest::__selector6_;
// public bool get_IsActive() [instance] :68
bool BasicSwipeToggleBigTest::IsActive()
{
return _field_IsActive;
}
// public void set_IsActive(bool value) [instance] :69
void BasicSwipeToggleBigTest::IsActive(bool value)
{
SetIsActive(value, NULL);
}
// public float4 get_PrimaryColor() [instance] :23
::g::Uno::Float4 BasicSwipeToggleBigTest::PrimaryColor()
{
return _field_PrimaryColor;
}
// public void set_PrimaryColor(float4 value) [instance] :24
void BasicSwipeToggleBigTest::PrimaryColor(::g::Uno::Float4 value)
{
SetPrimaryColor(value, NULL);
}
// public float4 get_SecondaryColor() [instance] :38
::g::Uno::Float4 BasicSwipeToggleBigTest::SecondaryColor()
{
return _field_SecondaryColor;
}
// public void set_SecondaryColor(float4 value) [instance] :39
void BasicSwipeToggleBigTest::SecondaryColor(::g::Uno::Float4 value)
{
SetSecondaryColor(value, NULL);
}
// public bool get_Sendable() [instance] :8
bool BasicSwipeToggleBigTest::Sendable()
{
return _field_Sendable;
}
// public void set_Sendable(bool value) [instance] :9
void BasicSwipeToggleBigTest::Sendable(bool value)
{
SetSendable(value, NULL);
}
// public void SetIsActive(bool value, Uno.UX.IPropertyListener origin) [instance] :71
void BasicSwipeToggleBigTest::SetIsActive(bool value, uObject* origin)
{
if (value != _field_IsActive)
{
_field_IsActive = value;
OnPropertyChanged1(::g::Uno::UX::Selector__op_Implicit1(::STRINGS[0/*"IsActive"*/]), origin);
}
}
// public void SetPrimaryColor(float4 value, Uno.UX.IPropertyListener origin) [instance] :26
void BasicSwipeToggleBigTest::SetPrimaryColor(::g::Uno::Float4 value, uObject* origin)
{
if (::g::Uno::Float4__op_Inequality(value, _field_PrimaryColor))
{
_field_PrimaryColor = value;
OnPropertyChanged1(::g::Uno::UX::Selector__op_Implicit1(::STRINGS[7/*"PrimaryColor"*/]), origin);
}
}
// public void SetSecondaryColor(float4 value, Uno.UX.IPropertyListener origin) [instance] :41
void BasicSwipeToggleBigTest::SetSecondaryColor(::g::Uno::Float4 value, uObject* origin)
{
if (::g::Uno::Float4__op_Inequality(value, _field_SecondaryColor))
{
_field_SecondaryColor = value;
OnPropertyChanged1(::g::Uno::UX::Selector__op_Implicit1(::STRINGS[8/*"SecondaryCo...*/]), origin);
}
}
// public void SetSendable(bool value, Uno.UX.IPropertyListener origin) [instance] :11
void BasicSwipeToggleBigTest::SetSendable(bool value, uObject* origin)
{
if (value != _field_Sendable)
{
_field_Sendable = value;
OnPropertyChanged1(::g::Uno::UX::Selector__op_Implicit1(::STRINGS[3/*"Sendable"*/]), origin);
}
}
// }
} // ::g
| [
"[email protected]"
] | |
de2f669ea5b1c447e2995696d935a0de8211c0d4 | 74af4094371b6661821a69c1e80008a1a10b88f0 | /src/controllers/keys_entities.h | e4f9cde9dd4f8ea60c41f03ca257006152e4416f | [] | no_license | Alian416/bcm-server | 82a93ba44196789938effcbfd7359c6cd8371189 | 289e5bc7c130617b910a272d071bfcb7efd6f407 | refs/heads/master | 2023-03-12T07:51:29.723137 | 2021-03-03T23:33:22 | 2021-03-03T23:33:22 | 344,285,434 | 0 | 0 | null | 2021-03-04T00:30:43 | 2021-03-03T22:50:59 | C++ | UTF-8 | C++ | false | false | 4,170 | h | #pragma once
#include <utils/jsonable.h>
#include <proto/dao/pre_key.pb.h>
namespace bcm {
struct PreKeyCount {
uint32_t count;
};
inline void to_json(nlohmann::json& j, const PreKeyCount& keyCount) {
j = nlohmann::json{{"count", keyCount.count}};
}
inline void from_json(const nlohmann::json& j, PreKeyCount& keyCount) {
jsonable::toNumber(j, "count", keyCount.count);
}
//message PreKey {
// uint64 keyId = 1;
// string publicKey = 2;
//}
inline void to_json(nlohmann::json& j, const PreKey& preKey) {
j = nlohmann::json{{"keyId", preKey.keyid()},
{"publicKey", preKey.publickey()}};
}
inline void from_json(const nlohmann::json& j, PreKey& preKey) {
uint64_t keyId{0};
std::string publicKey;
jsonable::toNumber(j, "keyId", keyId);
jsonable::toString(j, "publicKey", publicKey);
preKey.set_keyid(keyId);
preKey.set_publickey(publicKey);
}
//message SignedPreKey {
// uint64 keyId = 1;
// string publicKey = 2;
// string signature = 3;
//}
inline bool operator!=(const SignedPreKey& l, const SignedPreKey& r)
{
return (l.keyid() != r.keyid()) || (l.publickey() != r.publickey()) || (l.signature() != r.signature());
}
inline void to_json(nlohmann::json& j, const SignedPreKey& signedPreKey) {
j = nlohmann::json{{"keyId", signedPreKey.keyid()},
{"publicKey", signedPreKey.publickey()},
{"signature", signedPreKey.signature()}};
}
inline void from_json(const nlohmann::json& j, SignedPreKey& signedPreKey) {
uint64_t keyId{0};
std::string publicKey;
std::string signature;
jsonable::toNumber(j, "keyId", keyId);
jsonable::toString(j, "publicKey", publicKey);
jsonable::toString(j, "signature", signature);
signedPreKey.set_keyid(keyId);
signedPreKey.set_publickey(publicKey);
signedPreKey.set_signature(signature);
}
struct PreKeyState {
std::vector<PreKey> preKeys;
SignedPreKey signedPreKey;
std::string identityKey; // deprecated
};
inline void to_json(nlohmann::json& j, const PreKeyState& keyState) {
j = nlohmann::json{{"preKeys", keyState.preKeys},
{"signedPreKey", keyState.signedPreKey},
{"identityKey",keyState.identityKey}};
}
inline void from_json(const nlohmann::json& j, PreKeyState& keyState) {
jsonable::toGeneric(j, "preKeys", keyState.preKeys);
jsonable::toGeneric(j, "signedPreKey", keyState.signedPreKey);
jsonable::toString(j, "identityKey", keyState.identityKey);
}
struct PreKeyResponseItem {
int deviceId;
int registrationId;
std::string deviceIdentityKey;
std::string accountSignature;
boost::optional<SignedPreKey> signedPreKey;
boost::optional<PreKey> preKey;
};
inline void to_json(nlohmann::json& j, const PreKeyResponseItem& item) {
j = nlohmann::json{{"deviceId", item.deviceId},
{"registrationId", item.registrationId},
{"deviceIdentityKey", item.deviceIdentityKey},
{"accountSignature", item.accountSignature},
{"signedPreKey", item.signedPreKey},
{"preKey", item.preKey}};
}
inline void from_json(const nlohmann::json& j, PreKeyResponseItem& item) {
jsonable::toNumber(j, "deviceId", item.deviceId);
jsonable::toNumber(j, "registrationId", item.registrationId);
jsonable::toString(j, "deviceIdentityKey", item.deviceIdentityKey);
jsonable::toString(j, "accountSignature", item.accountSignature);
jsonable::toGeneric(j, "signedPreKey", item.signedPreKey);
jsonable::toGeneric(j, "preKey", item.preKey);
}
struct PreKeyResponse {
std::string identityKey;
std::vector<PreKeyResponseItem> devices;
};
inline void to_json(nlohmann::json& j, const PreKeyResponse& response) {
j = nlohmann::json{{"identityKey", response.identityKey},
{"devices", response.devices}};
}
inline void from_json(const nlohmann::json& j, PreKeyResponse& response) {
jsonable::toString(j, "identityKey", response.identityKey);
jsonable::toGeneric(j, "devices", response.devices);
}
}
| [
"[email protected]"
] | |
2c91335adc879bcf0036fb4284489e215aec0dfa | 6dd771a1f1b806643e3bd93b3767731a425e8da8 | /PopulationBattle.cpp | d4855e0fd90a44c67f98ef7fab4400aadddf4a8c | [] | no_license | molip/Eclipsoid | 138862038feb45df2829f185171cf1263e02e119 | 70a9a12452bfbe9f8cf27c5dec4f3833ffe58b70 | refs/heads/master | 2021-01-16T23:24:42.058399 | 2019-10-21T08:12:17 | 2019-10-21T08:12:17 | 7,979,506 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,754 | cpp | #include "stdafx.h"
#include "PopulationBattle.h"
#include "App.h"
#include "Hex.h"
#include "Blueprint.h"
#include "LiveGame.h"
#include "Test.h"
#include "AttackPopulationRecord.h"
void PopulationBattle::Hits::Save(Serial::SaveNode& node) const
{
node.SaveCntr("hits", *this, Serial::TypeSaver());
node.SaveType("auto_hit", autoHit);
}
void PopulationBattle::Hits::Load(const Serial::LoadNode& node)
{
node.LoadCntr("hits", *this, Serial::TypeLoader());
node.LoadType("auto_hit", autoHit);
}
//-------------------------------------------------------------------
PopulationBattle::PopulationBattle()
{
}
PopulationBattle::PopulationBattle(const Hex& hex, const Game& game, const GroupVec& oldGroups) : Battle(hex, game, oldGroups)
{
m_turn.phase = BattlePhase::Population;
}
bool PopulationBattle::operator==(const Battle& rhs) const
{
return dynamic_cast<const PopulationBattle*>(&rhs) && __super::operator==(rhs);
}
BattlePtr PopulationBattle::Clone() const
{
return BattlePtr(new PopulationBattle(*this));
}
void PopulationBattle::DoAdvanceTurn(const Game& game)
{
VERIFY(m_turn.phase == BattlePhase::Population);
const Hex* hex = game.GetMap().FindHex(m_hexId);
if (hex->CanAttackPopulation())
{
while (++m_turn.groupIndex < (int)m_groups.size() && GetCurrentGroup().IsDead()); // TODO: Check cannons.
if (m_turn.groupIndex == m_groups.size())
m_turn.groupIndex = -1; // All groups had a go - finished.
}
else
m_turn.groupIndex = -1; // All population dead - finished.
}
PopulationBattle::Hits PopulationBattle::AutoAssignPopulationHits(const Dice& dice, const Game& game) const
{
PopulationBattle::Hits hits;
const Blueprint& firing = GetBlueprint(game, GetCurrentGroup());
int toHit = Dice::GetToHitRoll(firing.GetComputer(), 0);
int damage = dice.GetDamage(toHit);
auto& squares = game.GetMap().FindHex(m_hexId)->GetSquares();
for (int i = 0; i < (int)squares.size() && damage > 0; ++i)
if (squares[i].IsOccupied())
{
hits.push_back(i);
--damage;
}
return hits;
}
bool PopulationBattle::CanAutoDestroyPopulation(const Game& game) const
{
const Hex* hex = game.GetMap().FindHex(m_hexId);
return hex->CanAttackPopulation() && game.GetTeam(hex->GetFleets().front().GetColour()).HasTech(TechType::NeutronBomb);
}
RecordPtr PopulationBattle::CreateAttackRecord(const Game& game, const Dice& dice) const
{
const Hits hits = game.GetPopulationBattle().AutoAssignPopulationHits(dice, game);
return RecordPtr(new AttackPopulationRecord(hits));
}
RecordPtr PopulationBattle::CreateAutoAttackRecord(const Game& game) const
{
if (CanAutoDestroyPopulation(game))
return RecordPtr(new AttackPopulationRecord(PopulationBattle::Hits(true)));
return nullptr;
}
REGISTER_DYNAMIC(PopulationBattle)
| [
"[email protected]"
] | |
aecbcbe4f8a8e1e51baacd50203ed84577a44bd9 | a314c44ef5a8a4c94720501a212d509eadd98264 | /src/Magnum/SceneGraph/Camera.h | 71c599fc1c63fbc3e0a7bcac01e3198e3525ee39 | [
"MIT"
] | permissive | rockgong/magnum | 5c4ac7e189d02d9e0b9e1d0bc9367e2c82cc9fae | b937f3901e8dcb3f108769166fcf9d3be5a43fbc | refs/heads/master | 2020-05-16T09:44:54.922838 | 2019-04-22T12:29:24 | 2019-04-22T12:48:24 | 182,959,433 | 1 | 0 | NOASSERTION | 2019-04-23T07:30:40 | 2019-04-23T07:30:40 | null | UTF-8 | C++ | false | false | 10,520 | h | #ifndef Magnum_SceneGraph_Camera_h
#define Magnum_SceneGraph_Camera_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::SceneGraph::Camera, enum @ref Magnum::SceneGraph::AspectRatioPolicy, alias @ref Magnum::SceneGraph::BasicCamera2D, @ref Magnum::SceneGraph::BasicCamera3D, typedef @ref Magnum::SceneGraph::Camera2D, @ref Magnum::SceneGraph::Camera3D
*/
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h"
#include "Magnum/SceneGraph/AbstractFeature.h"
#include "Magnum/SceneGraph/visibility.h"
#ifdef CORRADE_TARGET_WINDOWS /* I so HATE windef.h */
#undef near
#undef far
#endif
namespace Magnum { namespace SceneGraph {
/**
@brief Camera aspect ratio policy
@see @ref Camera::setAspectRatioPolicy()
*/
enum class AspectRatioPolicy: UnsignedByte {
NotPreserved, /**< Don't preserve aspect ratio (default) */
Extend, /**< Extend on larger side of view */
Clip /**< Clip on smaller side of view */
};
namespace Implementation {
template<UnsignedInt dimensions, class T> MatrixTypeFor<dimensions, T> aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport);
}
/**
@brief Camera
See @ref Drawable documentation for more information. The camera by default
displays OpenGL unit cube `[(-1, -1, -1); (1, 1, 1)]` and doesn't do any aspect
ratio correction.
Common setup example for 2D scenes:
@snippet MagnumSceneGraph.cpp Camera-2D
Common setup example for 3D scenes:
@snippet MagnumSceneGraph.cpp Camera-3D
@section SceneGraph-Camera-explicit-specializations Explicit template specializations
The following specializations are explicitly compiled into @ref SceneGraph
library. For other specializations (e.g. using @ref Magnum::Double "Double"
type) you have to use @ref Camera.hpp implementation file to avoid linker
errors. See also @ref compilation-speedup-hpp for more information.
- @ref Camera2D
- @ref Camera3D
@see @ref scenegraph, @ref BasicCamera2D, @ref BasicCamera3D, @ref Camera2D,
@ref Camera3D, @ref Drawable, @ref DrawableGroup
*/
template<UnsignedInt dimensions, class T> class Camera: public AbstractFeature<dimensions, T> {
public:
/**
* @brief Constructor
* @param object Object holding the camera
*
* Sets orthographic projection to the default OpenGL cube (range
* @f$ [-1; 1] @f$ in all directions).
* @see @ref setProjectionMatrix()
*/
explicit Camera(AbstractObject<dimensions, T>& object);
#ifndef DOXYGEN_GENERATING_OUTPUT
/* This is here to avoid ambiguity with deleted copy constructor when
passing `*this` from class subclassing both Camera and AbstractObject */
template<class U, class = typename std::enable_if<std::is_base_of<AbstractObject<dimensions, T>, U>::value>::type> explicit Camera(U& object): Camera<dimensions, T>{static_cast<AbstractObject<dimensions, T>&>(object)} {}
#endif
~Camera();
/** @brief Aspect ratio policy */
AspectRatioPolicy aspectRatioPolicy() const { return _aspectRatioPolicy; }
/**
* @brief Set aspect ratio policy
* @return Reference to self (for method chaining)
*
* @attention Aspect ratio correction might not work properly with some
* specific cases of projection matrices. Projection matrices
* generated with @ref Matrix3::projection(),
* @ref Matrix4::orthographicProjection() or
* @ref Matrix4::perspectiveProjection() are known to be working.
*/
Camera<dimensions, T>& setAspectRatioPolicy(AspectRatioPolicy policy);
/**
* @brief Camera matrix
*
* Camera matrix describes world position relative to the camera and is
* applied after object transformation matrix and before projection
* matrix.
*/
MatrixTypeFor<dimensions, T> cameraMatrix() {
AbstractFeature<dimensions, T>::object().setClean();
return _cameraMatrix;
}
/**
* @brief Projection matrix
*
* Projection matrix handles e.g. perspective distortion and is applied
* as last, after @ref cameraMatrix() and object transformation matrix.
* @see @ref projectionSize()
*/
MatrixTypeFor<dimensions, T> projectionMatrix() const { return _projectionMatrix; }
/**
* @brief Set projection matrix
* @return Reference to self (for method chaining)
*
* @see @ref Matrix3::projection(), @ref Matrix4::orthographicProjection(),
* @ref Matrix4::perspectiveProjection()
*/
Camera<dimensions, T>& setProjectionMatrix(const MatrixTypeFor<dimensions, T>& matrix);
/**
* @brief Size of (near) XY plane in current projection
*
* Returns size of near XY plane computed from projection matrix.
*
* Conversion from integer window-space coordinates with origin in top
* left corner and Y down (e.g. from
* @ref Platform::Sdl2Application::MouseEvent "Platform::*Application::MouseEvent")
* to floating-point coordinates on near XY plane with origin at camera
* position and Y up can be done using the following snippet:
*
* @snippet MagnumSceneGraph-gl.cpp Camera-projectionSize
*
* This is position relative to camera transformation, getting absolute
* transformation in 2D scene can be done for example using
* @ref SceneGraph::Object::absoluteTransformation():
*
* @snippet MagnumSceneGraph-gl.cpp Camera-projectionSize-absolute
*
* @see @ref projectionMatrix()
*/
Math::Vector2<T> projectionSize() const {
return {T(2.0)/_projectionMatrix[0].x(), T(2.0)/_projectionMatrix[1].y()};
}
/** @brief Viewport size */
Vector2i viewport() const { return _viewport; }
/**
* @brief Set viewport size
*
* Stores viewport size internally and recalculates projection matrix
* according to aspect ratio policy.
* @see @ref setAspectRatioPolicy()
*/
void setViewport(const Vector2i& size);
/**
* @brief Drawable transformations
*
* Returns calculated transformations for given group of drawables.
* Useful in combination with @ref draw(const std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>>&)
* to provide custom draw order. See @ref SceneGraph-Drawable-draw-order
* for more information.
*/
std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>> drawableTransformations(DrawableGroup<dimensions, T>& group);
/**
* @brief Draw
*
* Draws given group of drawables.
* @see @ref draw(const std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>>&)
*/
void draw(DrawableGroup<dimensions, T>& group);
/**
* @brief Draw given drawables with transformations
*
* Useful in combination with @ref drawableTransformations() for
* drawing in a custom order. See @ref SceneGraph-Drawable-draw-order
* for more information.
*/
void draw(const std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>>& drawableTransformations);
private:
/** Recalculates camera matrix */
void cleanInverted(const MatrixTypeFor<dimensions, T>& invertedAbsoluteTransformationMatrix) override {
_cameraMatrix = invertedAbsoluteTransformationMatrix;
}
void fixAspectRatio();
MatrixTypeFor<dimensions, T> _rawProjectionMatrix;
AspectRatioPolicy _aspectRatioPolicy;
MatrixTypeFor<dimensions, T> _projectionMatrix;
MatrixTypeFor<dimensions, T> _cameraMatrix;
Vector2i _viewport;
};
/**
@brief Camera for two-dimensional scenes
Convenience alternative to @cpp Camera<2, T> @ce. See @ref Camera for more
information.
@see @ref Camera2D, @ref BasicCamera3D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class T> using BasicCamera2D = Camera<2, T>;
#endif
/**
@brief Camera for two-dimensional float scenes
@see @ref Camera3D
*/
typedef BasicCamera2D<Float> Camera2D;
/**
@brief Camera for three-dimensional scenes
Convenience alternative to @cpp Camera<3, T> @ce. See @ref Camera for more
information.
@see @ref Camera3D, @ref BasicCamera2D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class T> using BasicCamera3D = Camera<3, T>;
#endif
/**
@brief Camera for three-dimensional float scenes
@see @ref Camera2D
*/
typedef BasicCamera3D<Float> Camera3D;
#if defined(CORRADE_TARGET_WINDOWS) && !defined(__MINGW32__)
extern template class MAGNUM_SCENEGRAPH_EXPORT Camera<2, Float>;
extern template class MAGNUM_SCENEGRAPH_EXPORT Camera<3, Float>;
#endif
}}
#endif
| [
"[email protected]"
] | |
6f03e041cfa96b8f63223bcf5ed725b3a83e5152 | 267cced59d531328ccc5fcabdb8139b78478872d | /examples/cpp_classification/classification.cpp | db15eae7db6807634d5041ef6de8df2f3c105ee5 | [
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause"
] | permissive | 309ily/Caffe | d382b1f9c0f866b593ff3b90011ed87a34e125c6 | fdff0acaa9a6a9bded3c31c022bf9edf02a3dcfc | refs/heads/master | 2020-07-22T17:15:36.664616 | 2020-01-02T15:23:17 | 2020-01-02T15:23:17 | 207,271,937 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,758 | cpp | #include <caffe/caffe.hpp>
#ifdef USE_OPENCV
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif // USE_OPENCV
#include <algorithm>
#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#ifdef USE_OPENCV
using namespace caffe; // NOLINT(build/namespaces)
using std::string;
/* Pair (label, confidence) representing a prediction. */
typedef std::pair<string, float> Prediction;
class Classifier {
public:
Classifier(const string& model_file,
const string& trained_file,
const string& mean_file,
const string& label_file);
std::vector<Prediction> Classify(const cv::Mat& img, int N = 5);
private:
void SetMean(const string& mean_file);
std::vector<float> Predict(const cv::Mat& img);
void WrapInputLayer(std::vector<cv::Mat>* input_channels);
void Preprocess(const cv::Mat& img,
std::vector<cv::Mat>* input_channels);
private:
shared_ptr<Net<float> > net_;
cv::Size input_geometry_;
int num_channels_;
cv::Mat mean_;
std::vector<string> labels_;
};
Classifier::Classifier(const string& model_file,
const string& trained_file,
const string& mean_file,
const string& label_file) {
#ifdef CPU_ONLY
Caffe::set_mode(Caffe::CPU);
#else
Caffe::set_mode(Caffe::GPU);
#endif
/* Load the network. */
net_.reset(new Net<float>(model_file, TEST));
net_->CopyTrainedLayersFrom(trained_file);
CHECK_EQ(net_->num_inputs(), 1) << "Network should have exactly one input.";
CHECK_EQ(net_->num_outputs(), 1) << "Network should have exactly one output.";
Blob<float>* input_layer = net_->input_blobs()[0];
num_channels_ = input_layer->channels();
CHECK(num_channels_ == 3 || num_channels_ == 1)
<< "Input layer should have 1 or 3 channels.";
input_geometry_ = cv::Size(input_layer->width(), input_layer->height());
/* Load the binaryproto mean file. */
//SetMean(mean_file);
/* Load labels. */
std::ifstream labels(label_file.c_str());
CHECK(labels) << "Unable to open labels file " << label_file;
string line;
while (std::getline(labels, line))
labels_.push_back(string(line));
Blob<float>* output_layer = net_->output_blobs()[0];
CHECK_EQ(labels_.size(), output_layer->channels())
<< "Number of labels is different from the output layer dimension.";
}
static bool PairCompare(const std::pair<float, int>& lhs,
const std::pair<float, int>& rhs) {
return lhs.first > rhs.first;
}
/* Return the indices of the top N values of vector v. */
static std::vector<int> Argmax(const std::vector<float>& v, int N) {
std::vector<std::pair<float, int> > pairs;
for (size_t i = 0; i < v.size(); ++i)
pairs.push_back(std::make_pair(v[i], static_cast<int>(i)));
std::partial_sort(pairs.begin(), pairs.begin() + N, pairs.end(), PairCompare);
std::vector<int> result;
for (int i = 0; i < N; ++i)
result.push_back(pairs[i].second);
return result;
}
/* Return the top N predictions. */
std::vector<Prediction> Classifier::Classify(const cv::Mat& img, int N) {
std::vector<float> output = Predict(img);
N = std::min<int>(labels_.size(), N);
std::vector<int> maxN = Argmax(output, N);
std::vector<Prediction> predictions;
for (int i = 0; i < N; ++i) {
int idx = maxN[i];
predictions.push_back(std::make_pair(labels_[idx], output[idx]));
}
return predictions;
}
/* Load the mean file in binaryproto format. */
void Classifier::SetMean(const string& mean_file) {
BlobProto blob_proto;
ReadProtoFromBinaryFileOrDie(mean_file.c_str(), &blob_proto);
/* Convert from BlobProto to Blob<float> */
Blob<float> mean_blob;
mean_blob.FromProto(blob_proto);
CHECK_EQ(mean_blob.channels(), num_channels_)
<< "Number of channels of mean file doesn't match input layer.";
/* The format of the mean file is planar 32-bit float BGR or grayscale. */
std::vector<cv::Mat> channels;
float* data = mean_blob.mutable_cpu_data();
for (int i = 0; i < num_channels_; ++i) {
/* Extract an individual channel. */
cv::Mat channel(mean_blob.height(), mean_blob.width(), CV_32FC1, data);
channels.push_back(channel);
data += mean_blob.height() * mean_blob.width();
}
/* Merge the separate channels into a single image. */
cv::Mat mean;
cv::merge(channels, mean);
/* Compute the global mean pixel value and create a mean image
* filled with this value. */
cv::Scalar channel_mean = cv::mean(mean);
mean_ = cv::Mat(input_geometry_, mean.type(), channel_mean);
}
std::vector<float> Classifier::Predict(const cv::Mat& img) {
Blob<float>* input_layer = net_->input_blobs()[0];
input_layer->Reshape(1, num_channels_,
input_geometry_.height, input_geometry_.width);
/* Forward dimension change to all layers. */
net_->Reshape();
std::vector<cv::Mat> input_channels;
WrapInputLayer(&input_channels);
Preprocess(img, &input_channels);
net_->Forward();
/* Copy the output layer to a std::vector */
Blob<float>* output_layer = net_->output_blobs()[0];
const float* begin = output_layer->cpu_data();
const float* end = begin + output_layer->channels();
return std::vector<float>(begin, end);
}
/* Wrap the input layer of the network in separate cv::Mat objects
* (one per channel). This way we save one memcpy operation and we
* don't need to rely on cudaMemcpy2D. The last preprocessing
* operation will write the separate channels directly to the input
* layer. */
void Classifier::WrapInputLayer(std::vector<cv::Mat>* input_channels) {
Blob<float>* input_layer = net_->input_blobs()[0];
int width = input_layer->width();
int height = input_layer->height();
float* input_data = input_layer->mutable_cpu_data();
for (int i = 0; i < input_layer->channels(); ++i) {
cv::Mat channel(height, width, CV_32FC1, input_data);
input_channels->push_back(channel);
input_data += width * height;
}
}
void Classifier::Preprocess(const cv::Mat& img,
std::vector<cv::Mat>* input_channels) {
/* Convert the input image to the input image format of the network. */
cv::Mat sample;
if (img.channels() == 3 && num_channels_ == 1)
cv::cvtColor(img, sample, cv::COLOR_BGR2GRAY);
else if (img.channels() == 4 && num_channels_ == 1)
cv::cvtColor(img, sample, cv::COLOR_BGRA2GRAY);
else if (img.channels() == 4 && num_channels_ == 3)
cv::cvtColor(img, sample, cv::COLOR_BGRA2BGR);
else if (img.channels() == 1 && num_channels_ == 3)
cv::cvtColor(img, sample, cv::COLOR_GRAY2BGR);
else
sample = img;
cv::Mat sample_resized;
if (sample.size() != input_geometry_)
cv::resize(sample, sample_resized, input_geometry_);
else
sample_resized = sample;
cv::Mat sample_float;
if (num_channels_ == 3)
sample_resized.convertTo(sample_float, CV_32FC3);
else
sample_resized.convertTo(sample_float, CV_32FC1);
cv::Mat sample_normalized;
//cv::subtract(sample_float, mean_, sample_normalized);
cv::divide(sample_float, 256.0, sample_normalized);
/* This operation will write the separate BGR planes directly to the
* input layer of the network because it is wrapped by the cv::Mat
* objects in input_channels. */
cv::split(sample_normalized, *input_channels);
CHECK(reinterpret_cast<float*>(input_channels->at(0).data)
== net_->input_blobs()[0]->cpu_data())
<< "Input channels are not wrapping the input layer of the network.";
}
int main(int argc, char** argv) {
if (argc != 6) {
std::cerr << "Usage: " << argv[0]
<< " deploy.prototxt network.caffemodel"
<< " mean.binaryproto labels.txt img.jpg" << std::endl;
return 1;
}
//system("pause");
::google::InitGoogleLogging(argv[0]);
string model_file = argv[1];
string trained_file = argv[2];
string mean_file = argv[3];
string label_file = argv[4];
Classifier classifier(model_file, trained_file, mean_file, label_file);
string file = argv[5];
std::cout << "---------- Prediction for "
<< file << " ----------" << std::endl;
cv::Mat img = cv::imread(file, -1);
CHECK(!img.empty()) << "Unable to decode image " << file;
std::vector<Prediction> predictions = classifier.Classify(img);
/* Print the top N predictions. */
for (size_t i = 0; i < predictions.size(); ++i) {
Prediction p = predictions[i];
std::cout << std::fixed << std::setprecision(4) << p.second << " - \""
<< p.first << "\"" << std::endl;
}
}
#else
int main(int argc, char** argv) {
LOG(FATAL) << "This example requires OpenCV; compile with USE_OPENCV.";
}
#endif // USE_OPENCV
| [
"[email protected]"
] | |
fb4a5b30b160db747acf765ac851d1804d3a20f3 | 81b7033dd0d0203290795b51513a4014b084d39d | /hash/sizehash.h | 88417d468b68adf0af15348e4dbeafda79770b27 | [] | no_license | starcid/lua-binding-libraries | d27f5c2fccfeae2d667fdb60c86c3244d9ddc065 | e33c85f773d88d3b31b026464066264820e4c302 | refs/heads/master | 2016-08-04T19:57:05.839477 | 2010-11-15T12:02:08 | 2010-11-15T12:02:08 | 35,589,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | h | #ifndef HASH_SIZE_H_
#define HASH_SIZE_H_
class CSizeHash
{
unsigned long m_context;
public:
enum { nDigestLength = 4};
int Init()
{
m_context = 0;
return 0;
}
int Update(unsigned char * /*pData*/, unsigned long ulLen)
{
m_context += ulLen;
return 0;
}
int Final(unsigned char * pszOut)
{
pszOut[0] = (unsigned char)((m_context & 0xFF000000 )>> 24);
pszOut[1] = (unsigned char)((m_context & 0xFF0000 )>> 16);
pszOut[2] = (unsigned char)((m_context & 0xFF00 )>> 8);
pszOut[3] = (unsigned char)((m_context & 0xFF ));
return 0;
}
};
#endif | [
"missdeer@959521e0-e54e-11de-9298-fbd6a473cdd1"
] | missdeer@959521e0-e54e-11de-9298-fbd6a473cdd1 |
b424ef2385a01f5483c7ff486397bb7ba35f6216 | 014ca6018b254f00776f538834623ebc10b8ca23 | /appsrc/dcfile/dcbriggs.cc | ba7aa6a9495d9c4f226809a9ad6be4f1c679b3f2 | [] | no_license | IMAGE-ET/dicom3tools | 5aacebf2bc661b5afab83a0ac53b08cf5319bc87 | a8c0a8e6b4a3767ba1a4edfb6471fd584406dcde | refs/heads/master | 2020-03-11T18:44:08.741659 | 2017-02-18T21:49:02 | 2017-02-18T21:49:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,977 | cc | static const char *CopyrightIdentifier(void) { return "@(#)dcbriggs.cc Copyright (c) 1993-2015, David A. Clunie DBA PixelMed Publishing. All rights reserved."; }
#include "attrtype.h"
#include "attrothr.h"
#include "attrmxls.h"
#include "transynu.h"
#include "elmconst.h"
#include "mesgtext.h"
//#include "ioopt.h"
#include "dcopt.h"
#include "briggsrc.h"
int
main(int argc,char **argv)
{
bool bad=false;
GetNamedOptions options(argc,argv);
DicomOutputOptions dicom_output_options(options);
bool verbose=options.get("verbose") || options.get("v");
unsigned rows=512;
(void)(options.get("rows",rows) || options.get("x",rows));
unsigned cols=512;
(void)(options.get("cols",cols) || options.get("columns",cols) || options.get("y",cols));
unsigned bits=8;
(void)(options.get("bits",bits) || options.get("depth",bits) || options.get("d",bits));
if (bits < 1 || bits > 16) {
cerr << EMsgDC(OptionUnsupported) << " - bits = " << dec << bits << endl;
bad=true;
}
int minval=0;
(void)options.get("minval",minval);
int maxval=(int)(((long)(0x0001l)<<bits)-1);
(void)options.get("maxval",maxval);
bool wantsigned=options.get("signed");
bool wantinverted=options.get("invert") || options.get("inverted") || options.get("monochrome1");
unsigned contrast=7;
(void)options.get("contrast",contrast);
Assert(maxval-minval >= contrast);
unsigned surround=70;
(void)options.get("surround",surround);
Assert(surround <= 100);
unsigned background=30;
(void)options.get("background",background);
Assert(background <= 100);
dicom_output_options.done();
options.done();
DicomOutputOpenerFromOptions output_opener(
options,dicom_output_options.filename,cout);
cerr << dicom_output_options.errors();
cerr << options.errors();
cerr << output_opener.errors();
if (!dicom_output_options.good()
|| !options.good()
|| !output_opener.good()
|| !options
|| bad) {
cerr << MMsgDC(Usage) << ": " << options.command()
<< dicom_output_options.usage()
<< " [-rows|-y rows]"
<< " [-cols|-columns|-x columns]"
<< " [-bits|-depth|-d bits]"
<< " [-minval i]"
<< " [-mavxal i]"
<< " [-signed]"
<< " [-inverted|-invert|-monochrome1]"
<< " [-contrast value]"
<< " [-surround percent]"
<< " [-background percent]"
<< " [-v|-verbose]"
<< " [" << MMsgDC(OutputFile) << "]"
<< " >" << MMsgDC(OutputFile)
<< endl;
exit(1);
}
DicomOutputStream dout(*(ostream *)output_opener,
dicom_output_options.transfersyntaxuid,
dicom_output_options.usemetaheader,
dicom_output_options.useimplicitmetaheader,
dicom_output_options.addtiff);
ManagedAttributeList list;
TransferSyntax transfersyntax(
dicom_output_options.transfersyntaxuid
? dicom_output_options.transfersyntaxuid
: DefaultTransferSyntaxUID);
TextOutputStream log(cerr);
Uint16 bitsAllocated=((bits-1)/8+1)*8;
Uint16 bitsStored=bits;
Uint16 highBit=bits-1;
list+=new UnsignedShortAttribute(TagFromName(BitsAllocated),bitsAllocated);
list+=new UnsignedShortAttribute(TagFromName(BitsStored),bitsStored);
list+=new UnsignedShortAttribute(TagFromName(HighBit),highBit);
list+=new UnsignedShortAttribute(TagFromName(Rows),rows);
list+=new UnsignedShortAttribute(TagFromName(Columns),cols);
list+=new UnsignedShortAttribute(TagFromName(SamplesPerPixel),1u);
list+=new UnsignedShortAttribute(TagFromName(PixelRepresentation),wantsigned?1u:0u);
list+=new CodeStringAttribute(TagFromName(PhotometricInterpretation),wantinverted ? "MONOCHROME1":"MONOCHROME2");
// various Type 1 and Type 2 attributes for mandatory SC modules ...
list+=new PersonNameAttribute(TagFromName(PatientName),"^^^^");
list+=new LongStringAttribute(TagFromName(PatientID));
list+=new DateStringAttribute(TagFromName(PatientBirthDate));
list+=new CodeStringAttribute(TagFromName(PatientSex));
list+=new ShortStringAttribute(TagFromName(StudyID));
list+=new DateStringAttribute(TagFromName(StudyDate));
list+=new TimeStringAttribute(TagFromName(StudyTime));
list+=new PersonNameAttribute(TagFromName(ReferringPhysicianName),"^^^^");
list+=new ShortStringAttribute(TagFromName(AccessionNumber));
list+=new IntegerStringAttribute(TagFromName(SeriesNumber));
list+=new IntegerStringAttribute(TagFromName(InstanceNumber));
list+=new CodeStringAttribute(TagFromName(Modality),"OT");
list+=new CodeStringAttribute(TagFromName(ConversionType),"WSD");
list+=new LongStringAttribute(TagFromName(Manufacturer));
list+=new CodeStringAttribute(TagFromName(PatientOrientation));
Briggs_PixelDataSource *pixeldatasrc=new Briggs_PixelDataSource(rows,cols,wantsigned,wantinverted,(Uint16)minval,(Uint16)maxval,
contrast,surround,background);
Assert(pixeldatasrc);
list+=new OtherUnspecifiedLargeAttribute(
TagFromName(PixelData),
pixeldatasrc,
rows,
cols,
1,
1,
&transfersyntax,
0,bitsAllocated,bitsStored,highBit);
if (!usualManagedAttributeListWrite(list,dout,
dicom_output_options,log,verbose)) return 1;
return 0;
}
| [
"[email protected]"
] | |
95300b9379667d5a86d18ad58b90909166bd1085 | 44215f54f56b1cdf5b58d4dcd0b6a89ef329dc38 | /src/ezSockets.cpp | 622e2137cd55713c988b5deb2d630c14efb85691 | [] | no_license | Hazzytje/Kyubu | 6c401e58ceb777d7473d1664d356b1b3b71d5b7f | cf51f43961d72c41e06e023fa8c30d9fc79720a9 | refs/heads/master | 2021-01-10T19:01:33.376357 | 2014-02-20T21:28:35 | 2014-02-20T21:28:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,063 | cpp | /*******************************************************************\
| ezsockets.cpp: EzSockets Class Source |
| Designed by Josh Allen, Charles Lohr and Adam Lowman. |
| Socket programming methods based on Charles Lohr's EZW progam. |
| Modified by Charles Lohr for use with Windows-Based OSes. |
| UDP/NON-TCP Support by Adam Lowman. |
| |
| Primary Editor: Charles Lohr |
\*******************************************************************/
#include "ezSockets.h"
#if defined(_MSC_VER) && !defined(_XBOX) // We need the WinSock32 Library on Windows
#pragma comment(lib,"wsock32.lib")
#elif !defined(__MINGW32__) && !defined(_XBOX)
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#if !defined(SOCKET_ERROR)
#define SOCKET_ERROR -1
#endif
//There are cases where 0 isn't a proper socket
#if !defined(SOCKET_NONE)
#define SOCKET_NONE 0
#endif
#if !defined(INVALID_SOCKET)
#define INVALID_SOCKET -1
#endif
#if defined(WIN32)
typedef int socklen_t;
#endif
int iPackets = 0;
#include <iostream>
#include <cstring>
ezSocketsPacket::ezSocketsPacket()
{
Data = NULL;
Next = NULL;
iPackets++;
Port = 0;
ClearPacket();
}
ezSocketsPacket::~ezSocketsPacket()
{
iPackets--;
if ( Data )
free( Data );
}
void ezSocketsPacket::CopyPacket( ezSocketsPacket & pPacketToCopy )
{
Size = pPacketToCopy.Size;
if ( Data )
delete Data;
Data = (char*)malloc( Size );
memcpy( Data, pPacketToCopy.Data, Size );
Position = 0;
Next = NULL;
}
void ezSocketsPacket::DestroyTree()
{
if ( Next )
{
Next->DestroyTree();
delete Next;
Next = NULL;
}
if ( Data )
{
delete Data;
Data = NULL;
}
}
void ezSocketsPacket::ClearPacket()
{
if ( Data )
free( Data );
Data = NULL;
Position = 0;
Size = 0;
}
void ezSocketsPacket::SetupPacket( unsigned int iSize )
{
if ( Data )
free( Data );
Data = (char*)malloc( iSize );
Position = 0;
Size = iSize;
}
unsigned char ezSocketsPacket::Read1()
{
if ( Position < Size )
return Data[Position++];
else
return 0;
}
unsigned short ezSocketsPacket::Read2()
{
if ( Position < (Size-1) )
return ntohs( *((unsigned short*)&(Data[(Position+=2)-2])) );
else
return 0;
}
unsigned long ezSocketsPacket::Read4()
{
if ( Position < (Size-3) )
return ntohl( *((unsigned long*)&(Data[(Position+=4)-4])) );
else
return 0;
}
MString ezSocketsPacket::ReadNT()
{
if ( Position >= Size )
return MString("");
char * base = &Data[Position];
while ( Data[Position++] != '\0' );
return MString(base);
}
void ezSocketsPacket::Write1( unsigned char Info )
{
Grow( Position + 1 );
Data[Position++] = Info;
}
void ezSocketsPacket::Write2( unsigned short Info )
{
Grow( Position + 2 );
*((short*)(&Data[Position])) = htons(Info);
Position+=2;
}
void ezSocketsPacket::Write4( unsigned long Info )
{
Grow( Position + 4 );
*((unsigned long*)(&Data[Position])) = htonl(Info);
Position += 4;
}
void ezSocketsPacket::WriteNT( const MString& Info )
{
Grow( Position + Info.length() + 1 );
memcpy( &Data[Position], Info.c_str(), Info.length()+1 );
Position += Info.length()+1;
}
int ezSocketsPacket::ReadData( int Bytes, char * ToReplace )
{
if ( Bytes + Position >= Size )
Bytes = Size - Position;
if ( Bytes > 0 )
memcpy( ToReplace, &Data[Position], Bytes );
else
return 0;
Position += Bytes;
return Bytes;
}
void ezSocketsPacket::WriteData( const char * Info, unsigned int Length )
{
Grow( Length + Position );
memcpy( &Data[Position], Info, Length );
Position += Length;
}
void ezSocketsPacket::Grow( unsigned long iSizeTo )
{
if ( iSizeTo > (unsigned long)(Size) )
{
char * OldData = Data;
Data = (char*)malloc( iSizeTo );
if ( OldData )
{
memcpy( Data, OldData, Size );
free( OldData );
}
Size = iSizeTo;
}
}
ezSockets::ezSockets()
{
memset (&addr,0,sizeof(addr)); //Clear the sockaddr_in structure
#if defined(_WIN32) || defined(_XBOX) // Windows REQUIRES WinSock Startup
WSAStartup( MAKEWORD(1,1), &wsda );
#endif
sock = INVALID_SOCKET;
bBlocking = true;
scks = new fd_set;
times = new timeval;
times->tv_sec = 0;
times->tv_usec = 0;
state = skDISCONNECTED;
iBytesInPending = 0;
pDataInTail = NULL;
pDataInHead = NULL;
}
ezSockets::~ezSockets()
{
Close();
delete scks;
delete times;
}
bool ezSockets::Check()
{
#if !defined(XBOX)
return sock > SOCKET_NONE;
#else
return sock != INVALID_SOCKET;
#endif
}
bool ezSockets::Create(int Protocol, int Type)
{
state = skDISCONNECTED;
sock = socket(AF_INET, Type, Protocol);
lastCode = sock;
#if !defined(XBOX)
return sock > SOCKET_NONE; //Socket must be Greater than 0
#else
return sock != INVALID_SOCKET;
#endif
}
bool ezSockets::Bind(unsigned short port)
{
if(!Check())
return false;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(port);
lastCode = ::bind(sock,(struct sockaddr*)&addr, sizeof(addr));
return !lastCode;
}
bool ezSockets::Listen( unsigned long depth )
{
lastCode = ::listen(sock, depth);
if (lastCode == SOCKET_ERROR)
return false;
state = skLISTENING;
return true;
}
bool ezSockets::Accept(ezSockets& socket)
{
if (!bBlocking && !CanRead())
return false;
int length = sizeof(socket);
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
(socklen_t*) &length);
#if !( defined (_WIN32) || defined( _XBOX ) )
char buf[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &socket.addr.sin_addr, buf, INET_ADDRSTRLEN);
address = buf;
#else
address = inet_ntoa(socket.addr.sin_addr);
#endif
lastCode = socket.sock;
if ( socket.sock == SOCKET_ERROR )
return false;
socket.state = skCONNECTED;
return true;
}
ezSockets * ezSockets::Accept()
{
if (!bBlocking && !CanRead())
return NULL;
sockaddr_in local_addr;
int length = sizeof(local_addr);
int localsock = ::accept(sock,(struct sockaddr*) &local_addr,
(socklen_t*) &length);
if ( localsock == SOCKET_ERROR )
return NULL;
ezSockets * sNew = new ezSockets;
#if !( defined (_WIN32) || defined( _XBOX ) )
char buf[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &local_addr.sin_addr, buf, INET_ADDRSTRLEN);
sNew->address = buf;
#else
sNew->address = inet_ntoa(local_addr.sin_addr);
#endif
lastCode = localsock;
sNew->bBlocking = bBlocking;
sNew->lastCode = 0;
sNew->mode = mode;
sNew->pDataInHead = NULL;
sNew->sock = localsock;
sNew->state = skCONNECTED;
return sNew;
}
void ezSockets::Close()
{
state = skDISCONNECTED;
if ( pDataInHead )
{
pDataInHead->DestroyTree();
delete pDataInHead;
pDataInHead = NULL;
}
#if defined(WIN32) // The close socket command is different in Windows
::closesocket(sock);
#else
::close(sock);
#endif
}
bool ezSockets::Connect(const MString& host, unsigned short port)
{
if(!Check())
return false;
#if defined(_XBOX)
if(!isdigit(host[0])) // don't do a DNS lookup for an IP address
{
XNDNS *pxndns = NULL;
XNetDnsLookup(host.c_str(), NULL, &pxndns);
while (pxndns->iStatus == WSAEINPROGRESS)
{
// Do something else while lookup is in progress
}
if (pxndns->iStatus == 0)
memcpy(&addr.sin_addr, &pxndns->aina[0], sizeof(struct in_addr));
else
return false;
XNetDnsRelease(pxndns);
}
else
addr.sin_addr.s_addr = inet_addr(host.c_str());
#else
struct hostent* phe;
phe = gethostbyname(host.c_str());
if (phe == NULL)
return false;
memcpy(&addr.sin_addr, phe->h_addr, sizeof(struct in_addr));
#endif
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if(::connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR)
return false;
state = skCONNECTED;
return true;
}
bool ezSockets::CanRead()
{
FD_ZERO(scks);
FD_SET((unsigned)sock, scks);
return select(sock+1,scks,NULL,NULL,times) > 0;
}
bool ezSockets::DataAvailable()
{
if ( CanRead() )
return true;
//I think this is wrong, and is only the case with skGeneral
if ( pDataInHead )
if ( pDataInHead->PositionTAG != (unsigned int)(pDataInHead->Position) )
return true;
return false;
}
bool ezSockets::IsError()
{
if (state == skERROR)
return true;
FD_ZERO(scks);
FD_SET((unsigned)sock, scks);
if (select(sock+1, NULL, NULL, scks, times) >=0 )
return false;
state = skERROR;
return true;
}
bool ezSockets::CanWrite()
{
FD_ZERO(scks);
FD_SET((unsigned)sock, scks);
return select(sock+1, NULL, scks, NULL, times) > 0;
}
void ezSockets::SendData(const MString& outData)
{
if ( mode == skGeneral )
pWriteData( outData.c_str(), outData.length() );
}
void ezSockets::SendData(const char *data, unsigned int bytes)
{
if ( mode == skGeneral )
pWriteData( data, bytes );
}
int ezSockets::ReadData(char *data, unsigned int bytes)
{
if ( mode != skGeneral )
return -1;
int iRL = ReadLeftover( data, bytes );
while ( (unsigned int)(iRL) < bytes )
{
int iGot = pReadData( data + iRL, bytes - iRL );
if ( iGot <= 0 )
return iRL;
iRL += iGot;
}
return iRL;
}
int ezSockets::PeekData(char *data, unsigned int bytes)
{
if ( mode != skGeneral )
return -1;
int iRL = 0;
ReceiveGeneralData();
ezSocketsPacket * tmp = pDataInHead;
while ( tmp )
{
int iPotential = tmp->Size - tmp->Position;
if ( (unsigned int)(iPotential) > bytes-iRL )
iPotential = bytes-iRL;
memcpy( data + iRL, tmp->Data + tmp->Position, iPotential );
iRL += iPotential;
if ( (unsigned int)(iRL) >= bytes )
return iRL;
tmp = tmp->Next;
}
return iRL;
}
//Yuck, this algorithm is kind of slow...
bool ezSockets::ReadLine( MString & str )
{
if ( mode != skGeneral )
return false;
str = "";
ReceiveGeneralData();
ezSocketsPacket * tmp = pDataInHead;
bool bFound = false;
int i = 0;
while ( tmp )
{
for ( i = tmp->Position; i < (int)(tmp->PositionTAG); i++ )
if ( tmp->Data[i] == '\n' )
{
bFound = true;
break;
}
if ( !bFound )
tmp = tmp->Next;
else
break;
}
if ( !bFound && !bBlocking )
return false;
if ( bFound )
while ( pDataInHead != tmp )
{
str.append( pDataInHead->Data, pDataInHead->Size-pDataInHead->Position );
pDataInHead = pDataInHead->Next;
}
if ( pDataInHead )
if ( i != pDataInHead->Position )
{
str.append( pDataInHead->Data + pDataInHead->Position, i - pDataInHead->Position );
pDataInHead->Position = i + 1;
}
//Keep waiting for more data
if ( !bFound && bBlocking )
{
if ( pDataInHead )
pDataInHead->Position = pDataInHead->PositionTAG;
char tmp = '\0';
while ( tmp != '\n' )
{
if ( ReadLeftover( &tmp, 1 ) != 1 )
return false;
if ( tmp != '\n' )
str.append( &tmp, 1 );
}
}
if ( str.length() > 0 )
if ( str.c_str()[str.length()-1] == '\r' )
str.resize ( str.length() - 1 );
return true;
}
void ezSockets::WriteLine( const MString & str )
{
SendData( str.c_str(), str.length() );
SendData( "\r\n", 1 );
}
int ezSockets::ReadLeftover( char * data, unsigned int maxbytes )
{
if ( mode != skGeneral )
return -1;
ReceiveGeneralData();
int iPos = 0;
while ( pDataInHead )
{
int iMemToRead = pDataInHead->PositionTAG - pDataInHead->Position;
if ( iMemToRead == 0 )
break;
if ( iMemToRead > ( (int)(maxbytes) - iPos ) )
iMemToRead = maxbytes - iPos;
memcpy( data + iPos, pDataInHead->Data + pDataInHead->Position, iMemToRead );
pDataInHead->Position += iMemToRead;
iPos += iMemToRead;
if ( pDataInHead->Position == pDataInHead->Size )
{
if ( pDataInHead == pDataInTail )
{
delete pDataInHead;
pDataInHead = 0;
pDataInTail = 0;
return iPos;
} else {
ezSocketsPacket * tmp = pDataInHead;
pDataInHead = pDataInHead->Next;
delete tmp;
}
}
if ( (unsigned int)(iPos) >= maxbytes )
return iPos;
}
if ( bBlocking )
{
int iRead = pReadData( Buffer, (ezSocketsBuffersize<maxbytes)?ezSocketsBuffersize:maxbytes );
if ( iRead > 0 )
{
memcpy( data+iPos, Buffer, iRead );
return iRead+iPos;
}
else
return iPos;
} else
return iPos;
}
void ezSockets::ReceiveGeneralData( bool bForceBlock )
{
if ( mode == skGeneral )
{
while( CanRead() )
{
if( pDataInTail )
{
if ( pDataInTail->Size <= (int)(pDataInTail->PositionTAG) )
{
pDataInTail->Next = new ezSocketsPacket;
pDataInTail = pDataInTail->Next;
pDataInTail->Next = NULL;
pDataInTail->SetupPacket( ezSocketsBuffersize );
pDataInTail->PositionTAG = 0;
} else {
int rec = pReadData( pDataInTail->Data + pDataInTail->PositionTAG, pDataInTail->Size - pDataInTail->PositionTAG );
if ( rec>0 )
pDataInTail->PositionTAG += rec;
else
break;
}
}
else
{
pDataInTail = new ezSocketsPacket;
pDataInHead = pDataInTail;
pDataInHead->SetupPacket( ezSocketsBuffersize );
pDataInHead->PositionTAG = 0;
}
}
return;
} else if ( mode == skPackets )
{
bool bGotPack = false;
if ( pDataInTail )
if ( pDataInTail->PositionTAG >= 4 && pDataInTail->Position == pDataInTail->Size )
bGotPack = true;
while ( CanRead() || ( bForceBlock && !bGotPack ) )
{
if ( !pDataInTail )
{
pDataInHead = new ezSocketsPacket;
pDataInTail = pDataInHead;
pDataInTail->Next = NULL;
pDataInTail->PositionTAG = 0; //0: Nothing received yet.
}
if ( pDataInTail->PositionTAG == 4 && pDataInTail->Size == pDataInTail->Position )
{
pDataInTail->Next = new ezSocketsPacket;
pDataInTail = pDataInTail->Next;
pDataInTail->Next = NULL;
pDataInTail->PositionTAG = 0;
}
if ( pDataInTail->PositionTAG < 4 )
{
int recv = pReadData( Buffer, 4 - pDataInTail->PositionTAG );
int cpos = 0;
unsigned int oldpos = pDataInTail->PositionTAG;
pDataInTail->PositionTAG+=recv;
if ( recv > 0 )
{
for ( ; oldpos < pDataInTail->PositionTAG; oldpos++ )
{
unsigned long j = (unsigned char)Buffer[cpos];
pDataInTail->Size += j<<(8*(3-oldpos));
cpos++;
}
} else
return;
if ( pDataInTail->PositionTAG == 4 )
{
pDataInTail->SetupPacket( pDataInTail->Size );
pDataInTail->Position = 0;
}
} else
{
int recv = pReadData( pDataInTail->Data + pDataInTail->Position, pDataInTail->Size - pDataInTail->Position );
if ( recv > 0 )
pDataInTail->Position += recv;
else
return;
}
if ( pDataInTail )
if ( pDataInTail->PositionTAG >= 4 && pDataInTail->Position == pDataInTail->Size )
bGotPack = true;
}
} else if ( mode == skUDP )
{
if ( CanRead() || bForceBlock )
{
int iRead = pReadData( Buffer, ezSocketsBuffersize );
int pAddy = ntohl(fromAddr.sin_addr.s_addr);
int pPort = ntohs(fromAddr.sin_port);
if ( iRead>0 )
{
if ( !pDataInTail )
{
pDataInHead = new ezSocketsPacket;
pDataInTail = pDataInHead;
pDataInTail->PositionTAG = 0; //0: Nothing received yet.
} else {
ezSocketsPacket * tmp = pDataInTail;
pDataInTail = new ezSocketsPacket;
tmp->Next = pDataInTail;
}
pDataInTail->SetupPacket( iRead );
memcpy( pDataInTail->Data, Buffer, iRead );
pDataInTail->PositionTAG = pAddy;
pDataInTail->Port = pPort;
}
}
}
}
void ezSockets::SendPack( const ezSocketsPacket &pPack )
{
//While this seems kind of dumb, re-copying the data and all
//it does save us a potential extra packet.
//
//Overall, it actually saves CPU.
char * sToSend = (char*)malloc( pPack.Size + 4 );
unsigned int nBytes = htonl( pPack.Size );
memcpy( sToSend, &nBytes, 4 );
memcpy( sToSend + 4, pPack.Data, pPack.Size );
if( pPack.Port != 0 && mode == skUDP )
{
sockaddr_in to;
to.sin_port = htons( pPack.Port );
to.sin_family = AF_INET;
to.sin_addr.s_addr = htonl( pPack.PositionTAG );
memset( to.sin_zero, 0, 8 );
sendto( sock, sToSend, pPack.Size + 4 , 0, (sockaddr*)&to, sizeof( sockaddr_in ) );
}
else
pWriteData( sToSend, pPack.Size + 4 );
free( sToSend );
}
int ezSockets::ReadPack( ezSocketsPacket &pPack )
{
ReceiveGeneralData();
if( pDataInHead )
{
if ( ( pDataInHead->Position == pDataInHead->Size || mode == skUDP ) && pDataInHead->PositionTAG >= 4 )
{
//Free up any necessiary data
pPack.~ezSocketsPacket();
pPack = (*pDataInHead);
ezSocketsPacket * g = pDataInHead;
pPack.Position = 0;
if ( pDataInHead == pDataInTail )
{
pDataInHead = NULL;
pDataInTail = NULL;
} else
pDataInHead = pDataInHead->Next;
free( g );
return 1;
}
}
//Otherwise, wait until the packet is ready.
if ( bBlocking )
{
ReceiveGeneralData( true );
if( pDataInHead )
{
if ( ( pDataInHead->Position == pDataInHead->Size || mode == skUDP ) && pDataInHead->PositionTAG >= 4 )
{
//Free up any necessiary data
pPack.~ezSocketsPacket();
pPack = (*pDataInHead);
ezSocketsPacket * g = pDataInHead;
pPack.Position = 0;
if ( pDataInHead == pDataInTail )
{
pDataInHead = NULL;
pDataInTail = NULL;
} else
pDataInHead = pDataInHead->Next;
free( g );
return 1;
}
}
}
return 0;
}
int ezSockets::PeekPack( ezSocketsPacket &pPack )
{
ReceiveGeneralData();
if( pDataInHead )
{
if ( pDataInHead->Position == pDataInHead->Size )
{
pPack.CopyPacket( *pDataInHead );
pPack.Position = 0;
return 1;
}
}
return 0;
}
int ezSockets::pReadData(char* data, int maxsize )
{
if(state == skCONNECTED || state == skLISTENING)
return recv(sock, data, maxsize, 0);
int saddrinlen = sizeof(sockaddr_in);
return recvfrom(sock, data, maxsize, 0, (sockaddr*)&fromAddr,
(socklen_t*)&saddrinlen);
}
int ezSockets::pWriteData(const char* data, int dataSize)
{
return send(sock, data, dataSize, 0);
}
/*
* (c) 2003-2006 Josh Allen, Charles Lohr, and Adam Lowman
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 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.
*/
| [
"[email protected]"
] | |
8ddafc22c970e5eb6996f13a0dc8f79754efe3ca | dfb4cb8d916b62d7272ca353302d1ad95e4d7244 | /src/qt/openuridialog.h | 527813ba09d6509c7cb2eb64a3149b07e479e0e7 | [
"MIT"
] | permissive | mirzaei-ce/core-shahbit | d166ab47067bf66c3015c3da49ff31cd29f843db | 57ad738667b3d458c92d94aee713c184d911c537 | refs/heads/master | 2021-07-21T11:09:22.493418 | 2017-10-25T13:50:55 | 2017-10-25T13:50:55 | 108,276,937 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 655 | h | // Copyright (c) 2011-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef SHAHBIT_QT_OPENURIDIALOG_H
#define SHAHBIT_QT_OPENURIDIALOG_H
#include <QDialog>
namespace Ui {
class OpenURIDialog;
}
class OpenURIDialog : public QDialog
{
Q_OBJECT
public:
explicit OpenURIDialog(QWidget *parent);
~OpenURIDialog();
QString getURI();
protected Q_SLOTS:
void accept();
private Q_SLOTS:
void on_selectFileButton_clicked();
private:
Ui::OpenURIDialog *ui;
};
#endif // SHAHBIT_QT_OPENURIDIALOG_H
| [
"[email protected]"
] | |
f527ead6309712b9bf4eae8c09aed3927786f778 | a0520d443820a89a26e51f6cf6f8d5623615258c | /src/gqfast/loader/temp/q2_array_4threads_16966392.cpp | ee790597fb97432cb22b395c96ab0a7a440bdba0 | [] | no_license | lusuon/GQ-Fast | bcc9afc0350cbf2e310d4774f2fcf25b885fa1bb | e696945281759c4eb33cf370df0b2e92ba592f91 | refs/heads/master | 2023-03-17T17:52:11.550878 | 2016-08-15T21:01:52 | 2016-08-15T21:01:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,086 | cpp | #ifndef q2_array_4threads_16966392_
#define q2_array_4threads_16966392_
#include "../fastr_index.hpp"
#include "../global_vars.hpp"
#define NUM_THREADS 4
#define BUFFER_POOL_SIZE 1
using namespace std;
static args_threading arguments[NUM_THREADS];
static uint32_t year1_col0_element;
static double* R;
static int* RC;
extern inline void q2_array_4threads_16966392_year1_col0_decode_UA(uint32_t* year1_col0_ptr) __attribute__((always_inline));
extern inline void q2_array_4threads_16966392_term1_col0_decode_UA(uint32_t* term1_col0_ptr, uint32_t term1_col0_bytes, uint32_t & term1_fragment_size) __attribute__((always_inline));
extern inline void q2_array_4threads_16966392_term1_col1_decode_UA(unsigned char* term1_col1_ptr, uint32_t term1_fragment_size) __attribute__((always_inline));
void* pthread_q2_array_4threads_16966392_worker(void* arguments);
extern inline void q2_array_4threads_16966392_doc2_col0_decode_UA_threaded(int thread_id, uint32_t* doc2_col0_ptr, uint32_t doc2_col0_bytes, uint32_t & doc2_fragment_size) __attribute__((always_inline));
extern inline void q2_array_4threads_16966392_doc2_col1_decode_UA_threaded(int thread_id, unsigned char* doc2_col1_ptr, uint32_t doc2_fragment_size) __attribute__((always_inline));
extern inline void q2_array_4threads_16966392_year2_col0_decode_UA(uint32_t* year2_col0_ptr, uint32_t & year2_col0_element) __attribute__((always_inline));
void q2_array_4threads_16966392_year1_col0_decode_UA(uint32_t* year1_col0_ptr) {
year1_col0_element = *year1_col0_ptr;
}
void q2_array_4threads_16966392_term1_col0_decode_UA(uint32_t* term1_col0_ptr, uint32_t term1_col0_bytes, uint32_t & term1_fragment_size) {
term1_fragment_size = term1_col0_bytes/4;
for (uint32_t i=0; i<term1_fragment_size; i++) {
buffer_arrays[2][0][0][0][i] = *term1_col0_ptr++;
}
}
void q2_array_4threads_16966392_term1_col1_decode_UA(unsigned char* term1_col1_ptr, uint32_t term1_fragment_size) {
for (uint32_t i=0; i<term1_fragment_size; i++) {
buffer_arrays[2][1][0][0][i] = *term1_col1_ptr++;
}
}
void* pthread_q2_array_4threads_16966392_worker(void* arguments) {
args_threading* args = (args_threading *) arguments;
uint32_t term1_it = args->start;
uint32_t term1_fragment_size = args->end;
int thread_id = args->thread_id;
for (; term1_it < term1_fragment_size; term1_it++) {
uint32_t term1_col0_element = buffer_arrays[2][0][0][0][term1_it];
unsigned char term1_col1_element = buffer_arrays[2][1][0][0][term1_it];
uint32_t* row_doc2 = idx[3]->index_map[term1_col0_element];
uint32_t doc2_col0_bytes = idx[3]->index_map[term1_col0_element+1][0] - row_doc2[0];
if(doc2_col0_bytes) {
uint32_t* doc2_col0_ptr = reinterpret_cast<uint32_t *>(&(idx[3]->fragment_data[0][row_doc2[0]]));
uint32_t doc2_fragment_size = 0;
q2_array_4threads_16966392_doc2_col0_decode_UA_threaded(thread_id, doc2_col0_ptr, doc2_col0_bytes, doc2_fragment_size);
unsigned char* doc2_col1_ptr = &(idx[3]->fragment_data[1][row_doc2[1]]);
q2_array_4threads_16966392_doc2_col1_decode_UA_threaded(thread_id, doc2_col1_ptr, doc2_fragment_size);
for (uint32_t doc2_it = 0; doc2_it < doc2_fragment_size; doc2_it++) {
uint32_t doc2_col0_element = buffer_arrays[3][0][thread_id][0][doc2_it];
unsigned char doc2_col1_element = buffer_arrays[3][1][thread_id][0][doc2_it];
uint32_t* row_year2 = idx[1]->index_map[doc2_col0_element];
uint32_t* year2_col0_ptr = reinterpret_cast<uint32_t *>(&(idx[1]->fragment_data[0][row_year2[0]]));
uint32_t year2_col0_element;
q2_array_4threads_16966392_year2_col0_decode_UA(year2_col0_ptr, year2_col0_element);
RC[doc2_col0_element] = 1;
pthread_spin_lock(&spin_locks[3][doc2_col0_element]);
R[doc2_col0_element] += (double)(term1_col1_element*doc2_col1_element)/(ABS((int)year1_col0_element-(int)year2_col0_element)+1);
pthread_spin_unlock(&spin_locks[3][doc2_col0_element]);
}
}
}
return nullptr;
}
void q2_array_4threads_16966392_doc2_col0_decode_UA_threaded(int thread_id, uint32_t* doc2_col0_ptr, uint32_t doc2_col0_bytes, uint32_t & doc2_fragment_size) {
doc2_fragment_size = doc2_col0_bytes/4;
for (uint32_t i=0; i<doc2_fragment_size; i++) {
buffer_arrays[3][0][thread_id][0][i] = *doc2_col0_ptr++;
}
}
void q2_array_4threads_16966392_doc2_col1_decode_UA_threaded(int thread_id, unsigned char* doc2_col1_ptr, uint32_t doc2_fragment_size) {
for (uint32_t i=0; i<doc2_fragment_size; i++) {
buffer_arrays[3][1][thread_id][0][i] = *doc2_col1_ptr++;
}
}
void q2_array_4threads_16966392_year2_col0_decode_UA(uint32_t* year2_col0_ptr, uint32_t & year2_col0_element) {
year2_col0_element = *year2_col0_ptr;
}
extern "C" double* q2_array_4threads_16966392(int** null_checks) {
benchmark_t1 = chrono::steady_clock::now();
int max_frag;
max_frag = metadata.idx_max_fragment_sizes[1];
for(int i=0; i<metadata.idx_num_encodings[1]; i++) {
for (int j=0; j<NUM_THREADS; j++) {
buffer_arrays[1][i][j] = new uint64_t*[BUFFER_POOL_SIZE];
for (int k=0; k<BUFFER_POOL_SIZE; k++) {
buffer_arrays[1][i][j][k] = new uint64_t[max_frag];
}
}
}
max_frag = metadata.idx_max_fragment_sizes[2];
for(int i=0; i<metadata.idx_num_encodings[2]; i++) {
for (int j=0; j<NUM_THREADS; j++) {
buffer_arrays[2][i][j] = new uint64_t*[BUFFER_POOL_SIZE];
for (int k=0; k<BUFFER_POOL_SIZE; k++) {
buffer_arrays[2][i][j][k] = new uint64_t[max_frag];
}
}
}
max_frag = metadata.idx_max_fragment_sizes[3];
for(int i=0; i<metadata.idx_num_encodings[3]; i++) {
for (int j=0; j<NUM_THREADS; j++) {
buffer_arrays[3][i][j] = new uint64_t*[BUFFER_POOL_SIZE];
for (int k=0; k<BUFFER_POOL_SIZE; k++) {
buffer_arrays[3][i][j][k] = new uint64_t[max_frag];
}
}
}
RC = new int[metadata.idx_domains[3][0]]();
R = new double[metadata.idx_domains[3][0]]();
uint64_t doc1_list[1];
doc1_list[0] = 16966392;
for (int doc1_it = 0; doc1_it<1; doc1_it++) {
uint64_t doc1_col0_element = doc1_list[doc1_it];
uint32_t* row_year1 = idx[1]->index_map[doc1_col0_element];
uint32_t* year1_col0_ptr = reinterpret_cast<uint32_t *>(&(idx[1]->fragment_data[0][row_year1[0]]));
q2_array_4threads_16966392_year1_col0_decode_UA(year1_col0_ptr);
uint32_t* row_term1 = idx[2]->index_map[doc1_col0_element];
uint32_t term1_col0_bytes = idx[2]->index_map[doc1_col0_element+1][0] - row_term1[0];
if(term1_col0_bytes) {
uint32_t* term1_col0_ptr = reinterpret_cast<uint32_t *>(&(idx[2]->fragment_data[0][row_term1[0]]));
uint32_t term1_fragment_size = 0;
q2_array_4threads_16966392_term1_col0_decode_UA(term1_col0_ptr, term1_col0_bytes, term1_fragment_size);
unsigned char* term1_col1_ptr = &(idx[2]->fragment_data[1][row_term1[1]]);
q2_array_4threads_16966392_term1_col1_decode_UA(term1_col1_ptr, term1_fragment_size);
uint32_t thread_size = term1_fragment_size/NUM_THREADS;
uint32_t position = 0;
for (int i=0; i<NUM_THREADS; i++) {
arguments[i].start = position;
position += thread_size;
arguments[i].end = position;
arguments[i].thread_id = i;
}
arguments[NUM_THREADS-1].end = term1_fragment_size;
for (int i=0; i<NUM_THREADS; i++) {
pthread_create(&threads[i], NULL, &pthread_q2_array_4threads_16966392_worker, (void *) &arguments[i]);
}
for (int i=0; i<NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
}
}
for (int j=0; j<metadata.idx_num_encodings[1]; j++) {
for (int k=0; k<NUM_THREADS; k++) {
for (int l=0; l<BUFFER_POOL_SIZE; l++) {
delete[] buffer_arrays[1][j][k][l];
}
delete[] buffer_arrays[1][j][k];
}
}
for (int j=0; j<metadata.idx_num_encodings[2]; j++) {
for (int k=0; k<NUM_THREADS; k++) {
for (int l=0; l<BUFFER_POOL_SIZE; l++) {
delete[] buffer_arrays[2][j][k][l];
}
delete[] buffer_arrays[2][j][k];
}
}
for (int j=0; j<metadata.idx_num_encodings[3]; j++) {
for (int k=0; k<NUM_THREADS; k++) {
for (int l=0; l<BUFFER_POOL_SIZE; l++) {
delete[] buffer_arrays[3][j][k][l];
}
delete[] buffer_arrays[3][j][k];
}
}
*null_checks = RC;
return R;
}
#endif
| [
"[email protected]"
] | |
4885f9151cb1a398abef4964838f8dd1677093f7 | 39ee69301076fe46c53edf858dd472374fea51da | /Trees/Binary Trees/MinMaxofBT.cpp | 423ef3bc28fbe0edf5875155acfcf97868cfd42e | [] | no_license | imadi04/DS-CPP | b94cafc21abd38e1136ed4b2a427d09d6aa8cdf9 | d1ad1ebe8810e44f38f4c899516032f249b26dc4 | refs/heads/master | 2021-04-04T06:43:04.004649 | 2020-06-29T15:06:04 | 2020-06-29T15:06:04 | 248,433,403 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,164 | cpp | // Following is the Binary Tree node structure
/**************
class BinaryTreeNode {
public :
T data;
BinaryTreeNode<T> *left;
BinaryTreeNode<T> *right;
BinaryTreeNode(T data) {
this -> data = data;
left = NULL;
right = NULL;
}
};
// PairAns class -
class PairAns {
public :
int min;
int max;
};
***************/
//pair<int,int>
#include<algorithm>
PairAns minMax(BinaryTreeNode<int> *root) {
/* Don't write main().
* Don't read input, it is passed as function argument.
* Return output and don't print it.
* Taking input and printing output is handled automatically.
*/
if(!root){
PairAns p;
p.min=0;
p.max=0;
return p;
}
int rootData=root->data;
PairAns ans1=minMax(root->left);
PairAns ans2=minMax(root->right);
int leftMax=ans1.max;
int leftMin=ans1.min?ans1.min:rootData;
int rightMax=ans2.max;
int rightMin=ans2.min?ans2.min:rootData;
PairAns answer;
answer.max=max(rootData,max(leftMax,rightMax));
answer.min=min(rootData,min(leftMin,rightMin));
return answer;
}
| [
"[email protected]"
] | |
5aab43d2b205dad68ad2f5080eba7b40436e8f46 | 2728a9835ada3a355acf4fda50e5ef0bf78bea41 | /algorithm_Hoons/algorithm_Hoons/Programers/DFS_BFS_ChangeWord.cpp | 479df460aeec63a459fe6125ed2c8aa9679eb859 | [] | no_license | SeungHoons/algorithm_Hoons | 5d1301c78e35f3d5475aff3ceee9f98b9760ea87 | 551141939d1afdd4c177a0ee7acbc38a971f4df7 | refs/heads/master | 2020-04-13T11:11:55.354197 | 2020-02-27T07:56:47 | 2020-02-27T07:56:47 | 163,166,802 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,778 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
bool Collect(string _a, string _b)
{
int count = 0;
for (int i = 0; i < _a.length(); i++)
{
if (_a[i] != _b[i])
{
count++;
}
}
if (count != 1)
{
return false;
}
return true;
}
int DFSv1(string _now, string _starget, vector<string>& _words, bool* _visited, int _count)
{
int result = 0;
if (!strcmp(_now.c_str(), _starget.c_str()))
{
return _count ==0 ? 1 : _count;
}
int temp = 0;
for (int i = 0; i < _words.size(); i++)
{
if (_visited[i] == true)
continue;
temp = 0;
for (int j = 0; j < strlen(_words[i].c_str()); j++)
{
string tempStr = _words[i].c_str();
if (_now.c_str()[j] != tempStr[j])
temp++;
if (temp > 1)
{
_visited[i] = false;
break;
}
if (temp <= 1 && strlen(_words[i].c_str()) == (j + 1))
{
_visited[i] = true;
result = DFSv1(_words[i], _starget, _words, _visited, _count + 1);
_count--;
}
}
}
return result;
}
int DFS(string _now, string _starget, vector<string>& _words, bool* _visited, int _count)
{
int result = 0;
if (!strcmp(_now.c_str(), _starget.c_str()))
{
return _count;
}
int temp = 0;
for (int i = 0; i < _words.size(); i++)
{
if (_visited[i] == true)
continue;
temp = 0;
for (int j = 0; j < strlen(_words[i].c_str()); j++)
{
string tempStr = _words[i].c_str();
if (_now.c_str()[j] != tempStr[j])
temp++;
if (temp > 1)
{
_visited[i] = false;
break;
}
if (temp <= 1 && strlen(_words[i].c_str()) == (j + 1))
{
_visited[i] = true;
result = DFS(_words[i], _starget, _words, _visited, _count+1);
_count--;
}
}
}
return result;
}
int solution(string begin, string target, vector<string> words) {
int answer = words.size();
//처음에 잡아 내기위한
bool isNothing = true;
for (int i = 0; i < words.size(); i++)
{
if (!strcmp(words[i].c_str(), target.c_str()))
{
isNothing = false;
break;
}
}
if (isNothing)
return 0;
//
bool* visited;
visited = new bool[words.size()]{ false };
for (int i = 0; i < words.size(); i++)
{
for (int j = 0; j < words.size(); j++)
{
visited[j] = false;
}
if (Collect(begin, words[i]))
{
int tempAns;
tempAns = DFSv1(words[i], target, words, visited, 0);
if (tempAns != 0 && tempAns < answer)
answer = tempAns;
}
}
return answer;
}
int main()
{
string begin, target;
vector<string> words;
int maxWordsNum;
cin >> begin;
cin >> target;
Collect(begin, target);
scanf("%d", &maxWordsNum);
words.resize(maxWordsNum);
for (int i = 0; i < maxWordsNum; i++)
{
cin >> words[i];
}
printf("%d", solution(begin, target, words));
return 0;
}
| [
"[email protected]"
] | |
8557f5b2b651b3f3f9abf2f2a8e8bb864ebf366a | 09606d4778c676f3ccdd6eff4c032d2bab37fff3 | /tests/imported_host.cpp | 631400aa58b4bec2e77716cd23233ceb8201c3c3 | [
"MIT"
] | permissive | vcoda/Granite | 884bdfbc701dfd0e4a0befb603000c9692cb8dd1 | 8cd1ef557696e2897c9e235a503ea28d31a89360 | refs/heads/master | 2020-06-23T17:38:35.951920 | 2019-07-17T13:45:56 | 2019-07-17T13:45:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,521 | cpp | /* Copyright (c) 2017-2019 Hans-Kristian Arntzen
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "vulkan.hpp"
#include "device.hpp"
#include "global_managers.hpp"
#include <string.h>
using namespace Vulkan;
int main(int argc, char **argv)
{
if (argc != 2)
return EXIT_FAILURE;
Granite::Global::init();
if (!Context::init_loader(nullptr))
return EXIT_FAILURE;
auto file = Granite::Global::filesystem()->open(argv[1], Granite::FileMode::ReadOnly);
if (!file)
return EXIT_FAILURE;
void *mapped = file->map();
if (!mapped)
return EXIT_FAILURE;
Context ctx;
if (!ctx.init_instance_and_device(nullptr, 0, nullptr, 0))
return EXIT_FAILURE;
Device device;
device.set_context(ctx);
BufferCreateInfo info = {};
info.domain = BufferDomain::CachedHost;
info.size = file->get_size();
info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
auto buffer = device.create_imported_host_buffer(info, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, mapped);
if (!buffer)
return EXIT_FAILURE;
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
auto dst_buffer = device.create_buffer(info);
auto cmd = device.request_command_buffer();
cmd->copy_buffer(*dst_buffer, *buffer);
device.submit(cmd);
device.wait_idle();
auto *dst_mapped = device.map_host_buffer(*dst_buffer, MEMORY_ACCESS_READ_BIT);
if (memcmp(dst_mapped, mapped, 4096) != 0)
{
LOGE("Failure!\n");
return EXIT_FAILURE;
}
device.unmap_host_buffer(*dst_buffer, MEMORY_ACCESS_READ_BIT);
} | [
"[email protected]"
] | |
14bbb5bc8a83da9c228d77d6e64bbe7608e048a2 | 3b224c4d840bc733bf64894e7d4769fa2ae76016 | /E04s - Circle Creation/MyMesh.h | d1c25630e45158175bf71649c08baa1d78aa67f2 | [
"MIT"
] | permissive | labigm/IGME309-2201 | c89b3d77adbed9b413b0bf82719cd30fa46d8832 | 4f76fe565dbf727b2c0e16fbd02c10bcf83ab8ef | refs/heads/master | 2023-01-05T03:41:54.156487 | 2020-09-24T16:08:53 | 2020-09-24T16:08:53 | 288,234,145 | 2 | 29 | MIT | 2020-09-21T17:59:44 | 2020-08-17T16:45:03 | C++ | UTF-8 | C++ | false | false | 5,987 | h | /*----------------------------------------------
Programmer: Alberto Bobadilla ([email protected])
Date: 2017/05
----------------------------------------------*/
#ifndef __MYMESH_H_
#define __MYMESH_H_
#include "Definitions.h"
class MyMesh
{
bool m_bBinded = false; //Binded flag
uint m_uVertexCount = 0; //Number of vertices in this MyMesh
GLuint m_VAO = 0; //OpenGL Vertex Array Object
GLuint m_VBO = 0; //OpenGL Vertex Array Object
std::vector<vector3> m_lVertex; //Composed vertex array
std::vector<vector3> m_lVertexPos; //List of Vertices
std::vector<vector3> m_lVertexCol; //List of Colors
ShaderManager* m_pShaderMngr = nullptr; //Shader Manager
public:
/*
USAGE: Initialize the object's fields
ARGUMENTS: ---
OUTPUT: ---
*/
void Init(void);
/*
USAGE: Releases the object from memory
ARGUMENTS: ---
OUTPUT: ---
*/
void Release(void);
/*
USAGE: Constructor
ARGUMENTS: ---
OUTPUT: class object
*/
MyMesh();
/*
USAGE: Destructor
ARGUMENTS: ---
OUTPUT: ---
*/
~MyMesh();
/*
USAGE: Copy Constructor -> MyMesh does not allow to copy
from other MyMesh objects, create an empty MyMesh
and use the Instantiate method instead
ARGUMENTS: class object (to copy)
OUTPUT: class object
*/
MyMesh(MyMesh& other);
/*
USAGE: Copy Assignment Operator -> MyMesh does not allow to copy
from other SimpleMesh objects, use the Instantiate method instead.
ARGUMENTS: class object (to copy)
OUTPUT: class object
*/
MyMesh& operator=(MyMesh& other);
/*
USAGE: Swaps the contents of the object with another object's content
ARGUMENTS: class object (to swap with)
OUTPUT: ---
*/
void Swap(MyMesh& other);
/*
USAGE: Completes the information missing to create the mesh
ARGUMENTS: ---
OUTPUT: ---
*/
void CompleteMesh(vector3 a_v3Color = vector3(1.0f, 0.0f, 0.0f));
/*
USAGE: Adds a new point to the vector of vertices
ARGUMENTS:
- vector3 a_v3Input -> vector input
OUTPUT: ---
*/
void AddVertexPosition(vector3 a_v3Input);
/*
USAGE: Adds a new color to the vector of vertices
ARGUMENTS:
- vector3 a_v3Input -> vector input
OUTPUT: ---
*/
void AddVertexColor(vector3 a_v3Input);
/*
USAGE: Compiles the MyMesh for OpenGL 3.X use
ARGUMENTS: ---
OUTPUT: ---
*/
void CompileOpenGL3X(void);
/*
USAGE: Renders the mesh on the specified position by the
provided camera view and projection
ARGUMENTS:
- matrix4 a_mProjection -> Projection matrix
- matrix4 a_mView -> View matrix
- matrix4 a_mModel -> matrix of the model in the world
OUTPUT: ---
*/
void Render(matrix4 a_mProjection, matrix4 a_mView, matrix4 a_mModel);
/*
USAGE: Adds a tri to the list points in the buffer to be compiled
//C
//| \
//A--B
//This will make the triangle A->B->C
ARGUMENTS:
- vector3 a_vBottomLeft (A)
- vector3 a_vBottomRight (B)
- vector3 a_vTopLeft (C)
OUTPUT: ---
*/
void AddTri(vector3 a_vBottomLeft, vector3 a_vBottomRight, vector3 a_vTopLeft);
/*
USAGE: Adds a quad to the list points in the buffer to be compiled
//C--D
//| |
//A--B
//Will make the triangle A->B->C and then the triangle C->B->D
ARGUMENTS:
- vector3 a_vBottomLeft (A)
- vector3 a_vBottomRight (B)
- vector3 a_vTopLeft (C)
- vector3 a_vTopRight (D)
OUTPUT: ---
*/
void AddQuad(vector3 a_vBottomLeft, vector3 a_vBottomRight, vector3 a_vTopLeft, vector3 a_vTopRight);
#pragma region 3D Primitives
/*
USAGE: Generates a cube
ARGUMENTS:
- float a_fSize -> Size of each side
- vector3 a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateCube(float a_fSize, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a cuboid
ARGUMENTS:
- vector3 a_v3Dimensions -> Dimensions of each side of the cuboid
- vector3 a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateCuboid(vector3 a_v3Dimensions, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a cone mesh
ARGUMENTS:
- float a_fRadius -> radius
- int a_nSubdivisions -> divisions of the cap
- vector3 a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateCircle(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a cylinder mesh
ARGUMENTS:
- float a_fRadius -> radius
- float a_fHeight -> how tall is the mesh
- int a_nSubdivisions -> divisions on the cap
- vector3 a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateCone(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a cylinder mesh
ARGUMENTS:
- float a_fRadius -> radius
- float a_fHeight -> how tall is the mesh
- int a_nSubdivisions -> divisions on the cap
- vector3 a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateCylinder(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a tube mesh
ARGUMENTS:
- float a_fOuterRadius -> outer radius
- float a_fInnerRadius -> inner radius
- float a_fHeight -> how tall is the mesh
- int a_nSubdivisions -> divisions on the cap
- a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateTube(float a_fOuterRadius, float a_fInnerRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a torus mesh
ARGUMENTS:
- float a_fOuterRadius -> Outer radius
- float a_fInnerRadius -> Inner Radius
- int a_nSubdivisionHeight -> divisions vertical
- int a_nSubdivisionAxis -> divisions along the roundness of the mesh
- a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateTorus(float a_fOuterRadius, float a_fInnerRadius, int a_nSubdivisionHeight, int a_nSubdivisionAxis, vector3 a_v3Color = C_WHITE);
/*
USAGE: Generates a Sphere mesh
ARGUMENTS:
- float a_fRadius -> radius of the sphere
- int a_nSubdivisions -> Number of divisions, not a lot of difference in shapes larger than 3 subd
- a_v3Color -> Color of the mesh
OUTPUT: ---
*/
void GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color = C_WHITE);
#pragma endregion
};
#endif //__MYMESH_H_
/*
USAGE:
ARGUMENTS: ---
OUTPUT: ---
*/ | [
"[email protected]"
] | |
a6a09dcaca69d5348a402081514504e5156c4aeb | a3e2b0cb3c95e3d9735acd913ec1a767ec24754a | /src/libtorrent_deps.hpp | 1f9e006335feef57934442d565feeb034705d02f | [] | no_license | Ursescu/torrent-client | 98d9c901e1f8ed10ddd851bd392ff27e0a4f4bdd | 832520c93e6c511ffa063b96df7982ab6e1d63b0 | refs/heads/master | 2020-03-19T18:08:09.869846 | 2018-06-25T10:39:19 | 2018-06-25T10:39:19 | 136,795,360 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,826 | hpp | #ifndef LIBTORRENT_DEPS
#define LIBTORRENT_DEPS
#include <boost/smart_ptr/make_shared.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/entry.hpp>
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/session.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/torrent_status.hpp>
// Show torrent status
std::string state(libtorrent::torrent_status::state_t s) {
switch (s) {
case libtorrent::torrent_status::checking_files:
return std::string("Checking");
case libtorrent::torrent_status::downloading_metadata:
return std::string("Dl metadata");
case libtorrent::torrent_status::downloading:
return std::string("Downloading");
case libtorrent::torrent_status::finished:
return std::string("Finished");
case libtorrent::torrent_status::seeding:
return std::string("Seeding");
case libtorrent::torrent_status::allocating:
return std::string("Allocating");
case libtorrent::torrent_status::checking_resume_data:
return std::string("Checking resume");
default:
return std::string("<>");
}
}
namespace gui {
std::string torrent_status(libtorrent::torrent_status stat) {
std::stringstream ss;
ss << "\r" << std::left << std::setw(17) << state(stat.state) << " "
<< std::left << std::setw(80) << stat.name << " " << stat.save_path << " "
<< (stat.download_payload_rate / 1000) << " kB/s "
<< (stat.upload_payload_rate / 1000) << " kB/s "
<< (stat.total_done / 1000) << "/" << (stat.total_wanted / 1000) << " kB ("
<< (stat.progress_ppm / 10000) << "%)"
<< " : " << stat.num_peers << " peers : " << stat.num_seeds << " seeders"
<< std::endl;
return ss.str();
}
} // namespace gui
#endif | [
"[email protected]"
] | |
20aae2ba30f2178af4f7e6220060c62a27f9546b | 67fee4c964cfba111dcb1a39d126987e6b9867fd | /src/main.cpp | 6be536ed2335ff68bb02d7fa81ad184e4c63efd1 | [] | no_license | ss12330335/MEPL | f4fd3e02880f8cd511c7e5d7baa346bde8f44477 | 99629bf5ddb814480a1fd533346163c76a79090c | refs/heads/master | 2020-03-27T12:39:11.025795 | 2018-08-29T07:13:15 | 2018-08-29T07:13:15 | 146,559,449 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 703 | cpp | #include "header.h"
#include "planner.h"
using namespace std;
// global variable andfor compile
string domainName;
vector<string> atoms;
map<string, vector<string> > objects;
vector<string> agents;
map<int, string> findAtomsByIndex;
map<string, int> findAtomsByName;
map<string, int> findSensingActionByName;
map<string, int> findOnticActionByName;
vector<SensingAction> sActions;
vector<OnticAction> oActions;
KLDNF init;
KLDNF posGoal;
KLDNF goal;
PropDNF constraint;
// search data
int atomNum, solNum, expNum, solDepth;
double preTime, searchTime;
char epddlFilePath[500] = "../input/test.epddl";
int main(int argc, char** argv) {
Planner planner(epddlFilePath);
planner.exec();
return 0;
} | [
"[email protected]"
] | |
a59253bebcc02221d96773457bbb95f5ac7ce5fc | 9a3fd403e16941232f9d48c837ebe494b5f34023 | /Tests/MFC/mfc1/mfc1.cpp | 13384224799f50a4b7f43317c60d0d029f39ac40 | [
"BSD-3-Clause"
] | permissive | AnomalousMedical/CMake-OldFork | 9f7735199073525ab5f6b9074829af4abffac65b | 1bf1d8d1c8de2f7156a47ecf883408574c031ac1 | refs/heads/master | 2021-06-11T11:15:48.950407 | 2017-03-11T17:07:10 | 2017-03-11T17:07:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,862 | cpp | // mfc1.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "mfc1.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "mfc1Doc.h"
#include "mfc1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cmfc1App
BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
// Cmfc1App construction
Cmfc1App::Cmfc1App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only Cmfc1App object
Cmfc1App theApp;
// Cmfc1App initialization
BOOL Cmfc1App::InitInstance()
{
// InitCommonControls() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
InitCommonControls();
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE,
RUNTIME_CLASS(Cmfc1Doc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(Cmfc1View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// App command to run the dialog
void Cmfc1App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// Cmfc1App message handlers
| [
"AndrewPiper@7b0d72ad-f3cb-b44e-b30e-0ca2391ac3a1"
] | AndrewPiper@7b0d72ad-f3cb-b44e-b30e-0ca2391ac3a1 |
404f1280063be5f78801f9ca067b89677bd9ed78 | 101376386d33a98a56af71c3dd3126f54c32f61c | /heapsort.cpp | 8134982854866f7316d53ec9e7527e1c1d33429e | [] | no_license | varrior/Algorithms- | 30961581f3c446248a167e4d9a4c4763f70dc2e3 | 04dc60e5f6648f48bf0251ed9297ab7fb2331921 | refs/heads/master | 2022-07-26T19:52:24.898125 | 2020-05-22T10:17:43 | 2020-05-22T10:17:43 | 266,081,452 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 2,628 | cpp | #include<iostream>
#include<cmath>
#include<time.h>
#include<iomanip>
using namespace std;
/* SORTOWANIE PRZEZ KOPCOWANIE
Sortowanie metodą kopcowania. W programie głównym tworzona jest nieposortowana tablica z wykorzystaniem liczb pseudolosowych. Dodatkowo w pętlach wywoływane są dwie funkcje:
- wstawNaKoniec - powiększa pomocniczą tablicę A i element T[i] i porządkuje kopiec funckją doDory();
- usunMin - usuwa najmniejszy element z tablicy A i zapisuje go na miejscu T[i] i porządkuje kopiec funckją naDol().
Dodatkowo program wyświetla tablicę nieposortowaną, tablicę posortowaną oraz czas wykonania algorytmu
*/
void doGory(int *A, int na) {
int s = na; //Początkowy indeks potomka
int parent; //Indeks rodzica
int tmp; //Zmienna pomocnicza
while (true) {
if (s == 0) {
break;
}
parent = floor(s - 1) / 2;
if (A[s] >= A[parent]) {
break;
}
tmp = A[parent];
A[parent] = A[s];
A[s] = tmp;
s = parent;
}
}
void wstawNaKoniec(int* A, int e, int s) {
A[s] = e;
doGory(A, s);
}
void naDol(int* A, int na) {
int parent = 0; //Początkowy indeks rodzica
int right; //Indeks prawego potomka
int left; //Indeks lewego potomka
int tmp; //Zmienna pomocnicza
while (true) {
left = 2 * parent +1;
if (left > na) {
break;
}
right = 2 * parent + 2;
if (right <= na && A[right] < A[left]) {
left = right;
}
if (A[parent] <= A[left]) {
break;
}
tmp = A[parent];
A[parent] = A[left];
A[left] = tmp;
parent = left;
}
}
void usunMin(int* A, int& e, int s) {
e = A[0];
A[0] = A[s];
naDol(A, s);
}
int main() {
int n;
int* T;
int* A;
float start, stop, sort_time;
cout << "Sortowanie elementow w tablicy metoda kopcowania" << endl <<endl;
cout << "Podaj liczbe elementow w tablicy: " << endl;
cin >> n;
cout << endl;
T = new int[n];
A = new int[n];
srand((double)time(NULL));
for (int i = 0; i < n; i++) {
T[i] = rand() % 50;
}
int na = 0;
cout << "Tablica nieposortowana: [";
for (int i = 0; i < n; i++) {
if (i < n - 1) {
cout << T[i]<<", ";
}
else {
cout << T[i]<<"]" << endl;
}
}
start = clock();
for (int i = 0; i < n; i++) {
wstawNaKoniec(A, T[i], na++);
}
na = n-1;
for (int i = 0; i < n; i++) {
usunMin(A, T[i], na--);
}
stop = clock();
cout << "Tablica posortowana: [";
for (int i = 0; i < n; i++) {
if (i < n - 1) {
cout << T[i] << ", ";
}
else {
cout << T[i] << "]" << endl;
}
}
cout << endl << "Czas wykonania sortowania: " << setprecision(7) <<(stop - start) / CLOCKS_PER_SEC << endl;
delete[] T;
delete[] A;
return 0;
} | [
"[email protected]"
] | |
f623461ede0f7033e151c90f572e3ca09c6e9e8b | fb7868146d811f049d85345b7af878c391c79be1 | /client/model/Organisation.cpp | a8584eea29dce984a2a999ed8cbc7be70b1dd0d1 | [
"MIT"
] | permissive | jmp75/senaps-cpp | e5e7560422107804aad32792a6bba219ad1579be | 13b0410a3965a8a25771719281481c91212b07b8 | refs/heads/master | 2021-05-07T22:57:16.612555 | 2018-01-09T00:46:20 | 2018-01-09T00:46:20 | 107,370,080 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,925 | cpp | /**
* Sensor Data API
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 2.20
*
*
* NOTE: This class is auto generated by the swagger code generator 2.3.1-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "Organisation.h"
namespace io {
namespace swagger {
namespace client {
namespace model {
Organisation::Organisation()
{
m_Id = utility::conversions::to_string_t("");
m_IdIsSet = false;
m_Name = utility::conversions::to_string_t("");
m_NameIsSet = false;
m__linksIsSet = false;
}
Organisation::~Organisation()
{
}
void Organisation::validate()
{
// TODO: implement validation
}
web::json::value Organisation::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
{
val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id);
}
if(m_NameIsSet)
{
val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name);
}
if(m__linksIsSet)
{
val[utility::conversions::to_string_t("_links")] = ModelBase::toJson(m__links);
}
return val;
}
void Organisation::fromJson(web::json::value& val)
{
if(val.has_field(utility::conversions::to_string_t("id")))
{
setId(ModelBase::stringFromJson(val[utility::conversions::to_string_t("id")]));
}
if(val.has_field(utility::conversions::to_string_t("name")))
{
setName(ModelBase::stringFromJson(val[utility::conversions::to_string_t("name")]));
}
if(val.has_field(utility::conversions::to_string_t("_links")))
{
if(!val[utility::conversions::to_string_t("_links")].is_null())
{
std::shared_ptr<Organisation__links> newItem(new Organisation__links());
newItem->fromJson(val[utility::conversions::to_string_t("_links")]);
setLinks( newItem );
}
}
}
void Organisation::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id));
}
if(m_NameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name));
}
if(m__linksIsSet)
{
if (m__links.get())
{
m__links->toMultipart(multipart, utility::conversions::to_string_t("_links."));
}
}
}
void Organisation::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}
if(multipart->hasContent(utility::conversions::to_string_t("id")))
{
setId(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id"))));
}
if(multipart->hasContent(utility::conversions::to_string_t("name")))
{
setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name"))));
}
if(multipart->hasContent(utility::conversions::to_string_t("_links")))
{
if(multipart->hasContent(utility::conversions::to_string_t("_links")))
{
std::shared_ptr<Organisation__links> newItem(new Organisation__links());
newItem->fromMultiPart(multipart, utility::conversions::to_string_t("_links."));
setLinks( newItem );
}
}
}
utility::string_t Organisation::getId() const
{
return m_Id;
}
void Organisation::setId(utility::string_t value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Organisation::idIsSet() const
{
return m_IdIsSet;
}
void Organisation::unsetId()
{
m_IdIsSet = false;
}
utility::string_t Organisation::getName() const
{
return m_Name;
}
void Organisation::setName(utility::string_t value)
{
m_Name = value;
m_NameIsSet = true;
}
bool Organisation::nameIsSet() const
{
return m_NameIsSet;
}
void Organisation::unsetName()
{
m_NameIsSet = false;
}
std::shared_ptr<Organisation__links> Organisation::getLinks() const
{
return m__links;
}
void Organisation::setLinks(std::shared_ptr<Organisation__links> value)
{
m__links = value;
m__linksIsSet = true;
}
bool Organisation::linksIsSet() const
{
return m__linksIsSet;
}
void Organisation::unset_links()
{
m__linksIsSet = false;
}
}
}
}
}
| [
"[email protected]"
] | |
ad393ff98cc4cd64367e481e91549700872beb9a | 9bb00c7c2eabdcac09b71f43e69e75efff4812f4 | /src/DisplayDriver.h | 2645cd24df172c025e39d784fd3a4cddbb41fb7e | [] | no_license | mattncsu/minigrafx | 724423995d57cdd3bfaff5e73e872fbaa3a89f99 | 6c16c413f600f7bd427ac0ee599b408dde1f7eb2 | refs/heads/master | 2021-05-10T23:20:22.737209 | 2018-03-01T04:48:00 | 2018-03-01T04:48:00 | 118,281,734 | 2 | 0 | null | 2018-01-20T21:21:10 | 2018-01-20T21:21:10 | null | UTF-8 | C++ | false | false | 2,287 | h | /**
The MIT License (MIT)
Copyright (c) 2017 by Daniel Eichhorn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Please note: I am spending a lot of my free time in developing Software and Hardware
for these projects. Please consider supporting me by
a) Buying my hardware kits from https://blog.squix.org/shop
b) Send a donation: https://www.paypal.me/squix/5USD
c) Or using this affiliate link while shopping: https://www.banggood.com/?p=6R31122484684201508S
See more at https://blog.squix.org
Demo for the buffered graphics library. Renders a 3D cube
*/
#ifndef _MINIGRAFX_DRIVER_H
#define _MINIGRAFX_DRIVER_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class DisplayDriver {
public:
DisplayDriver(int16_t w, int16_t h); // Constructor
virtual void setRotation(uint8_t r);
virtual void init() = 0;
virtual void writeBuffer(uint8_t *buffer, uint8_t bitsPerPixel, uint16_t *palette) = 0;
virtual void setFastRefresh(boolean isEnabled) = 0;
int16_t height(void) const;
int16_t width(void) const;
uint8_t getRotation(void) const;
protected:
const int16_t
WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
int16_t _width, _height;
uint8_t rotation;
boolean isFastRefreshEnabled = false;
};
#endif // _MINIGRAFX_DRIVER_H
| [
"[email protected]"
] | |
b2b8b942d7379b34d54522abe40b61826fc05201 | ce86806a49f6437fb469dd9f8c60a15b3caead40 | /src/Graph/Graph.h | c351690802ad8b6d5d859f02a7f27aec9fe886aa | [
"MIT"
] | permissive | tchuna/Cal-FEUP | b03eab2f77d8bcd78e04a4b859a1247df2ca2ce5 | c0032adb711f4f52f3a73a7115bfdd76ca4a17a2 | refs/heads/master | 2022-09-19T20:46:56.058050 | 2020-05-13T23:24:54 | 2020-05-13T23:24:54 | 254,610,993 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,483 | h | /*
* Graph.h
*/
#ifndef GRAPH_H_
#define GRAPH_H_
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <list>
#include <limits.h>
using namespace std;
template <class T> class Edge;
template <class T> class Graph;
template <class T> class Vertex;
const int NOT_VISITED = 0;
const int BEING_VISITED = 1;
const int DONE_VISITED = 2;
const int INT_INFINITY = INT_MAX;
/*
* ================================================================================================
* Class Vertex
* ================================================================================================
*/
template <class T>
class Vertex {
T info;
bool visited;
bool processing;
int indegree;
int x;
int y;
double dist;
public:
vector<Edge<T> > adj;
Vertex(T in);
friend class Graph<T>;
void addEdge(Vertex<T> *dest, double w);
bool removeEdgeTo(Vertex<T> *d);
T getInfo() const;
void setInfo(T info);
int getDist() const;
int getIndegree() const;
bool operator<(const Vertex<T> vertex);
Vertex* path;
vector<Edge<T> > getAdj() const;
};
template <class T>
struct vertex_greater_than {
bool operator()(Vertex<T> * a, Vertex<T> * b) const {
return a->getDist() > b->getDist();
}
};
template <class T>
bool Vertex<T>::removeEdgeTo(Vertex<T> *d) {
d->indegree--;
typename vector<Edge<T> >::iterator it= adj.begin();
typename vector<Edge<T> >::iterator ite= adj.end();
while (it!=ite) {
if (it->dest == d) {
adj.erase(it);
return true;
}
else it++;
}
return false;
}
template <class T>
Vertex<T>::Vertex(T in): info(in), visited(false), processing(false), indegree(0), dist(0) {
path = NULL;
}
template <class T>
void Vertex<T>::addEdge(Vertex<T> *dest, double w) {
Edge<T> edgeD(dest,w);
adj.push_back(edgeD);
}
template <class T>
T Vertex<T>::getInfo() const {
return this->info;
}
template <class T>
int Vertex<T>::getDist() const {
return this->dist;
}
template <class T>
void Vertex<T>::setInfo(T info) {
this->info = info;
}
template <class T>
int Vertex<T>::getIndegree() const {
return this->indegree;
}
/* ================================================================================================
* Class Edge
* ================================================================================================
*/
template <class T>
class Edge {
Vertex<T> * dest;
public:
double weight;
Edge(Vertex<T> *d, double w);
friend class Graph<T>;
friend class Vertex<T>;
};
template <class T>
Edge<T>::Edge(Vertex<T> *d, double w): dest(d), weight(w){}
/* ================================================================================================
* Class Graph
* ================================================================================================
*/
template <class T>
class Graph {
vector<Vertex<T> *> vertexSet;
void dfs(Vertex<T> *v, vector<T> &res) const;
int numCycles;
void dfsVisit(Vertex<T> *v);
void dfsVisit();
void getPathTo(Vertex<T> *origin, list<T> &res);
int ** W; //weight
int ** P; //path
public:
bool addVertex(const T &in);
bool addEdge(const T &sourc, const T &dest, double w);
bool removeVertex(const T &in);
bool removeEdge(const T &sourc, const T &dest);
vector<T> dfs() const;
vector<T> bfs(Vertex<T> *v) const;
int maxNewChildren(Vertex<T> *v, T &inf) const;
vector<Vertex<T> * > getVertexSet() const;
int getNumVertex() const;
Vertex<T>* getVertex(const T &v) const;
void resetIndegrees();
vector<Vertex<T>*> getSources() const;
int getNumCycles();
vector<T> topologicalOrder();
vector<T> getPath(const T &origin, const T &dest);
void unweightedShortestPath(const T &v);
bool isDAG();
void bellmanFordShortestPath(const T &s);
void dijkstraShortestPath(const T &s);
void floydWarshallShortestPath();
int edgeCost(int vOrigIndex, int vDestIndex);
vector<T> getfloydWarshallPath(const T &origin, const T &dest);
void getfloydWarshallPathAux(int index1, int index2, vector<T> & res);
int getWeight(const T &source, const T &dest);
};
template <class T>
int Graph<T>::getNumVertex() const {
return vertexSet.size();
}
template <class T>
vector<Vertex<T> * > Graph<T>::getVertexSet() const {
return vertexSet;
}
template <class T>
int Graph<T>::getNumCycles() {
numCycles = 0;
dfsVisit();
return this->numCycles;
}
template <class T>
bool Graph<T>::isDAG() {
return (getNumCycles() == 0);
}
template <class T>
bool Graph<T>::addVertex(const T &in) {
typename vector<Vertex<T>*>::iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::iterator ite= vertexSet.end();
for (; it!=ite; it++)
if ((*it)->info == in) return false;
Vertex<T> *v1 = new Vertex<T>(in);
vertexSet.push_back(v1);
return true;
}
template <class T>
bool Graph<T>::removeVertex(const T &in) {
typename vector<Vertex<T>*>::iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::iterator ite= vertexSet.end();
for (; it!=ite; it++) {
if ((*it)->info == in) {
Vertex<T> * v= *it;
vertexSet.erase(it);
typename vector<Vertex<T>*>::iterator it1= vertexSet.begin();
typename vector<Vertex<T>*>::iterator it1e= vertexSet.end();
for (; it1!=it1e; it1++) {
(*it1)->removeEdgeTo(v);
}
typename vector<Edge<T> >::iterator itAdj= v->adj.begin();
typename vector<Edge<T> >::iterator itAdje= v->adj.end();
for (; itAdj!=itAdje; itAdj++) {
itAdj->dest->indegree--;
}
delete v;
return true;
}
}
return false;
}
template <class T>
bool Graph<T>::addEdge(const T &sourc, const T &dest, double w) {
typename vector<Vertex<T>*>::iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::iterator ite= vertexSet.end();
int found=0;
Vertex<T> *vS, *vD;
while (found!=2 && it!=ite ) {
if ( (*it)->info == sourc )
{ vS=*it; found++;}
if ( (*it)->info == dest )
{ vD=*it; found++;}
it ++;
}
if (found!=2) return false;
vD->indegree++;
vS->addEdge(vD,w);
return true;
}
template <class T>
bool Graph<T>::removeEdge(const T &sourc, const T &dest) {
typename vector<Vertex<T>*>::iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::iterator ite= vertexSet.end();
int found=0;
Vertex<T> *vS, *vD;
while (found!=2 && it!=ite ) {
if ( (*it)->info == sourc )
{ vS=*it; found++;}
if ( (*it)->info == dest )
{ vD=*it; found++;}
it ++;
}
if (found!=2)
return false;
vD->indegree--;
return vS->removeEdgeTo(vD);
}
template <class T>
vector<T> Graph<T>::dfs() const {
typename vector<Vertex<T>*>::const_iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::const_iterator ite= vertexSet.end();
for (; it !=ite; it++)
(*it)->visited=false;
vector<T> res;
it=vertexSet.begin();
for (; it !=ite; it++)
if ( (*it)->visited==false )
dfs(*it,res);
return res;
}
template <class T>
void Graph<T>::dfs(Vertex<T> *v,vector<T> &res) const {
v->visited = true;
res.push_back(v->info);
typename vector<Edge<T> >::iterator it= (v->adj).begin();
typename vector<Edge<T> >::iterator ite= (v->adj).end();
for (; it !=ite; it++)
if ( it->dest->visited == false ){
dfs(it->dest, res);
}
}
template <class T>
vector<T> Graph<T>::bfs(Vertex<T> *v) const {
vector<T> res;
queue<Vertex<T> *> q;
q.push(v);
v->visited = true;
while (!q.empty()) {
Vertex<T> *v1 = q.front();
q.pop();
res.push_back(v1->info);
typename vector<Edge<T> >::iterator it=v1->adj.begin();
typename vector<Edge<T> >::iterator ite=v1->adj.end();
for (; it!=ite; it++) {
Vertex<T> *d = it->dest;
if (d->visited==false) {
d->visited=true;
q.push(d);
}
}
}
return res;
}
template <class T>
int Graph<T>::maxNewChildren(Vertex<T> *v, T &inf) const {
vector<T> res;
queue<Vertex<T> *> q;
queue<int> level;
int maxChildren=0;
inf =v->info;
q.push(v);
level.push(0);
v->visited = true;
while (!q.empty()) {
Vertex<T> *v1 = q.front();
q.pop();
res.push_back(v1->info);
int l=level.front();
level.pop(); l++;
int nChildren=0;
typename vector<Edge<T> >::iterator it=v1->adj.begin();
typename vector<Edge<T> >::iterator ite=v1->adj.end();
for (; it!=ite; it++) {
Vertex<T> *d = it->dest;
if (d->visited==false) {
d->visited=true;
q.push(d);
level.push(l);
nChildren++;
}
}
if (nChildren>maxChildren) {
maxChildren=nChildren;
inf = v1->info;
}
}
return maxChildren;
}
template <class T>
Vertex<T>* Graph<T>::getVertex(const T &v) const {
for(unsigned int i = 0; i < vertexSet.size(); i++)
if (vertexSet[i]->info == v) return vertexSet[i];
return NULL;
}
template<class T>
void Graph<T>::resetIndegrees() {
for(unsigned int i = 0; i < vertexSet.size(); i++) vertexSet[i]->indegree = 0;
for(unsigned int i = 0; i < vertexSet.size(); i++) {
for(unsigned int j = 0; j < vertexSet[i]->adj.size(); j++) {
vertexSet[i]->adj[j].dest->indegree++;
}
}
}
template<class T>
vector<Vertex<T>*> Graph<T>::getSources() const {
vector< Vertex<T>* > buffer;
for(unsigned int i = 0; i < vertexSet.size(); i++) {
if( vertexSet[i]->indegree == 0 ) buffer.push_back( vertexSet[i] );
}
return buffer;
}
template <class T>
void Graph<T>::dfsVisit() {
typename vector<Vertex<T>*>::const_iterator it= vertexSet.begin();
typename vector<Vertex<T>*>::const_iterator ite= vertexSet.end();
for (; it !=ite; it++)
(*it)->visited=false;
it=vertexSet.begin();
for (; it !=ite; it++)
if ( (*it)->visited==false )
dfsVisit(*it);
}
template <class T>
void Graph<T>::dfsVisit(Vertex<T> *v) {
v->processing = true;
v->visited = true;
typename vector<Edge<T> >::iterator it= (v->adj).begin();
typename vector<Edge<T> >::iterator ite= (v->adj).end();
for (; it !=ite; it++) {
if ( it->dest->processing == true) numCycles++;
if ( it->dest->visited == false ){
dfsVisit(it->dest);
}
}
v->processing = false;
}
template<class T>
vector<T> Graph<T>::topologicalOrder() {
vector<T> res;
if( getNumCycles() > 0 ) {
cout << "Ordenacao Impossivel!" << endl;
return res;
}
this->resetIndegrees();
queue<Vertex<T>*> q;
vector<Vertex<T>*> sources = getSources();
while( !sources.empty() ) {
q.push( sources.back() );
sources.pop_back();
}
while( !q.empty() ) {
Vertex<T>* v = q.front();
q.pop();
res.push_back(v->info);
for(unsigned int i = 0; i < v->adj.size(); i++) {
v->adj[i].dest->indegree--;
if( v->adj[i].dest->indegree == 0) q.push( v->adj[i].dest );
}
}
if ( res.size() != vertexSet.size() ) {
while( !res.empty() ) res.pop_back();
}
this->resetIndegrees();
return res;
}
template<class T>
vector<T> Graph<T>::getPath(const T &origin, const T &dest){
list<T> buffer;
Vertex<T>* v = getVertex(dest);
buffer.push_front(v->info);
while ( v->path != NULL && v->path->info != origin) {
v = v->path;
buffer.push_front(v->info);
}
if( v->path != NULL )
buffer.push_front(v->path->info);
vector<T> res;
while( !buffer.empty() ) {
res.push_back( buffer.front() );
buffer.pop_front();
}
return res;
}
template<class T>
vector<T> Graph<T>::getfloydWarshallPath(const T &origin, const T &dest){
int originIndex = -1, destinationIndex = -1;
for(unsigned int i = 0; i < vertexSet.size(); i++)
{
if(vertexSet[i]->info == origin)
originIndex = i;
if(vertexSet[i]->info == dest)
destinationIndex = i;
if(originIndex != -1 && destinationIndex != -1)
break;
}
vector<T> res;
if(W[originIndex][destinationIndex] == INT_INFINITY)
return res;
res.push_back(vertexSet[originIndex]->info);
if(P[originIndex][destinationIndex] != -1)
{
int intermedIndex = P[originIndex][destinationIndex];
getfloydWarshallPathAux(originIndex, intermedIndex, res);
res.push_back(vertexSet[intermedIndex]->info);
getfloydWarshallPathAux(intermedIndex,destinationIndex, res);
}
res.push_back(vertexSet[destinationIndex]->info);
return res;
}
template<class T>
void Graph<T>::getfloydWarshallPathAux(int index1, int index2, vector<T> & res)
{
if(P[index1][index2] != -1)
{
getfloydWarshallPathAux(index1, P[index1][index2], res);
res.push_back(vertexSet[P[index1][index2]]->info);
getfloydWarshallPathAux(P[index1][index2],index2, res);
}
}
template<class T>
void Graph<T>::unweightedShortestPath(const T &s) {
for(unsigned int i = 0; i < vertexSet.size(); i++) {
vertexSet[i]->path = NULL;
vertexSet[i]->dist = INT_INFINITY;
}
Vertex<T>* v = getVertex(s);
v->dist = 0;
queue< Vertex<T>* > q;
q.push(v);
while( !q.empty() ) {
v = q.front(); q.pop();
for(unsigned int i = 0; i < v->adj.size(); i++) {
Vertex<T>* w = v->adj[i].dest;
if( w->dist == INT_INFINITY ) {
w->dist = v->dist + 1;
w->path = v;
q.push(w);
}
}
}
}
template<class T>
void Graph<T>::bellmanFordShortestPath(const T &s) {
for(unsigned int i = 0; i < vertexSet.size(); i++) {
vertexSet[i]->path = NULL;
vertexSet[i]->dist = INT_INFINITY;
}
Vertex<T>* v = getVertex(s);
v->dist = 0;
queue< Vertex<T>* > q;
q.push(v);
while( !q.empty() ) {
v = q.front(); q.pop();
for(unsigned int i = 0; i < v->adj.size(); i++) {
Vertex<T>* w = v->adj[i].dest;
if(v->dist + v->adj[i].weight < w->dist) {
w->dist = v->dist + v->adj[i].weight;
w->path = v;
q.push(w);
}
}
}
}
template<class T>
void Graph<T>::dijkstraShortestPath(const T &s) {
for(unsigned int i = 0; i < vertexSet.size(); i++) {
vertexSet[i]->path = NULL;
vertexSet[i]->dist = INT_INFINITY;
vertexSet[i]->processing = false;
}
Vertex<T>* v = getVertex(s);
v->dist = 0;
vector< Vertex<T>* > pq;
pq.push_back(v);
make_heap(pq.begin(), pq.end());
while( !pq.empty() ) {
v = pq.front();
pop_heap(pq.begin(), pq.end());
pq.pop_back();
for(unsigned int i = 0; i < v->adj.size(); i++) {
Vertex<T>* w = v->adj[i].dest;
if(v->dist + v->adj[i].weight < w->dist ) {
w->dist = v->dist + v->adj[i].weight;
w->path = v;
if(!w->processing)
{
w->processing = true;
pq.push_back(w);
}
make_heap (pq.begin(),pq.end(),vertex_greater_than<T>());
}
}
}
}
template<class T>
int Graph<T>::edgeCost(int vOrigIndex, int vDestIndex)
{
if(vertexSet[vOrigIndex] == vertexSet[vDestIndex])
return 0;
for(unsigned int i = 0; i < vertexSet[vOrigIndex]->adj.size(); i++)
{
if(vertexSet[vOrigIndex]->adj[i].dest == vertexSet[vDestIndex])
return vertexSet[vOrigIndex]->adj[i].weight;
}
return INT_INFINITY;
}
template<class T>
void Graph<T>::floydWarshallShortestPath() {
W = new int * [vertexSet.size()];
P = new int * [vertexSet.size()];
for(unsigned int i = 0; i < vertexSet.size(); i++)
{
W[i] = new int[vertexSet.size()];
P[i] = new int[vertexSet.size()];
for(unsigned int j = 0; j < vertexSet.size(); j++)
{
W[i][j] = edgeCost(i,j);
P[i][j] = -1;
}
}
for(unsigned int k = 0; k < vertexSet.size(); k++)
for(unsigned int i = 0; i < vertexSet.size(); i++)
for(unsigned int j = 0; j < vertexSet.size(); j++)
{
if(W[i][k] == INT_INFINITY || W[k][j] == INT_INFINITY)
continue;
int val = min ( W[i][j], W[i][k]+W[k][j] );
if(val != W[i][j])
{
W[i][j] = val;
P[i][j] = k;
}
}
}
template<class T>
int Graph<T>::getWeight(const T &source, const T &dest) {
int s=0,d=0;
for(unsigned int i=0; i<vertexSet.size(); i++) {
if(vertexSet[i]->getInfo() == getVertex(source)->getInfo())
s=i;
else if(vertexSet[i]->getInfo() == getVertex(dest)->getInfo())
d=i;
}
return edgeCost(s,d);
}
#endif /*GRAPH_H_ */
| [
"[email protected]"
] | |
972bd240ec857c48453e8c3f4d27676ff6604a08 | 11cb07ccbfdbe794147def48d4649d7a80bdc8e4 | /game/nAlgo.h | 43cea91fd683745af5ac7f0a1983cc332c3844fc | [] | no_license | qq587282/GameServerFramework | e34078d148400772b6473c49dd732d4c57bb2d7f | 64f0b71b81dc94ce92517f3e7efecc1d775a32ee | refs/heads/master | 2020-05-20T18:41:54.102213 | 2017-07-03T10:33:03 | 2017-07-03T10:33:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,991 | h | #ifndef _NALGO_H_
#define _NALGO_H_
#include "game/nPos.h"
#include "game/nRect.h"
#include "base/nBaseServer.h"
namespace Game
{
namespace nGraphAlgo
{
/// @brief 获取距离
/// @param begin 起点坐标
/// @param pos 到该点的距离
/// @return 距离
inline WORD getDistance(const nPos& begin, const nPos& pos)
{
return (WORD)sqrt( ((begin.x - pos.x) * (begin.x - pos.x)) + ((begin.y - pos.y) * (begin.y - pos.y)) );
}
inline float getDistance(const nPos2D& begin, const nPos2D& pos)
{
return (float)sqrt(( begin.x - pos.x) * (begin.x - pos.x) + (begin.z - pos.z) * (begin.z - pos.z) );
}
inline float getDistance(const nPos3D& begin, const nPos3D& pos)
{
return (float)sqrt( ((begin.x - pos.x) * (begin.x - pos.x)) + ((begin.z - pos.z) * ((begin.z - pos.z))) + ((begin.y - pos.y) * (begin.y - pos.y)) );
}
/// @brief 获取两点之间的近似距离
/// @param begin 起点坐标
/// @param end 终点坐标
/// @return 两点近似距离
inline WORD getSimilarDistance(const nPos& begin, const nPos& end)
{
return std::max(abs(end.x - begin.x), abs(end.y - begin.y));
}
/// @brief 以自身为中心点,获取到另外一个坐标的方向
/// @param begin 起点坐标
/// @param pos 另外一个坐标点
/// @return 方向
inline const int getDirect(const nPos2D& begin, const nPos2D &pos)
{
SWORD dX = (SWORD)(pos.x - begin.x);
SWORD dY = (SWORD)(pos.z - begin.z);
if(dX > 0)
{
dX = 2;
}
else if(dX < 0)
{
dX = 1;
}
if(dY > 0)
{
dY = 2;
}
else if(dY < 0)
{
dY = 1;
}
static BYTE direct[3][3] = {{_DIR_WRONG, _DIR_UP, _DIR_DOWN}, {_DIR_LEFT, _DIR_LEFTUP, _DIR_DOWNLEFT}, {_DIR_RIGHT, _DIR_UPRIGHT, _DIR_RIGHTDOWN}};
return direct[dX][dY];
}
inline const int getDirect(const nPos& begin, const nPos &pos)
{
SWORD dX = pos.x - begin.x;
SWORD dY = pos.y - begin.y;
if(dX > 0)
{
dX = 2;
}
else if(dX < 0)
{
dX = 1;
}
if(dY > 0)
{
dY = 2;
}
else if(dY < 0)
{
dY = 1;
}
static BYTE direct[3][3] = {{_DIR_WRONG, _DIR_UP, _DIR_DOWN}, {_DIR_LEFT, _DIR_LEFTUP, _DIR_DOWNLEFT}, {_DIR_RIGHT, _DIR_UPRIGHT, _DIR_RIGHTDOWN}};
return direct[dX][dY];
#if 0
if(begin.x == pos.x && begin.y > pos.y)
{
return _DIR_UP;
}
else if(begin.x < pos.x && begin.y > pos.y)
{
return _DIR_UPRIGHT;
}
else if(begin.x < pos.x && begin.y == pos.y)
{
return _DIR_RIGHT;
}
else if(begin.x < pos.x && begin.y < pos.y)
{
return _DIR_RIGHTDOWN;
}
else if(begin.x == pos.x && begin.y < pos.y)
{
return _DIR_DOWN;
}
else if(begin.x > pos.x && begin.y < pos.y)
{
return _DIR_DOWNLEFT;
}
else if(begin.x > pos.x && begin.y == pos.y)
{
return _DIR_LEFT;
}
else if(begin.x > pos.x && begin.y > pos.y)
{
return _DIR_LEFTUP;
}
return _DIR_WRONG;
#endif
}
/// @brief 以自身为中心点,获取到另一个坐标的视线方向
/// @param begin 起点坐标
/// @param pos 另外一个坐标点
/// @return 方向
inline const int getLineDirect(const nPos& begin, const nPos& pos)
{
//Bresenham算法,只用了第一步
int deltaX = pos.x - begin.x;
int deltaY = pos.y - begin.y;
int stepX = deltaX < 0 ? -1:1;
int stepY = deltaY < 0 ? -1:1;
deltaX = abs(deltaX);
deltaY = abs(deltaY);
if(deltaY > deltaX) //斜率>1
{
if(deltaX*2 - deltaY >= 0) //决策参数
{
return getDirect(begin, nPos(begin.x + stepX, begin.y + stepY));
}
else
{
return getDirect(begin, nPos(begin.x, begin.y + stepY));
}
}
else //斜率<=1
{
if(deltaY*2 - deltaX >= 0) //决策参数
{
return getDirect(begin, nPos(begin.x + stepX, begin.y + stepY));
}
else
{
return getDirect(begin, nPos(begin.x + stepX, begin.y));
}
}
return _DIR_WRONG;
}
/// @brief Bresenham线段算法
/// @param begin 起点坐标
/// @param end 终点坐标
/// @param len 线段最长长度
/// @return posVec 线段点集
inline void bresenhamLine(const nPos& begin, const nPos& end, const BYTE& len, nPosVector& posVec)
{
bool interchange = false;
WORD deltaX = abs(end.x - begin.x);
WORD deltaY = abs(end.y - begin.y);
if(deltaY > deltaX)
{
WORD temp = deltaX;
deltaX = deltaY;
deltaY = temp;
interchange = true;
}
SWORD sx = end.x > begin.x ? 1 : -1;
SWORD sy = end.y > begin.y ? 1 : -1;
SWORD p = (deltaY<<1) - deltaX;
WORD x = begin.x, y = begin.y;
for(WORD i=0; i<=len; ++i)
{
nPos pos(x, y);
posVec.push_back(pos);
if(p >= 0)
{
if(! interchange)
y += sy;
else
x += sx;
p -= deltaX<<1;
}
if(! interchange)
x += sx;
else
y += sy;
p += deltaY<<1;
}
}
/* 返回顶角在o点,起始边为os,终止边为oe的夹角(单位:弧度)
角度小于pi,返回正值
角度大于pi,返回负值
可以用于求线段之间的夹角
*/
inline SWORD getAngle(const nPos2D &o, const nPos2D &s, const nPos2D &e)
{
double dsx = s.x - o.x;
double dsy = s.z - o.z;
double dex = e.x - o.x;
double dey = e.z - o.z;
double cosfi=dsx*dex+dsy*dey;
double norm=(dsx*dsx+dsy*dsy)*(dex*dex+dey*dey);
cosfi /= sqrt( norm );
double fi = 0;
if (cosfi >= 1.0 )
{
fi = 0;
}
else if (cosfi <= -1.0 )
{
fi = -PI;
}
else
{
fi=acos(cosfi);
if ((dsx*dey - dsy*dex) <= 0)
{
fi = -fi;
}
}
SWORD angle = static_cast<SWORD>(fi * 180 /PI);
return angle;
}
/// 获取两点之间的向量的相对坐标系的弧度
inline float getAngle(float srcX, float srcY, float destX, float destY)
{
float disX = destX - srcX;
float disY = destY - srcY;
float len = sqrt(disX * disX + disY * disY);
if(len == 0) return 0;
float normalX = disX/len;
float normalY = disY/len;
return acos(normalY) * (normalX > 0 ? 1 : -1);
}
inline bool pointInTriangle(const nPos2D &point, const nPos2D &a, const nPos2D &b, const nPos2D &c)
{
// Algorithm from http://www.blackpawn.com/texts/pointinpoly/default.html
float x0 = c.x - a.x;
float z0 = c.z - a.z;
float x1 = b.x - a.x;
float z1 = b.z - a.z;
float x2 = point.x - a.x;
float z2 = point.z - a.z;
float dot00 = x0 * x0 + z0 * z0;
float dot01 = x0 * x1 + z0 * z1;
float dot02 = x0 * x2 + z0 * z2;
float dot11 = x1 * x1 + z1 * z1;
float dot12 = x1 * x2 + z1 * z2;
float denominator = dot00 * dot11 - dot01 * dot01;
if (!denominator)
// Triangle is zero-area. Treat querz point as not being inside.
return false;
// Compute
float inverseDenominator = 1.0f / denominator;
float u = (dot11 * dot02 - dot01 * dot12) * inverseDenominator;
float v = (dot00 * dot12 - dot01 * dot02) * inverseDenominator;
// 允许的误差
const float tolerance = 0.0000;
return (u >= 0.0f - tolerance) && (v >= 0.0f - tolerance) && (u + v <= 1.0f + tolerance);
}
inline bool pointInRect(const nPos2D &pos, const nRect rect)
{
return pos.x >= rect.pos.x && pos.x <= rect.pos.x + rect.size.x &&
pos.z >= rect.pos.z && pos.z <= rect.pos.z + rect.size.z;
}
enum eSide
{
eSide_None,
eSide_Left,
eSide_Right,
};
inline BYTE classifyPoint(const nPos2D &pos, const nPos2D &lineStart, const nPos2D &lineEnd)
{
float v = (pos.x - lineStart.x) * (lineEnd.z - lineStart.z) - (lineEnd.x - lineStart.x) * (pos.z - lineStart.z);
if(v > 0){
return eSide_Right;
}
else if(v < 0){
return eSide_Left;
}
return eSide_None;
}
/*计算客户端需要的向量
X和Z轴的mol*/
inline const nPos2D getDir(const nPos2D& begin, const nPos2D& pos)
{
nPos2D dir;
dir.x = pos.x - begin.x;
dir.z = pos.z - begin.z;
float absDirX = fabs(dir.x);
float absDirZ = fabs(dir.z);
float max;
if(absDirX > absDirZ){
max = absDirX;
}
else{
max = absDirZ;
}
dir.x = dir.x/ceil(max);
dir.z = dir.z/ceil(max);
return dir;
}
inline bool getDir(const nPos3D& start, const nPos3D& end, nPos3D *direct)
{
float distance = getDistance(start, end);
if(distance == 0){
return false;
}
direct->x = (end.x - start.x) / distance;
direct->y = (end.y - start.y) / distance;
direct->z = (end.z - start.z) / distance;
return true;
}
inline bool isRectIntersect(const nRect &a, const nRect &b)
{
float minx = std::max(a.pos.x, b.pos.x);
float minz = std::max(a.pos.z, b.pos.z);
float maxx = std::min(a.pos.x + a.size.x, b.pos.x + b.size.x);
float maxz = std::min(a.pos.z + a.size.z, b.pos.z + b.size.z);
if(minx >= maxx || minz >= maxz) {
return false;
}
else {
return true;
}
}
inline void getRectByLine(const nPos2D &lineStart, const nPos2D &lineEnd, nRect *dest)
{
float minx = std::min(lineStart.x, lineEnd.x);
float minz = std::min(lineStart.z, lineEnd.z);
float maxx = std::max(lineStart.x, lineEnd.x);
float maxz = std::max(lineStart.z, lineEnd.z);
dest->pos.x = minx;
dest->pos.z = minz;
dest->size.x = maxx - minx;
dest->size.z = maxz - minz;
/// 加一个修正,防止完全水平或者垂直的线的宽度是0,造成判断错误
if(dest->size.x == 0) {
dest->size.x = 0.0001;
}
if(dest->size.z == 0) {
dest->size.z = 0.0001;
}
return;
}
inline double mul(nPos2D a, nPos2D b, nPos2D c)
{
nPos2D AB, AC;
AB.x = b.x - a.x;
AB.z = b.z - a.z;
AC.x = c.x - a.x;
AC.z = c.z - a.z;
return (AB.x * AC.z - AB.z * AC.x);
}
inline bool isLineIntersect(const nPos2D &line1Start, const nPos2D &line1End, const nPos2D &line2Start, const nPos2D &line2End)
{
// 快速排斥判断
nRect line1Rect;
getRectByLine(line1Start, line1End, &line1Rect);
nRect line2Rect;
getRectByLine(line2Start, line2End, &line2Rect);
if(isRectIntersect(line1Rect, line2Rect) == false) {
return false;
}
// 跨立判断
double a = mul(line2Start, line1Start, line2End) * mul(line2Start, line1End, line2End);
double b = mul(line1Start, line2Start, line1End) * mul(line1Start, line2End, line1End);
if( a <= 0.1 && b <= 0.1) {
return true;
}
else {
return false;
}
}
/// brief 取得两线段交点,需要先确认两条线段相交,否则取到的点就是错误的
inline void getLineIntersectPos(const nPos2D &aStart, const nPos2D &aEnd, const nPos2D &bStart, const nPos2D &bEnd, nPos2D *dest)
{
*dest = aStart;
double t = ((aStart.x-bStart.x)*(bStart.z-bEnd.z)-(aStart.z-bStart.z)*(bStart.x-bEnd.x)) / ((aStart.x-aEnd.x)*(bStart.z-bEnd.z)-(aStart.z-aEnd.z)*(bStart.x-bEnd.x));
dest->x += (aEnd.x - aStart.x) * t;
dest->z += (aEnd.z - aStart.z) * t;
}
inline bool isLineIntersectRect(const nPos2D &startPos, const nPos2D &endPos, const nRect &rect)
{
if(pointInRect(startPos, rect) == true || pointInRect(endPos, rect) == true) {
return true;
}
nPos2D rectSideStartPos, rectSideEndPos;
rect.getTopLine(&rectSideStartPos, &rectSideEndPos);
if(isLineIntersect(startPos, endPos, rectSideStartPos, rectSideEndPos) == true) {
return true;
}
rect.getBottomLine(&rectSideStartPos, &rectSideEndPos);
if(isLineIntersect(startPos, endPos, rectSideStartPos, rectSideEndPos) == true) {
return true;
}
rect.getLeftLine(&rectSideStartPos, &rectSideEndPos);
if(isLineIntersect(startPos, endPos, rectSideStartPos, rectSideEndPos) == true) {
return true;
}
rect.getRightLine(&rectSideStartPos, &rectSideEndPos);
if(isLineIntersect(startPos, endPos, rectSideStartPos, rectSideEndPos) == true) {
return true;
}
return false;
}
inline bool isLineIntersectTriangle(const nPos2D &startPos, const nPos2D &endPos, const nPos2D &vertexA, const nPos2D &vertexB, const nPos2D &vertexC) {
if(pointInTriangle(startPos, vertexA, vertexB, vertexC) == true) {
return true;
}
if(pointInTriangle(endPos, vertexA, vertexB, vertexC) == true) {
return true;
}
if(isLineIntersect(startPos, endPos, vertexA, vertexB) == true) {
return true;
}
if(isLineIntersect(startPos, endPos, vertexB, vertexC) == true) {
return true;
}
if(isLineIntersect(startPos, endPos, vertexC, vertexA) == true) {
return true;
}
return true;
}
#if 0
/// @ brief 返回以pos为中心,dstPos的角度(0 - 360)
inline const double getAngle(const nPos2D &pos, const nPos2D &dstPos)
{
double dRotateAngle = atan2(fabs(pos.x-dstPos.x),fabs(pos.z-dstPos.z));
if (dstPos.x >= pos.x)
{
if (dstPos.z >= pos.z)
{
}
else
{
dRotateAngle = PI - dRotateAngle;
}
}
else
{
if (dstPos.z >= pos.z)
{
dRotateAngle = 2 * PI - dRotateAngle;
}
else
{
dRotateAngle = PI + dRotateAngle;
}
}
dRotateAngle = dRotateAngle * 180 / PI;
return dRotateAngle;
}
/// @ brief 以pos为中心,取得dstPos的朝向,分别有8个朝向
inline const BYTE getDirectArea(const nPos2D &pos, const nPos2D &dstPos)
{
double angle = getAngle(pos, dstPos);
return static_cast<BYTE>(angle / 45);
}
/// @ brief 以pos为中心,取得与dst朝向相反的朝向
inline const BYTE getAntiDirectArea(const nPos2D &pos, const nPos2D &dstPos)
{
BYTE directArea = getDirectArea(pos, dstPos);
directArea += 4;
directArea %= 8;
return directArea;
}
enum eDirect {
eDirect_Min = 0,
eDirect_Max = 7,
eDirect_Count
};
inline void getDirectVector(const BYTE area, nPos2D *vector)
{
assert_debug(area <= eDirect_Max, "错误的朝向区域");
static float directVector[eDirect_Count][2] = {
{0.5, 1.0},
{1.0, 0.5},
{1.0, -0.5},
{0.5, -1.0},
{-0.5, -1.0},
{-1.0, -0.5},
{-1.0, 0.5},
{-0.5, 1.0}
};
vector->x = directVector[area][0];
vector->z = directVector[area][1];
vector->normalise();
}
/// @ brief 取得以pos为中心,area方向,len距离的一个点
inline void getDirectPos(const nPos2D &pos, const float len, const BYTE area, nPos2D *dst)
{
getDirectVector(area, dst);
dst->x *= len;
dst->z *= len;
dst->x += pos.x;
dst->z += pos.z;
}
/// @ brief 取得以pos为中心,与dstPos朝向相反的(按areaRemote修正朝向),len距离的点
inline void getAntiDirectPos(const nPos2D &pos, const nPos2D &dstPos, const float len, const int areaRemote, nPos2D *dst)
{
int antiDirectArea = getAntiDirectArea(pos, dstPos) + areaRemote;
if(antiDirectArea >= 0) {
antiDirectArea %= eDirect_Count;
}
else {
antiDirectArea = eDirect_Count - (abs(antiDirectArea) % eDirect_Count);
}
getDirectPos(pos, len, antiDirectArea, dst);
}
#endif
enum eDirect
{
eDirect_Min = 0,
eDirect_Right = 0,
eDirect_RightDown = 1,
eDirect_Down = 2,
eDirect_LeftDown = 3,
eDirect_Left = 4,
eDirect_LeftUp = 5,
eDirect_Up = 6,
eDirect_RightUp = 7,
eDirect_Max = 7,
eDirect_Count = 8
};
inline const float getAngle(const nPos2D& start, const nPos2D& end)
{
//const float PI = 3.141592653;
float x = end.x - start.x;
float y = end.z - start.z;
float hypotenuse = sqrt(x * x + y * y);
float cos = x / hypotenuse;
float radian = acos(cos);
float angle = 180 / (PI / radian);
if(y < 0)
{
angle = 360 - angle;
}
else if(y == 0 && x < 0)
{
angle = 180;
}
return angle;
}
inline const DWORD getDirectInEight(const nPos2D& start, const nPos2D& end)
{
float angle = static_cast<DWORD>(getAngle(start, end));
angle += 22.5;
return static_cast<DWORD>((angle > 359 ? angle - 359 : angle) / 45);
}
inline const DWORD getAntiDirectInEight(const nPos2D& start, const nPos2D& end)
{
return (getDirectInEight(start, end) + 4) % 8;
}
inline void getDirectPos(const nPos2D& start, const DWORD direct, const float len, nPos2D *dest)
{
nPos2D vector;
switch(direct)
{
case eDirect_Right:
{
vector.x = 1;
vector.z = 0;
}
break;
case eDirect_RightDown:
{
vector.x = 1;
vector.z = 1;
}
break;
case eDirect_Down:
{
vector.x = 0;
vector.z = 1;
}
break;
case eDirect_LeftDown:
{
vector.x = -1;
vector.z = 1;
}
break;
case eDirect_Left:
{
vector.x = -1;
vector.z = 0;
}
break;
case eDirect_LeftUp:
{
vector.x = -1;
vector.z = -1;
}
break;
case eDirect_Up:
{
vector.x = 0;
vector.z = -1;
}
break;
case eDirect_RightUp:
{
vector.x = 1;
vector.z = -1;
}
break;
}
vector.normalise();
dest->x = start.x + vector.x * len;
dest->z = start.z + vector.z * len;
}
inline void getAntiDirectPos(const nPos2D& start, const nPos2D& end, const float len, const int off, nPos2D *dest)
{
int AntiDirect = getAntiDirectInEight(start, end);
AntiDirect = (AntiDirect + off) % 8;
getDirectPos(start, AntiDirect, len, dest);
}
inline float checkProjectInLine(const nPos2D &startPos, const nPos2D &endPos, const nPos2D &checkPos )
{
nPos2D startLine((checkPos.x - startPos.x), (checkPos.z - startPos.z));
nPos2D endLine((endPos.x - startPos.x), (endPos.z - startPos.z));
float v = (startLine.x * endLine.x + startLine.z * endLine.z)/(endLine.x * endLine.x + endLine.z * endLine.z);
if(v >= 0 && v <= 1){
nPos2D startToProjectLine(endLine.x * v, endLine.z * v);
v = startToProjectLine.normalise()/endLine.normalise();
}
return v;
}
inline void rotationToVector(float x, float y, float z, float w, float& outx, float& outy, float& outz)
{
float unitZ_x = 0.0f;
float unitZ_y = 0.0f;
float unitZ_z = 1.0f;
float uv_x = y * unitZ_z - z * unitZ_y;
float uv_y = z * unitZ_x - x * unitZ_z;
float uv_z = x * unitZ_y - y * unitZ_x;
float uuv_x = y * uv_z - z * uv_y;
float uuv_y = z * uv_x - x * uv_z;
float uuv_z = x * uv_y - y * uv_x;
uv_x *= 2.0f * w;
uv_y *= 2.0f * w;
uv_z *= 2.0f * w;
uuv_x *= 2.0f;
uuv_y *= 2.0f;
uuv_z *= 2.0f;
outx = unitZ_x + uv_x + uuv_x;
outy = unitZ_y + uv_y + uuv_y;
outz = unitZ_z + uv_z + uuv_z;
}
/// 正角度为顺时针旋转
inline void rotateVector2D(const nPos2D& src, const float angle, nPos2D* dest)
{
float radian = angle * PI / 180.0f;
nPos2D srcVector = src; // 这么做是为了防止src和dest是一个对象
dest->x = srcVector.x * cos(radian) - srcVector.z * sin(radian);
dest->z = srcVector.z * cos(radian) + srcVector.x * sin(radian);
}
};
};
#endif
| [
"[email protected]"
] | |
62234b0e29cfe92bfa61a932feb128d1b56b37d8 | 9b05688b2266fed3efac65fa60b045e71b12649b | /src/sketchpad.hpp | 0f373f4b7f2b3bd2cc6a557e329967ddca7f8024 | [
"MIT"
] | permissive | rainstormstudio/AsciiEditor | 5c41f42afbc039dc261ddb5eadcaf89e9eb09a73 | ea6a089cd1edf087cb086295ad6268af0ed37c65 | refs/heads/master | 2022-12-29T19:17:41.712871 | 2020-10-11T15:01:21 | 2020-10-11T15:01:21 | 285,425,174 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,366 | hpp | #ifndef SKETCHPAD_HPP
#define SKETCHPAD_HPP
#include <vector>
#include "panel.hpp"
#include "charpad.hpp"
#include "palettepad.hpp"
#include <fstream>
struct Cpixel {
Uint8 ch;
Uint8 r, g, b, a;
Uint8 br, bg, bb, ba;
bool operator==(const Cpixel& other) {
return (ch == other.ch
&& r == other.r
&& g == other.g
&& b == other.b
&& a == other.a
&& br == other.br
&& bg == other.bg
&& ba == other.ba);
}
};
class Sketchpad : public Panel {
Charpad* charpad;
Palettepad* palettepad;
std::vector<std::vector<Cpixel>> cpixels;
bool brushDown;
void fill(Cpixel prevColor, Cpixel newColor, int x, int y);
public:
Sketchpad(Application* app, unsigned int top, unsigned int left, unsigned int width, unsigned int height, Charpad* charpad, Palettepad* palettepad);
void clear();
void drawPoint();
void drawPoint(Cpixel info, int x, int y);
void fillArea();
void fillArea(Cpixel info, int x, int y);
void update() override;
void render() override;
void saveToFile(std::string filename);
void loadFromFile(std::string filename);
void setBrush(bool down);
bool getBrush() const;
int getCursorX() const;
int getCursorY() const;
Cpixel getCellInfo(int x, int y) const;
};
#endif
| [
"[email protected]"
] | |
60fa08e6725b5430547e72e326b589094441a5eb | 33f34a090b797d0d90abb90b041054582ccc9edc | /run/Ccall/sweeping_call.cpp | b89e15d0481efc67ea2a075a8a4d73632a4f63b0 | [] | no_license | gviejo/PST_INSERM | bebeb8a2eb5dc2fa1262d2450d0221e848f54540 | 2a95194fdb640783bf09aec214839c90e8501a80 | refs/heads/master | 2020-04-03T20:56:15.882331 | 2017-04-12T04:02:22 | 2017-04-12T04:02:22 | 56,002,874 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,303 | cpp | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <iomanip>
using namespace std;
void alignToMedian(double *daArray, int iSize) {
double* dpSorted = new double[iSize];
for (int i = 0; i < iSize; ++i) dpSorted[i] = daArray[i];
for (int i = iSize - 1; i > 0; --i) {
for (int j = 0; j < i; ++j) {
if (dpSorted[j] > dpSorted[j+1]) {
double dTemp = dpSorted[j];
dpSorted[j] = dpSorted[j+1];
dpSorted[j+1] = dTemp;
}
}
}
double dMedian = dpSorted[(iSize/2)-1]+(dpSorted[iSize/2]-dpSorted[(iSize/2)-1])/2.0;
for (int i=0;i<iSize;i++) {daArray[i] = daArray[i]-dMedian;dpSorted[i] = dpSorted[i]-dMedian;}
double dQ1 = dpSorted[(iSize/4)-1]+((dpSorted[(iSize/4)]-dpSorted[(iSize/4)-1])/2.0);
double dQ3 = dpSorted[(iSize/4)*3-1]+((dpSorted[(iSize/4)*3+1]-dpSorted[(iSize/4)*3-1])/2.0);
// std::cout << dpSorted[((iSize/4)*3)-2] << std::endl;
// std::cout << dpSorted[((iSize/4)*3)-1] << std::endl;
// // std::cout << dQ3 << std::endl;
// std::cout << dpSorted[(iSize/4)*3] << std::endl;
// std::cout << dpSorted[(iSize/4)*3+1] << std::endl;
delete [] dpSorted;
for (int i=0;i<iSize;i++) daArray[i] = daArray[i]/(dQ3-dQ1);
}
void softmax(double *p, double *v, double b) {
double sum = 0.0;
double tmp[4];
double max_de_sum = -10000.0;
//summing mb + mf
for (int i=0;i<4;i++) {
if (v[i] > max_de_sum) {
max_de_sum = v[i];
}
}
for (int i=0;i<4;i++) {
tmp[i] = exp((v[i]-max_de_sum)*b);
sum+=tmp[i];
}
for (int i=0;i<4;i++) {
p[i] = tmp[i]/sum;
}
for (int i=0;i<4;i++) {
if (p[i] == 0) {
sum = 0.0;
for (int i=0;i<4;i++) {
p[i]+=1e-8;
sum+=p[i];
}
for (int i=0;i<4;i++) {
p[i]/=sum;
}
}
}
}
double sigmoide(double Hb, double Hf, double n, double i, double t, double g) {
double x = 2.0 * -log2(0.25) - Hb - Hf;
// std::cout << pow((n-i),t) << std::endl;
double tmp = 1.0/(1.0+(pow((n-i),t)*exp(-x*g)));
// std::cout << " n=" << n << " i=" << i << "Hb = "<< Hb << ", Hf = " << Hf << " x=" << x << " p(A)=" << tmp << " threshold = " << t << " gain = " << g << std::endl;
// std::cout << tmp << " ";
return tmp;
// return 1.0/(1.0+((n-i)*t)*exp(-x*g));
}
void fusion(double *p_a, double *mb, double *mf, double beta) {
double tmp[4];
int tmp2[4];
double sum = 0.0;
double ninf = 0;
double mbplusmf[4];
double max_de_sum = -10000.0;
//summing mb + mf
for (int i=0;i<4;i++) {
mbplusmf[i] = mb[i] + mf[i];
if (mbplusmf[i] > max_de_sum) {
max_de_sum = mbplusmf[i];
}
}
for (int i=0;i<4;i++) {
tmp[i] = exp((mbplusmf[i]-max_de_sum)*beta);
sum+=tmp[i];
}
for (int i=0;i<4;i++) {
p_a[i] = tmp[i]/sum;
}
for (int i=0;i<4;i++) {
if (p_a[i] == 0) {
sum = 0.0;
for (int i=0;i<4;i++) {
p_a[i]+=1e-8;
sum+=p_a[i];
}
for (int i=0;i<4;i++) {
p_a[i]/=sum;
}
}
}
return;
}
double entropy(double *p) {
double tmp = 0.0;
for (int i=0;i<4;i++) {tmp+=p[i]*log2(p[i]);}
return -tmp;
}
double sum_prod(double *a, double *b, int n) {
double tmp = 0.0;
for (int i=0;i<n;i++) {
tmp+=(a[i]*b[i]);
}
return tmp;
}
// void sferes_call(double * fit, const char* data_dir, double alpha_, double beta_, double noise_, double length_, double gain_, double threshold_, double gamma_)
void sferes_call(double * fit, const int N, const char* data_dir, double alpha_, double beta_, double noise_, double length_, double gain_, double threshold_, double gamma_, double sigma_, double kappa_, double shift_)
{
// /////////////////
// parameters
double alpha=0.0+alpha_*(1.0-0.0);
double beta=0.0+beta_*(100.0-0.0);
double noise=0.0+noise_*(0.1-0.0);
int length=1+(10-1)*length_;
double gain=0.00001+(10000.0-0.00001)*gain_;
double threshold=0.0+(20.0-0.0)*threshold_;
double sigma=0.0+(20.0-0.0)*sigma_;
double gamma=0.0+(100.0-0.0)*gamma_;
double kappa=0.0+(1.0-0.0)*kappa_;
double shift=0.0+(0.999999-0.0)*shift_;
// std::cout << "alpha : " << alpha << std::endl;
// std::cout << "beta : " << beta << std::endl;
// std::cout << "noise : " << noise << std::endl;
// std::cout << "length : " << length << std::endl;
// std::cout << "gain : " << gain << std::endl;
// std::cout << "threshold : " << threshold << std::endl;
// std::cout << "sigma : " << sigma << std::endl;
// std::cout << "gamma : " << gamma << std::endl;
// std::cout << "kappa : " << kappa << std::endl;
// std::cout << "shift : " << shift << std::endl;
int nb_trials = N;
int n_state = 1;
int n_action = 4;
int n_r = 2;
int problem;
double max_entropy = -log2(0.25);
///////////////////
int sari [N][5];
double mean_rt [30][3];
double values [N]; // action probabilities according to subject
double rt [N]; // rt du model
double p_a_mf [n_action];
double p_a_mb [n_action];
double spatial_biases [n_action];
const char* _data_dir = data_dir;
std::string file1 = _data_dir;
std::string file2 = _data_dir;
file1.append(".txt");
file2.append("_rt_reg.txt");
std::ifstream data_file1(file1.c_str());
string line;
if (data_file1.is_open())
{
for (int i=0;i<N;i++)
{
getline (data_file1,line);
stringstream stream(line);
std::vector<double> values_(
(std::istream_iterator<double>(stream)),
(std::istream_iterator<double>()));
sari[i][0] = (int)values_[3]; // reward
sari[i][1] = (int)values_[4]; // problem
sari[i][2] = (int)values_[5]; // action
sari[i][3] = (int)values_[9]; // index
sari[i][4] = (int)values_[2]; // phase
}
data_file1.close();
}
std::ifstream data_file2(file2.c_str());
if (data_file2.is_open())
{
for (int i=0;i<30;i++)
{
getline (data_file2,line);
stringstream stream(line);
std::vector<double> values_(
(std::istream_iterator<double>(stream)),
(std::istream_iterator<double>()));
for (int j=0;j<3;j++) {
mean_rt[i][j] = values_[j];
}
}
data_file2.close();
}
problem = sari[0][1];
double p_a [length][n_action];
double p_r_a [length][n_action][n_r];
double p [n_action][2];
double values_mf [n_action];
double values_mb [n_action];
double tmp [n_action][2];
double p_a_r [n_action][2];
double reward = 0.0;
double p_r [2];
int n_element = 0;
int s, a, r;
double Hf = max_entropy;
double Hb = max_entropy;
for (int m=0;m<n_action;m++) {
values_mf[m] = 0.0;
spatial_biases[m] = 1./n_action;
}
for (int i=0;i<nb_trials;i++)
// for (int i=0;i<22;i++)
{
if (sari[i][4]-sari[i-1][4] < 0.0) {
// START BLOC //
problem = sari[i][1];
n_element = 0;
// // RESET Q-LEARNING SPATIAL BIASES AND REWARD SHIFT
// double summ = 0.0;
// for (int m=0;m<n_action;m++) { // normalise spatial bias
// summ+=spatial_biases[m];
// }
// for (int m=0;m<n_action;m++) {
// values_mf[m] = 0.0;
// values_mf[m] = spatial_biases[m]/summ;
// std::cout << spatial_biases[m] << " " ;
// }
// std::cout << std::endl;
// shift bias
// for (int m=0;m<n_action;m++) {
// if (m == sari[i-1][2]-1) {
// values_mf[m] *= (1.0-shift);
// } else {
// values_mf[m] *= (shift/3.);
// }
// }
// spatial biases update
// spatial_biases[sari[i][2]-1] += 1.0;
}
// START TRIAL //
// COMPUTE VALUE
a = sari[i][2]-1;
r = sari[i][0];
// QLEARNING CALL
softmax(p_a_mf, values_mf, gamma);
double Hf = 0.0;
for (int n=0;n<n_action;n++){
Hf-=p_a_mf[n]*log2(p_a_mf[n]);
}
// BAYESIAN CALL
int nb_inferences = 0;
double p_decision [n_element+1];
double p_retrieval [n_element+1];
double p_ak [n_element+1];
double reaction [n_element+1];
double values_net [n_action];
double p_a_final [n_action];
// NO SWEEPING
if ((sari[i][4] == 1) || (i == 0) || (sari[i][4]-sari[i-1][4] < 0.0)) {
for (int m=0;m<n_action;m++) {
p[m][0] = 1./(n_action*n_r);
p[m][1] = 1./(n_action*n_r);
values_mb[m] = 1./n_action;
} // fill with uniform
Hb = max_entropy;
// std::cout << " NO SWEEPING" << std::endl;
}
// for (int x =0;x<4;x++) {
// std::cout << values_mb[x] << " ";
// }
// std::cout<<std::endl;
// START
// std::cout << "Hb " << Hb << std::endl;
// std::cout << "Hf " << Hf << std::endl;
p_decision[0] = sigmoide(Hb, Hf, n_element, nb_inferences, threshold, gain);
// std::cout << p_decision[0] << std::endl;
p_retrieval[0] = 1.0-p_decision[0];
fusion(p_a_final, values_mb, values_mf, beta);
p_ak[0] = p_a_final[a];
reaction[0] = entropy(p_a_final);
// std::cout << 0 << " p_ak=" << p_ak[0] << " p_decision=" << p_decision[0] << "p_retrieval=" << p_retrieval[0] << std::endl;
// std::cout << "mf= ";
// for (int x=0;x<4;x++) {
// std::cout << values_mf[x] << " ";
// }
// std::cout << std::endl;
// std::cout << "mb = ";
// for (int x =0;x<4;x++) {
// std::cout << values_mb[x] << " ";
// }
// std::cout<<std::endl;
for (int k=0;k<n_element;k++) {
// INFERENCE
double sum = 0.0;
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p[m][o] += (p_a[k][m] * p_r_a[k][m][o]);
sum+=p[m][o];
}
}
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
tmp[m][o] = (p[m][o]/sum);
}
}
nb_inferences+=1;
// // EVALUATION
sum = 0.0;
for (int o=0;o<n_r;o++) {
p_r[o] = 0.0;
}
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p_r[o]+=tmp[m][o];
}
}
sum = 0.0;
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p_a_r[m][o] = tmp[m][o]/p_r[o];
}
values_mb[m] = p_a_r[m][1]/p_a_r[m][0];
sum+=values_mb[m];
}
for(int m=0;m<n_action;m++) {
p_a_mb[m] = values_mb[m]/sum;
}
Hb = entropy(p_a_mb);
// FUSION
fusion(p_a_final, values_mb, values_mf, beta);
// std::cout << "mb = ";
// for (int x =0;x<4;x++) {
// std::cout << values_mb[x] << " ";
// }
// std::cout<<std::endl;
p_ak[k+1] = p_a_final[a];
double N = k+2.0;
reaction[k+1] = pow(log2(N), sigma) + entropy(p_a_final);
// SIGMOIDE
double pA = sigmoide(Hb, Hf, n_element, nb_inferences, threshold, gain);
// std::cout << pA << std::endl;
p_decision[k+1] = pA*p_retrieval[k];
p_retrieval[k+1] = (1.0-pA)*p_retrieval[k];
// std::cout << k+1 << " p_ak=" << p_ak[k+1] << " p_decision=" << p_decision[k+1] << "p_retrieval=" << p_retrieval[k+1] << std::endl;
}
values[i] = log(sum_prod(p_ak, p_decision, n_element+1));
// for (int k=0;k<n_element+1;k++) {
// std::cout << p_decision[k] << " ";
// }
// std::cout << std::endl;
// for (int k=0;k<n_element+1;k++) {
// std::cout << p_ak[k] << " ";
// }
// std::cout << std::endl;
// std::cout << values[i] << std::endl;
// std::cout << std::endl;
double val = sum_prod(p_ak, p_decision, n_element+1);
rt[i] = sum_prod(reaction, p_decision, n_element+1);
// std::cout << rt[i] << " ";
// UPDATE MEMORY
for (int k=length-1;k>0;k--) {
for (int m=0;m<n_action;m++) {
p_a[k][m] = p_a[k-1][m]*(1.0-noise)+noise*(1.0/n_action);
for (int o=0;o<n_r;o++) {
p_r_a[k][m][o] = p_r_a[k-1][m][o]*(1.0-noise)+noise*0.5;
}
}
}
if (n_element < length) n_element+=1;
for (int m=0;m<n_action;m++) {
p_a[0][m] = 1./n_action;
for (int o=0;o<n_r;o++) {
p_r_a[0][m][o] = 0.5;
}
}
for (int m=0;m<n_action;m++) {
p_a[0][m] = 0.0;
}
p_a[0][a] = 1.0;
p_r_a[0][a][(r-1)*(r-1)] = 0.0;
p_r_a[0][a][r] = 1.0;
// // MODEL FREE
if (r == 0) {
reward = -1.0;
} else if (r == 1) {
reward = 1.0;
}
double max_next = 0;
for (int m=0;m<n_action;m++) {
if (values_mf[m]>max_next) {
max_next = values_mf[m];
}
}
double delta = reward + shift*max_next - values_mf[a];
values_mf[a]+=(alpha*delta);
for (int m=0;m<n_action;m++) {
if (m != a) {
values_mf[m] += (1.0-kappa)*(0.0-values_mf[m]);
}
}
// SWEEPING
if ((sari[i][4] == 0) && (r==0)) {
for (int m=0;m<n_action;m++) {
p[m][0] = 1./(n_action*n_r);
p[m][1] = 1./(n_action*n_r);
values_mb[m] = 1./n_action;
} // fill with uniform
Hb = max_entropy;
nb_inferences = 0;
for (int k=0;k<n_element;k++) {
// INFERENCE
double sum = 0.0;
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p[m][o] += (p_a[k][m] * p_r_a[k][m][o]);
sum+=p[m][o];
}
}
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
tmp[m][o] = (p[m][o]/sum);
}
}
}
nb_inferences+=1;
// // EVALUATION
double sum = 0.0;
for (int o=0;o<n_r;o++) {
p_r[o] = 0.0;
}
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p_r[o]+=tmp[m][o];
}
}
sum = 0.0;
for (int m=0;m<n_action;m++) {
for (int o=0;o<n_r;o++) {
p_a_r[m][o] = tmp[m][o]/p_r[o];
}
values_mb[m] = p_a_r[m][1]/p_a_r[m][0];
sum+=values_mb[m];
}
for(int m=0;m<n_action;m++) {
p_a_mb[m] = values_mb[m]/sum;
}
Hb = entropy(p_a_mb);
// std::cout << " INSIDE SWEE " << Hb << std::endl;
// std::cout << "pmb apres sweep = ";
// for (int x =0;x<4;x++) {
// std::cout << values_mb[x] << " ";
// }
// std::cout<<std::endl;
}
// std::cout << std::endl;
}
// ALIGN TO MEDIAN
alignToMedian(rt, N);
// REARRANGE TO REPRESENTATIVE STEPS
double mean_model [30];
double sum_tmp [30];
for (int i=0;i<30;i++) {
mean_model[i] = 0;
sum_tmp[i] = 0;
}
for (int i=0;i<N;i++) {
if (sari[i][3] >= 0.0) {
mean_model[sari[i][3]] += rt[i];
sum_tmp[sari[i][3]] += 1.0;
}
fit[0] += values[i];
}
for (int i=0;i<30;i++) {
mean_model[i] = mean_model[i]/sum_tmp[i];
// std::cout << i << " " << mean_model[i] << " " << std::endl;
fit[1] -= pow(mean_model[i] - mean_rt[i][1], 2.0);
}
if (std::isnan(fit[0]) || std::isinf(fit[0]) || std::isinf(fit[1]) || std::isnan(fit[1]) || fit[0] < -1e+30 || fit[1] < -1e+30) {
fit[0]=-1e+15;
fit[1]=-1e+15;
return;
}
}
| [
"[email protected]"
] | |
398715b2378afd20a9fc0fa8086c8bf3fe4fa5c1 | 06dfcdaf0c432e4488f162f7b6d4a583a450600a | /알고리즘/mid_quick_sort.cpp | 93c2488544dba23a871cc3d8628bbca4d2baceec | [] | no_license | sumniy/algorithm_study | 3941534a323e93cfca370f5d6614d6582ba10348 | a02faeb4e208764849414ae7f355855808221311 | refs/heads/master | 2020-12-12T04:13:07.798260 | 2020-10-16T15:20:46 | 2020-10-16T15:20:46 | 234,039,807 | 0 | 0 | null | 2020-05-06T04:34:47 | 2020-01-15T08:58:27 | C++ | UTF-8 | C++ | false | false | 1,135 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
void QuickSort(vector<int> &data, int start, int end)
{
if (start >= end)
{
return;
}
int mid = (start + end) / 2;
int pivot = data[mid];
swap(data[start], data[mid]);
int i = start + 1, j = end;
int temp;
while (i <= j)
{
while (i <= end && data[i] <= pivot)
{
++i;
}
while (j > start && data[j] >= pivot)
{
--j;
}
if (i > j)
{
swap(data[start], data[j]);
}
else
{
swap(data[i], data[j]);
}
}
QuickSort(data, start, j - 1);
QuickSort(data, j + 1, end);
}
const int INPUT_SIZE = 10000;
const int MAX_ELEM = 999999;
#define endl "\n"
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<int> array;
srand(11);
for (int i = 0; i < INPUT_SIZE; i++)
{
array.push_back(rand() % MAX_ELEM);
}
for (auto i : array)
cout << i << " ";
cout << endl;
QuickSort(array, 0, array.size() - 1);
for (auto i : array)
cout << i << " ";
cout << endl;
} | [
"[email protected]"
] | |
80e7d41c3a7c1b9b04cd1a124df82e60b9830c06 | 7910ee578a82b51fa72b1b9b98c7fb0262cee795 | /TRekt_3D/source/sound.cpp | 446e859b48728caa33b8da28d5afaad62453ff5d | [] | no_license | ihaveamac/TRekt_3D | 7c6400715c8e04090b1e947a5237d3f4c4dd7bf3 | 5eedbd815616ffb14d9d7fbd8591fade7409b50a | refs/heads/master | 2021-01-20T10:51:23.916921 | 2017-08-27T10:49:04 | 2017-08-27T10:49:04 | 101,653,887 | 2 | 0 | null | 2017-08-28T14:51:32 | 2017-08-28T14:51:32 | null | UTF-8 | C++ | false | false | 2,520 | cpp | // Cheuble's sound class
#include "sound.h"
sound::sound(string path, int channel, bool toloop)
{
song1 = loadWav(path, channel, toloop);
}
sound::~sound()
{
song1.dataSize =0;
song1.data = NULL;
song1.waveBuf.data_vaddr = 0;
song1.waveBuf.nsamples = 0;
song1.waveBuf.looping = false;
song1.waveBuf.status = 0;
ndspChnWaveBufClear(song1.chnl);
}
void sound::play()
{
DSP_FlushDataCache(song1.data, song1.dataSize);
ndspChnWaveBufAdd(song1.chnl, &song1.waveBuf);
}
void sound::stop()
{
ndspChnWaveBufClear(song1.chnl);
ndspChnWaveBufClear(song2.chnl);
}
song sound::loadWav(std::string path,int channel,bool toloop)
{
song snd;
u32 sampleRate;
u16 channels;
u16 bitsPerSample;
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
ndspSetOutputCount(2); // Num of buffers
// Reading wav file
FILE* fp = fopen(path.c_str(), "rb");
if (!fp)
{
printf("Could not open the example.wav file.\n");
}
char signature[4];
fread(signature, 1, 4, fp);
if (signature[0] != 'R' &&
signature[1] != 'I' &&
signature[2] != 'F' &&
signature[3] != 'F')
{
printf("Wrong file format.\n");
fclose(fp);
}
fseek(fp, 0, SEEK_END);
snd.dataSize = ftell(fp);
fseek(fp, 22, SEEK_SET);
fread(&channels, 2, 1, fp);
fseek(fp, 24, SEEK_SET);
fread(&sampleRate, 4, 1, fp);
fseek(fp, 34, SEEK_SET);
fread(&bitsPerSample, 2, 1, fp);
if (snd.dataSize == 0 || (channels != 1 && channels != 2) ||
(bitsPerSample != 8 && bitsPerSample != 16))
{
printf("Corrupted wav file.\n");
fclose(fp);
}
// Allocating and reading samples
snd.data = static_cast<u8*>(linearAlloc(snd.dataSize));
fseek(fp, 44, SEEK_SET);
fread(snd.data, 1, snd.dataSize, fp);
fclose(fp);
fseek(fp, 44, SEEK_SET);
fread(snd.data, 1, snd.dataSize, fp);
fclose(fp);
snd.dataSize /= 2;
// Find the right format
u16 ndspFormat;
if (bitsPerSample == 8)
{
ndspFormat = (channels == 1) ?
NDSP_FORMAT_MONO_PCM8 :
NDSP_FORMAT_STEREO_PCM8;
}
else
{
ndspFormat = (channels == 1) ?
NDSP_FORMAT_MONO_PCM16 :
NDSP_FORMAT_STEREO_PCM16;
}
ndspChnReset(channel);
ndspChnSetInterp(channel, NDSP_INTERP_NONE);
ndspChnSetRate(channel, float(sampleRate));
ndspChnSetFormat(channel, ndspFormat);
// Create and play a wav buffer
std::memset(&snd.waveBuf, 0, sizeof(snd.waveBuf));
snd.waveBuf.data_vaddr = reinterpret_cast<u32*>(snd.data);
snd.waveBuf.nsamples = snd.dataSize / (bitsPerSample >> 3);
snd.waveBuf.looping = toloop;
snd.waveBuf.status = NDSP_WBUF_FREE;
snd.chnl = channel;
return snd;
}
| [
"[email protected]"
] | |
1afaf04f49353ca7463f2da744973692434ac271 | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_3/processor18/20/phi | 7bfb341ac36c596a8e1b9390c8c4fccfc5779570 | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 25,790 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "20";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 3 -1 0 0 0 0];
internalField nonuniform List<scalar>
1652
(
-8.58559e-05
4.16846e-06
1.70409e-10
-8.99613e-05
4.10526e-06
1.70735e-10
-9.40234e-05
4.06193e-06
1.69597e-10
-9.80705e-05
4.04694e-06
1.66785e-10
4.08017e-06
1.62101e-10
-0.000102151
-8.38398e-05
-8.7715e-05
7.98049e-06
-9.15284e-05
7.87533e-06
-9.53079e-05
7.82647e-06
7.874e-06
-9.91018e-05
-8.3231e-05
1.1396e-05
-8.65476e-05
1.11919e-05
-8.97926e-05
1.10715e-05
1.10955e-05
-9.30141e-05
-7.65263e-05
1.41233e-05
-7.90993e-05
1.37649e-05
-8.15442e-05
1.35164e-05
1.34602e-05
-8.39089e-05
-6.76263e-05
1.5936e-05
-6.92107e-05
1.53492e-05
-7.05916e-05
1.48974e-05
1.46851e-05
-7.18165e-05
-5.65643e-05
1.66099e-05
-5.69175e-05
1.57025e-05
-5.69732e-05
1.49531e-05
1.44895e-05
-5.67776e-05
-4.33807e-05
1.59241e-05
-4.22637e-05
1.45855e-05
-4.07372e-05
1.34266e-05
1.25955e-05
-3.88432e-05
-2.81221e-05
1.36605e-05
-2.52988e-05
1.17622e-05
-2.19464e-05
1.00742e-05
8.7205e-06
-1.80714e-05
-1.08417e-05
-6.07067e-06
6.99118e-06
-5.91549e-07
4.59505e-06
2.69557e-06
5.43338e-06
1.53292e-05
6.11423e-08
2.31049e-05
-3.18065e-06
-5.90963e-06
3.17101e-05
3.88622e-05
-9.26069e-06
4.92278e-05
-1.35462e-05
-1.72597e-05
6.05778e-05
6.44466e-05
-2.11931e-05
7.76311e-05
-2.67306e-05
-3.1625e-05
9.19964e-05
9.20028e-05
0.000108237
-4.29651e-05
-4.92584e-05
0.000125871
0.000140958
-6.24734e-05
-7.04184e-05
0.000162118
0.000175701
-9.52881e-05
0.00020057
-0.00012416
0.000241274
-0.000157266
0.000284064
0.000328837
0.000157266
0.000328837
0.00012416
0.000284065
9.5288e-05
0.000241275
0.000175701
6.24733e-05
7.04183e-05
0.000200571
0.000140958
4.2965e-05
4.92582e-05
0.000162118
9.20031e-05
2.11929e-05
0.000108238
2.67305e-05
3.16248e-05
0.000125871
6.44469e-05
9.26049e-06
7.76314e-05
1.3546e-05
1.72595e-05
9.19967e-05
3.88625e-05
-6.13686e-08
4.92281e-05
3.18043e-06
5.90943e-06
6.05782e-05
1.53295e-05
-6.99143e-06
2.31052e-05
-4.59528e-06
-2.6958e-06
3.17104e-05
-1.08415e-05
-1.36607e-05
-6.07044e-06
-1.17624e-05
-5.91292e-07
-1.00744e-05
-8.72074e-06
5.43364e-06
-2.81219e-05
-1.59244e-05
-2.52986e-05
-1.45858e-05
-2.19462e-05
-1.34269e-05
-1.25957e-05
-1.80712e-05
-4.33805e-05
-1.66102e-05
-4.22635e-05
-1.57028e-05
-4.0737e-05
-1.49534e-05
-1.44898e-05
-3.8843e-05
-5.65641e-05
-1.59363e-05
-5.69173e-05
-1.53496e-05
-5.6973e-05
-1.48977e-05
-1.46854e-05
-5.67774e-05
-6.76262e-05
-1.41236e-05
-6.92105e-05
-1.37652e-05
-7.05915e-05
-1.35167e-05
-1.34605e-05
-7.18164e-05
-7.65262e-05
-1.13963e-05
-7.90992e-05
-1.11923e-05
-8.15441e-05
-1.10718e-05
-1.10958e-05
-8.39088e-05
-8.32309e-05
-7.98083e-06
-8.65475e-05
-7.87566e-06
-8.97925e-05
-7.8268e-06
-7.87432e-06
-9.30141e-05
-8.38397e-05
-4.1688e-06
-8.7715e-05
-4.1056e-06
-9.15284e-05
-4.06227e-06
-9.53079e-05
-4.04727e-06
-4.0805e-06
-9.91017e-05
-8.58559e-05
-8.99613e-05
-9.40234e-05
-9.80705e-05
-0.000102151
-0.000103817
1.6661e-06
2.0218e-10
1.06828e-06
1.74929e-10
-0.000100708
3.27244e-06
2.07423e-06
-9.45017e-05
4.75999e-06
2.95622e-06
-8.5221e-05
6.07212e-06
3.65563e-06
-7.28985e-05
7.15413e-06
4.11845e-06
-5.75785e-05
7.95506e-06
4.26996e-06
-3.93201e-05
8.43201e-06
4.07743e-06
-1.81858e-05
8.54645e-06
-1.7605e-05
3.4966e-06
-2.90734e-06
5.78666e-06
8.19317e-06
6.76771e-06
2.51555e-06
-4.68779e-06
3.24123e-05
7.49099e-06
3.38884e-05
1.03946e-06
-6.92793e-06
6.17329e-05
6.33598e-06
6.36603e-05
-8.87975e-07
-9.66105e-06
9.36186e-05
4.71371e-06
9.59792e-05
-3.24857e-06
-1.29205e-05
0.000127917
2.66689e-06
0.000130788
-6.11953e-06
-1.66911e-05
0.000164565
2.1964e-07
0.000167954
-9.50804e-06
0.000172242
-2.09792e-05
-3.2853e-05
0.000203545
-2.75522e-06
0.000207372
-1.33346e-05
0.00021217
-2.57778e-05
-3.84184e-05
0.000244621
-6.10237e-06
0.000248922
-1.76353e-05
0.000254222
-3.10773e-05
-4.44806e-05
0.00028775
-9.78852e-06
0.000292489
-2.23743e-05
0.000298274
-3.68623e-05
-5.10228e-05
0.000332823
-1.3774e-05
0.000337965
-2.75164e-05
0.000344211
-4.31083e-05
0.000351207
-5.80192e-05
-7.29344e-05
0.00037973
-1.80055e-05
0.000385238
-3.30237e-05
0.000391913
-4.97842e-05
0.000399329
-6.54347e-05
-8.08693e-05
0.000428367
0.0004342
-3.88567e-05
0.00044127
-5.68536e-05
0.000449059
-7.32239e-05
-8.91062e-05
0.000484751
-4.49784e-05
0.000492172
-6.4275e-05
0.000500277
-8.13286e-05
0.000508736
-9.75652e-05
-0.000112776
0.000536798
-5.13594e-05
0.000544524
-7.20014e-05
0.000552869
-8.96736e-05
0.000561445
-0.000106141
-0.00012132
0.000590265
0.000598242
-7.99778e-05
0.000606727
-9.81589e-05
0.000615281
-0.000114695
-0.000129673
0.000653262
-8.81342e-05
0.000661748
-0.000106646
0.000670093
-0.00012304
0.000678045
-0.000137624
-0.000150667
0.000709552
0.000717839
-0.000114932
0.000725722
-0.000130923
0.000733005
-0.000144908
-0.000157321
0.0007749
-0.000122717
0.000781977
-0.000138
0.000788259
-0.000151189
0.000793808
-0.00016287
-0.000173504
0.000832795
-0.000129553
0.000838611
-0.000143816
0.000843488
-0.000156066
0.000847594
-0.000166976
-0.000177006
0.000891345
0.000895305
-0.000147776
0.000898302
-0.000159063
0.0009006
-0.000169273
-0.000178805
0.000951732
-0.00014908
0.000952298
-0.000159629
0.000952403
-0.000169379
0.000952222
-0.000178623
-0.000187472
0.00100737
0.00100494
-0.000157203
0.0010025
-0.000166939
0.00100011
-0.00017623
-0.000185163
0.00347891
-0.000145894
0.00346903
-0.000157051
0.00346023
-0.000167434
0.00345229
-0.000177227
-0.000186533
0.00396791
-0.000119596
0.00394429
-0.000133426
0.00392296
-0.000146103
0.00390358
-0.00015785
-0.000168825
0.00443752
-8.43703e-05
0.00440473
-0.00010064
0.00437431
-0.000115681
0.00434609
-0.000129629
-0.000142616
0.00487444
-4.46565e-05
0.00483654
-6.27462e-05
0.00480058
-7.97201e-05
0.00476657
-9.5614e-05
-0.000110495
0.00527194
-3.24316e-06
0.00523182
-2.26271e-05
0.00519314
-4.10457e-05
0.005156
-5.84721e-05
-7.49203e-05
0.00562691
3.81236e-05
0.00558649
1.77938e-05
0.00554712
-1.68052e-06
0.0055089
-2.02523e-05
-3.79092e-05
0.00593822
7.82111e-05
0.00589884
5.71752e-05
0.00586022
3.69363e-05
0.00582244
1.75358e-05
-1.00831e-06
0.00620609
0.00011605
0.00616875
9.45126e-05
0.00613194
7.37471e-05
0.00609569
5.37798e-05
3.46232e-05
0.0064318
0.000150863
0.00639728
0.000129031
0.00636307
0.000107958
0.00632919
8.76553e-05
6.81267e-05
0.00661761
0.000182066
0.00658649
0.000160157
0.00655546
0.000138989
0.00652455
0.000118565
9.88815e-05
0.00676659
0.000209283
0.00673924
0.00018751
0.00671177
0.000166455
0.00668423
0.00014611
0.000126469
0.00688238
0.000232339
0.00685898
0.000210906
0.00683528
0.000190153
0.00681132
0.000170071
0.00015065
0.00696898
0.000251251
0.00694955
0.000230334
0.00692965
0.00021005
0.00690933
0.000190388
0.000171342
0.00703052
0.00026619
0.00701492
0.000245932
0.00699872
0.000226252
0.00698197
0.000207143
0.000188598
0.00707107
0.000277445
0.00705905
0.000257952
0.00704632
0.000238979
0.00703294
0.000220522
0.000202578
0.00709442
0.000285378
0.00708565
0.000266722
0.00707611
0.000248527
0.00706583
0.000230794
0.000213521
0.00710403
0.000290394
0.00709814
0.000272613
0.00709143
0.000255239
0.00708395
0.000238273
0.000221717
0.00710291
0.0002929
0.00709952
0.000276009
0.00709528
0.000259472
0.00709026
0.000243294
0.000227479
0.00709363
0.000293291
0.00709236
0.000277283
0.00709025
0.000261582
0.00708735
0.000246194
0.000231124
0.00707831
0.000291928
0.00707881
0.000276783
0.00707849
0.0002619
0.0070774
0.000247289
0.000232958
0.00705867
0.000289133
0.00706064
0.000274818
0.00706181
0.000260728
0.00706222
0.000246873
0.000233262
0.00703606
0.00028518
0.00703922
0.000271659
0.00704162
0.00025833
0.00704329
0.000245202
0.000232287
0.00701154
0.000280304
0.00701566
0.000267537
0.00701906
0.000254932
0.00702176
0.000242501
0.000230254
0.00698589
0.000274696
0.00699078
0.000262643
0.00699499
0.000250726
0.00699853
0.000238958
0.00022735
0.0069597
0.000268513
0.00696521
0.000257133
0.00697007
0.000245869
0.0069743
0.000234731
0.000223731
0.00693342
0.000261879
0.00693942
0.000251136
0.0069448
0.000240488
0.00694958
0.000229949
0.000219528
0.00690736
0.000254895
0.00691374
0.000244753
0.00691954
0.00023469
0.00692477
0.000224717
0.000214847
0.00688173
0.000247641
0.00688841
0.000238066
0.00689455
0.000228556
0.00690014
0.000219122
0.000209776
0.00685669
0.00024018
0.00686361
0.000231141
0.00687001
0.000222155
0.0068759
0.000213232
0.000204384
0.00683234
0.00023256
0.00683946
0.000224029
0.00684607
0.00021554
0.0068522
0.000207104
0.00019873
0.00680877
0.000224822
0.00681603
0.000216772
0.00682281
0.000208755
0.00682913
0.000200781
0.00019286
0.006786
0.000216996
0.00679337
0.000209404
0.00680029
0.000201836
0.00680677
0.000194302
0.000186813
0.00676408
0.000209109
0.00677153
0.00020195
0.00677856
0.000194809
0.00678517
0.000187696
0.000180619
0.00674301
0.00020118
0.00675053
0.000194434
0.00675764
0.0001877
0.00676435
0.000180988
0.000174305
0.00672281
0.000193225
0.00673037
0.000186872
0.00673754
0.000180527
0.00674433
0.000174197
0.000167892
0.00670347
0.000185258
0.00671106
0.00017928
0.00671828
0.000173305
0.00672514
0.000167342
0.000161398
0.00668499
0.000177289
0.0066926
0.000171669
0.00669986
0.000166049
0.00670676
0.000160436
0.000154838
0.00666737
0.000169326
0.00667499
0.000164048
0.00668227
0.000158767
0.00668922
0.000153491
0.000148225
0.00665059
0.000161376
0.00665822
0.000156426
0.00666551
0.00015147
0.00667249
0.000146517
0.00014157
0.00663466
0.000153444
0.00664228
0.000148808
0.00664958
0.000144165
0.00665658
0.000139521
0.000134882
0.00661956
0.000145535
0.00662716
0.0001412
0.00663447
0.000136857
0.00664148
0.000132511
0.000128168
0.00660527
0.000137651
0.00661287
0.000133606
0.00662017
0.000129551
0.00662719
0.000125493
0.000121435
0.0065918
0.000129795
0.00659938
0.000126028
0.00660668
0.000122252
0.0066137
0.00011847
0.000114688
0.00657914
0.000121967
0.00658669
0.000118469
0.00659398
0.000114961
0.00660101
0.000111448
0.000107932
0.00656726
0.000114168
0.0065748
0.00011093
0.00658208
0.000107682
0.0065891
0.000104427
0.00010117
0.00655617
0.000106399
0.00656369
0.000103413
0.00657095
0.000100416
0.00657797
9.74121e-05
9.44047e-05
0.00654585
9.86596e-05
0.00655335
9.59169e-05
0.0065606
9.31637e-05
0.00656761
9.04034e-05
8.76392e-05
0.00653631
9.09483e-05
0.00654378
8.84422e-05
0.00655102
8.5926e-05
0.00655802
8.34025e-05
8.08749e-05
0.00652752
8.32644e-05
0.00653498
8.09884e-05
0.0065422
7.87028e-05
0.00654919
7.64102e-05
7.41133e-05
0.00651949
7.56062e-05
0.00652693
7.35547e-05
0.00653414
7.14941e-05
0.00654112
6.94267e-05
6.73551e-05
0.00651221
6.79719e-05
0.00651963
6.61398e-05
0.00652682
6.42991e-05
0.0065338
6.24521e-05
6.0601e-05
0.00650567
6.03597e-05
0.00651307
5.87422e-05
0.00652025
5.71171e-05
0.00652722
5.54861e-05
5.38512e-05
0.00649988
5.27673e-05
0.00650726
5.13606e-05
0.00651443
4.9947e-05
0.00652139
4.85282e-05
4.71058e-05
0.00649482
4.51924e-05
0.00650218
4.39931e-05
0.00650934
4.27878e-05
0.00651629
4.15779e-05
4.03648e-05
0.00649049
3.7633e-05
0.00649785
3.66382e-05
0.006505
3.56384e-05
0.00651194
3.46347e-05
3.36281e-05
0.0064869
3.00871e-05
0.00649424
2.92945e-05
0.00650138
2.84978e-05
0.00650832
2.76979e-05
2.68956e-05
0.00648403
2.25528e-05
0.00649137
2.19605e-05
0.0064985
2.1365e-05
0.00650543
2.0767e-05
2.01672e-05
0.00648189
1.50285e-05
0.00648922
1.46348e-05
0.00649634
1.42389e-05
0.00650327
1.38412e-05
1.34423e-05
0.00648047
7.51191e-06
0.00648779
7.31552e-06
0.00649491
7.11796e-06
0.00650183
6.91948e-06
6.72033e-06
0.00647976
0.00648708
0.00649419
0.00650111
0.000232892
0.00680103
0.000224603
0.00677818
0.000216276
0.00675619
0.000207929
0.00673508
0.000199577
0.00671485
0.000191231
0.0066955
0.000182901
0.00667702
0.000174594
0.0066594
0.000166315
0.00664264
0.000158068
0.00662673
0.000149856
0.00661165
0.000141682
0.00659739
0.000133546
0.00658395
0.000125449
0.00657131
0.000117391
0.00655946
0.000109371
0.0065484
0.000101388
0.00653811
9.34411e-05
0.0065286
8.55277e-05
0.00651984
7.76459e-05
0.00651183
6.97934e-05
0.00650458
6.19675e-05
0.00649806
5.41654e-05
0.00649228
4.63843e-05
0.00648724
3.86215e-05
0.00648293
3.08746e-05
0.00647935
2.31412e-05
0.0064765
1.54194e-05
0.00647437
7.70685e-06
0.00647295
0.00647225
-0.000145894
0.00347891
0.000157203
-0.000119596
0.00396791
-8.43705e-05
0.00443752
-4.46568e-05
0.00487444
-3.24351e-06
0.00527194
3.81232e-05
0.00562691
7.82107e-05
0.00593822
0.000116049
0.00620609
0.000150862
0.0064318
0.000182066
0.00661761
0.000209282
0.00676659
0.000232339
0.00688238
0.000251251
0.00696898
0.00026619
0.00703052
0.000277444
0.00707107
0.000285378
0.00709442
0.000290393
0.00710403
0.0002929
0.00710291
0.000293291
0.00709363
0.000291928
0.00707831
0.000289132
0.00705867
0.00028518
0.00703606
0.000280304
0.00701154
0.000274696
0.00698589
0.000268512
0.0069597
0.000261879
0.00693342
0.000254895
0.00690736
0.000247641
0.00688173
0.000240179
0.00685669
0.00023256
0.00683234
0.000224821
0.00680877
0.000216996
0.006786
0.000209109
0.00676408
0.00020118
0.00674301
0.000193225
0.00672281
0.000185258
0.00670347
0.000177289
0.00668499
0.000169326
0.00666737
0.000161376
0.00665059
0.000153444
0.00663466
0.000145535
0.00661956
0.000137651
0.00660527
0.000129794
0.0065918
0.000121967
0.00657914
0.000114168
0.00656726
0.000106399
0.00655617
9.86595e-05
0.00654585
9.09483e-05
0.00653631
8.32643e-05
0.00652752
7.56061e-05
0.00651949
6.79719e-05
0.00651221
6.03597e-05
0.00650567
5.27672e-05
0.00649988
4.51924e-05
0.00649482
3.7633e-05
0.00649049
3.0087e-05
0.0064869
2.25528e-05
0.00648403
1.50284e-05
0.00648189
7.51191e-06
0.00648047
0.00647976
-0.000157052
0.00346903
0.000166939
-0.000133426
0.00394429
-0.00010064
0.00440474
-6.27466e-05
0.00483654
-2.26275e-05
0.00523182
1.77934e-05
0.00558649
5.71748e-05
0.00589884
9.45122e-05
0.00616875
0.000129031
0.00639728
0.000160156
0.00658649
0.00018751
0.00673924
0.000210906
0.00685898
0.000230334
0.00694955
0.000245932
0.00701492
0.000257951
0.00705905
0.000266721
0.00708565
0.000272612
0.00709814
0.000276009
0.00709952
0.000277283
0.00709236
0.000276782
0.00707881
0.000274817
0.00706064
0.000271659
0.00703922
0.000267537
0.00701566
0.000262642
0.00699078
0.000257133
0.00696521
0.000251136
0.00693942
0.000244753
0.00691374
0.000238066
0.00688841
0.000231141
0.00686361
0.000224029
0.00683946
0.000216772
0.00681602
0.000209403
0.00679337
0.00020195
0.00677153
0.000194434
0.00675053
0.000186872
0.00673037
0.00017928
0.00671106
0.000171668
0.0066926
0.000164048
0.00667499
0.000156426
0.00665822
0.000148808
0.00664228
0.0001412
0.00662716
0.000133606
0.00661287
0.000126028
0.00659938
0.000118469
0.00658669
0.00011093
0.0065748
0.000103413
0.00656369
9.59168e-05
0.00655335
8.84422e-05
0.00654378
8.09884e-05
0.00653498
7.35546e-05
0.00652693
6.61397e-05
0.00651963
5.87422e-05
0.00651307
5.13605e-05
0.00650726
4.39931e-05
0.00650218
3.66382e-05
0.00649785
2.92945e-05
0.00649424
2.19605e-05
0.00649137
1.46348e-05
0.00648922
7.31552e-06
0.00648779
0.00648708
-0.000167434
0.00346023
0.00017623
-0.000146104
0.00392296
-0.000115681
0.00437431
-7.97204e-05
0.00480058
-4.10461e-05
0.00519314
-1.68094e-06
0.00554712
3.69358e-05
0.00586023
7.37466e-05
0.00613194
0.000107958
0.00636307
0.000138989
0.00655546
0.000166455
0.00671177
0.000190153
0.00683528
0.000210049
0.00692965
0.000226251
0.00699872
0.000238978
0.00704632
0.000248527
0.00707611
0.000255238
0.00709143
0.000259472
0.00709528
0.000261582
0.00709025
0.0002619
0.00707849
0.000260727
0.00706181
0.000258329
0.00704162
0.000254932
0.00701906
0.000250726
0.00699499
0.000245868
0.00697007
0.000240488
0.0069448
0.000234689
0.00691954
0.000228556
0.00689455
0.000222155
0.00687001
0.00021554
0.00684607
0.000208755
0.00682281
0.000201835
0.00680029
0.000194809
0.00677856
0.0001877
0.00675764
0.000180527
0.00673754
0.000173305
0.00671828
0.000166049
0.00669986
0.000158767
0.00668227
0.00015147
0.00666551
0.000144165
0.00664958
0.000136857
0.00663447
0.000129551
0.00662017
0.000122252
0.00660668
0.000114961
0.00659398
0.000107682
0.00658208
0.000100416
0.00657095
9.31637e-05
0.0065606
8.59259e-05
0.00655102
7.87028e-05
0.0065422
7.1494e-05
0.00653414
6.42991e-05
0.00652682
5.7117e-05
0.00652025
4.9947e-05
0.00651443
4.27878e-05
0.00650934
3.56384e-05
0.006505
2.84978e-05
0.00650138
2.1365e-05
0.0064985
1.42389e-05
0.00649634
7.11796e-06
0.00649491
0.00649419
-0.000177227
0.00345229
0.000185164
-0.00015785
0.00390358
-0.000129629
0.00434609
-9.56144e-05
0.00476657
-5.84725e-05
0.005156
-2.02528e-05
0.0055089
1.75353e-05
0.00582244
5.37793e-05
0.00609569
8.76549e-05
0.00632919
0.000118565
0.00652455
0.00014611
0.00668423
0.00017007
0.00681132
0.000190388
0.00690933
0.000207142
0.00698197
0.000220522
0.00703294
0.000230794
0.00706583
0.000238273
0.00708395
0.000243294
0.00709026
0.000246193
0.000247289
0.000246872
0.000245202
0.000242501
0.000238958
0.000234731
0.000229948
0.000224717
0.000219122
0.000213232
0.000207104
0.000200781
0.000194302
0.000187696
0.000180988
0.000174197
0.000167342
0.000160436
0.000153491
0.000146517
0.000139521
0.000132511
0.000125493
0.00011847
0.000111447
0.000104427
9.7412e-05
9.04033e-05
8.34025e-05
7.64102e-05
6.94267e-05
6.24521e-05
5.54861e-05
4.85282e-05
4.15779e-05
3.46346e-05
2.76979e-05
2.0767e-05
1.38412e-05
6.91948e-06
-0.000186533
-0.000168826
-0.000142617
-0.000110495
-7.49208e-05
-3.79096e-05
-1.0088e-06
3.46227e-05
6.81262e-05
9.8881e-05
0.000126469
0.000150649
0.000171341
0.000188597
0.000202577
0.000213521
0.000221716
0.00100737
0.00014908
0.00100494
0.000159629
0.0010025
0.000169379
0.00100011
0.000178623
0.000187472
0.000951733
0.000147776
0.000952299
0.000159063
0.000952404
0.000169274
0.000952222
0.000178805
0.000891345
0.000129553
0.000895305
0.000143816
0.000898303
0.000156066
0.000900601
0.000166976
0.000177007
0.000832796
0.000122717
0.000838612
0.000138
0.000843488
0.000151189
0.000847594
0.00016287
0.000173504
0.000774901
0.000114932
0.000781978
0.000130923
0.00078826
0.000144908
0.000793808
0.000157321
0.000709553
8.81342e-05
0.000717839
0.000106646
0.000725722
0.00012304
0.000733006
0.000137624
0.000150667
0.000653262
7.99778e-05
0.000661749
9.81589e-05
0.000670094
0.000114695
0.000678045
0.000129673
0.000590266
5.13593e-05
0.000598242
7.20013e-05
0.000606727
8.96736e-05
0.000615281
0.000106141
0.00012132
0.000536798
4.49782e-05
0.000544524
6.42749e-05
0.00055287
8.13285e-05
0.000561446
9.75652e-05
0.000112776
0.000484751
3.88566e-05
0.000492173
5.68535e-05
0.000500277
7.32238e-05
0.000508736
8.91062e-05
0.000428368
1.80053e-05
0.000434201
3.30236e-05
0.00044127
4.97841e-05
0.000449059
6.54347e-05
8.08693e-05
0.000379731
1.37737e-05
0.000385238
2.75163e-05
0.000391914
4.31082e-05
0.000399329
5.80192e-05
7.29343e-05
0.000332823
9.78828e-06
0.000337965
2.23741e-05
0.000344211
3.68622e-05
0.000351208
5.10227e-05
0.000287751
6.10212e-06
0.00029249
1.76351e-05
0.000298275
3.10772e-05
4.44805e-05
0.000244622
2.75495e-06
0.000248922
1.33344e-05
0.000254222
2.57776e-05
3.84183e-05
0.000203546
-2.19925e-07
0.000207372
9.5078e-06
0.000212171
2.0979e-05
3.28529e-05
0.000164566
-2.66719e-06
0.000167954
6.11928e-06
0.000172242
1.66909e-05
0.000127918
-4.71403e-06
0.000130789
3.24831e-06
1.29203e-05
9.3619e-05
-6.33631e-06
9.59796e-05
8.87705e-07
9.66081e-06
6.17332e-05
-7.49133e-06
6.36606e-05
-1.03976e-06
6.92769e-06
3.24126e-05
-8.19352e-06
3.38887e-05
-2.51585e-06
4.68754e-06
5.78693e-06
-8.54681e-06
6.76799e-06
-3.49692e-06
2.90709e-06
-1.81856e-05
-8.43238e-06
-1.76048e-05
-4.07775e-06
-3.93199e-05
-7.95544e-06
-4.27029e-06
-5.75783e-05
-7.15451e-06
-4.11879e-06
-7.28984e-05
-6.07251e-06
-3.65597e-06
-8.52209e-05
-4.76039e-06
-2.95657e-06
-9.45016e-05
-3.27284e-06
-2.07458e-06
-0.000100708
-1.6665e-06
-1.06863e-06
-0.000103817
)
;
boundaryField
{
inlet
{
type calculated;
value nonuniform 0();
}
outlet
{
type calculated;
value nonuniform 0();
}
cylinder
{
type calculated;
value nonuniform 0();
}
top
{
type symmetryPlane;
value uniform 0;
}
bottom
{
type symmetryPlane;
value uniform 0;
}
defaultFaces
{
type empty;
value nonuniform 0();
}
procBoundary18to17
{
type processor;
value nonuniform List<scalar>
201
(
8.16873e-05
7.98833e-05
8.12488e-06
7.98155e-05
7.3799e-05
6.58136e-05
5.58903e-05
4.40665e-05
3.03857e-05
1.48971e-05
9.605e-06
-8.3992e-06
-2.95404e-05
-5.25142e-05
-7.72488e-05
-3.59471e-05
-0.00012145
-0.000152705
-8.54694e-05
-0.000212402
-0.000250959
-0.000291273
-0.00019483
-0.000375499
-0.000423948
-0.000423948
-0.00019483
-0.000375499
-0.000291273
-0.00025096
-0.000212402
-8.54693e-05
-0.000152705
-0.00012145
-3.59469e-05
-7.7249e-05
-5.25145e-05
-2.95407e-05
-8.39943e-06
9.60526e-06
1.48969e-05
3.03856e-05
4.40664e-05
5.58902e-05
6.58135e-05
7.37989e-05
7.98154e-05
8.12522e-06
7.98833e-05
8.16872e-05
-2.24248e-05
-0.000478629
-0.000530417
-0.000583639
-5.79855e-05
-0.000645105
-0.000701317
-9.63701e-05
-0.000767116
-0.000825959
-0.00088612
-0.000134778
-0.000950428
-0.00100965
-0.0001468
-0.00349022
-0.00399421
-0.00447275
-0.00491415
-0.00531335
-0.00566828
-0.00597831
-0.00624392
-0.00646661
-0.00664882
-0.00679381
-0.00690543
-0.00698789
-0.00704546
-0.00708232
-0.00710236
-0.00710905
-0.00710542
-0.00709402
-0.00707695
-0.00705588
-0.00703211
-0.00700666
-0.00698028
-0.00695352
-0.00692679
-0.00690037
-0.00687447
-0.00684923
-0.00682472
-0.00680103
-0.00677818
-0.00675619
-0.00673508
-0.00671485
-0.0066955
-0.00667702
-0.00665941
-0.00664264
-0.00662673
-0.00661165
-0.00659739
-0.00658395
-0.00657131
-0.00655946
-0.0065484
-0.00653811
-0.0065286
-0.00651984
-0.00651183
-0.00650458
-0.00649806
-0.00649228
-0.00648724
-0.00648293
-0.00647935
-0.0064765
-0.00647437
-0.00647295
-0.00647225
-0.0067928
-0.00676989
-0.00674787
-0.00672674
-0.0067065
-0.00668716
-0.00666869
-0.0066511
-0.00663436
-0.00661848
-0.00660344
-0.00658922
-0.00657581
-0.00656321
-0.0065514
-0.00654038
-0.00653013
-0.00652065
-0.00651193
-0.00650395
-0.00649672
-0.00649024
-0.00648448
-0.00647946
-0.00647517
-0.0064716
-0.00646876
-0.00646664
-0.00646524
-0.00646454
-0.00349022
-0.0001468
-0.00399421
-0.00447275
-0.00491415
-0.00531335
-0.00566828
-0.00597831
-0.00624392
-0.00646661
-0.00664882
-0.00679381
-0.00690543
-0.00698789
-0.00704546
-0.00708232
-0.00710236
-0.00710905
-0.00710542
-0.00709402
-0.00707695
-0.00705588
-0.00703211
-0.00700666
-0.00698028
-0.00695352
-0.00692679
-0.00690037
-0.00687447
-0.00684923
-0.00024112
-0.00682472
-0.00100965
-0.000950429
-0.000134778
-0.000886121
-0.000825959
-0.000767116
-9.637e-05
-0.000701317
-0.000645106
-5.79854e-05
-0.000583639
-0.000530417
-0.00047863
-2.24246e-05
)
;
}
procBoundary18to19
{
type processor;
value nonuniform List<scalar>
197
(
-0.000104886
-0.000101714
-9.53837e-05
-8.59204e-05
-7.33613e-05
-5.773e-05
-3.91276e-05
1.54806e-06
-1.62457e-05
8.54816e-06
3.61286e-05
6.63934e-05
9.92387e-05
0.000134559
2.7794e-05
0.000177301
0.000217736
0.000260284
0.000304817
6.53622e-05
0.000358779
0.000407264
0.000457296
0.000104206
0.000517307
0.000569989
0.000623633
0.000143205
0.000685506
0.00073966
0.000168578
0.000798734
0.000851096
0.000902398
0.000187823
0.00095187
0.000997797
0.00019377
0.00344506
0.00388587
0.00431988
0.00473445
0.00512043
0.00547189
0.00578554
0.00606006
0.00629569
0.00649379
0.00665664
0.00678714
0.00688864
0.00696471
0.00701896
0.00705489
0.00707575
0.0070845
0.0070837
0.00707556
0.00706192
0.00704426
0.00702379
0.00700143
0.00697792
0.00695379
0.00692945
0.00690521
0.0068813
0.00685785
0.006835
0.00681282
0.00679136
0.00677066
0.00675075
0.00673163
0.00671332
0.00669583
0.00667914
0.00666327
0.0066482
0.00663393
0.00662045
0.00660776
0.00659586
0.00658473
0.00657438
0.00656479
0.00655595
0.00654788
0.00654055
0.00653397
0.00652813
0.00652304
0.00651868
0.00651505
0.00651216
0.00650999
0.00650855
0.00650783
0.00708735
0.0070774
0.00706222
0.00704329
0.00702176
0.00699853
0.0069743
0.00694958
0.00692477
0.00690014
0.0068759
0.0068522
0.00682913
0.00680677
0.00678517
0.00676435
0.00674433
0.00672514
0.00670676
0.00668921
0.00667249
0.00665658
0.00664148
0.00662719
0.0066137
0.00660101
0.0065891
0.00657797
0.00656761
0.00655802
0.00654919
0.00654112
0.0065338
0.00652722
0.00652139
0.00651629
0.00651194
0.00650832
0.00650543
0.00650327
0.00650183
0.00650111
0.00344506
0.00019377
0.00388587
0.00431988
0.00473445
0.00512043
0.00547189
0.00578554
0.00606006
0.00629569
0.00649379
0.00665664
0.00678714
0.00688864
0.00696471
0.00701896
0.00705489
0.00707576
0.000227478
0.0070845
0.000997798
0.000951871
0.000187823
0.000902399
0.000851096
0.000798734
0.000168578
0.00073966
0.000685506
0.000143205
0.000623634
0.000569989
0.000517307
0.000104206
0.000457296
0.000407264
0.00035878
6.53622e-05
0.000304817
0.000260284
0.000217736
0.000177301
2.77938e-05
0.000134559
9.9239e-05
6.63938e-05
3.61289e-05
8.54845e-06
-1.62455e-05
1.5478e-06
-3.91274e-05
-5.77298e-05
-7.33612e-05
-8.59203e-05
-9.53836e-05
-0.000101714
-0.000104886
)
;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | ||
47f629cdc8e4b61a182e9062b41fff93866e4ffc | 533dd97ee789dfea9cab2583853309d004c3a6be | /examples/UbidotsPOST/UbidotsPOST.ino | d8061c752d2a6e4ca1616ddb72e97abae683dcec | [] | no_license | jaredsalazar/GPRSL | 4916723c5eb8d723a82e6b7b58e281c6a2cda720 | 2999c3dadb7fefad45c208a087810723256680ca | refs/heads/master | 2020-05-18T05:13:13.698636 | 2015-12-20T17:05:56 | 2015-12-20T17:05:56 | 41,818,175 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 612 | ino | #include<LBattery.h>
#include<GPRSL.h>
GPRSL global;
void setup() {
// put your setup code here, to run once:
global.START();
}
void loop() {
String value = String(LBattery.level()); //get battery charge level
String var="{\"value\":"+ value + "}"; //contruct json
char server[] = "things.ubidots.com";
char path[] = "/api/v1.6/variables/xxxxxxxxxxxxxxxxxxxx/values"; // Edit Path to include you source key
char token[] = "xxxxxxxxxxxxxxxxxxxxxxxxx"; //add token here
String response;
response = global.POST(var,server,path,token);
Serial.println(response);
delay(10000);
}
| [
"[email protected]"
] | |
f4868b5bf51206d2e40881c44093f99d1b2a933c | be96ad3f286ca488a59e360e04acca7f7845447c | /3D game ver4.5/Program/Library/Support/wsb_xml.h | c8ade3bd5f9d6c476614c03fb9ce37d330301b7a | [] | no_license | KonnyakuTugumi7/BOX-MAZE | 5153c625003ba1dab704160878165039e6d8ea5c | 8c1eb42a3c2533652814ddbb8977855e0e4131e0 | refs/heads/master | 2021-01-13T01:40:54.461773 | 2014-12-13T09:35:16 | 2014-12-13T09:35:16 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 6,053 | h | ////
//// wsb_xml.h
////
//// Created by 常木 徹 on 12/02/05.
//// Copyright (c) 2011 t.tsuneki All rights reserved.
////
//
//
//#ifndef __WSB_XML__
//#define __WSB_XML__
//
//#pragma comment( lib , "libxml2.lib" )
//
//#pragma warning( disable : 4127 )
//
//#include <iostream>
//#include <string>
//
//#include <libxml/xmlversion.h>
//#include <libxml/xmlreader.h>
//#include <libxml/tree.h>
//#include <memory>
//
//using namespace std ;
//class CWsbXml ;
//typedef std::shared_ptr< CWsbXml > CWsbXmlSP ;
//typedef std::weak_ptr< CWsbXml > CWsbXmlWP ;
//
////-------------------------------------------------------------------------
////
//// XML クラス
////
//class CWsbXml {
//
//private:
//
// // ユーザによるコンストラクタ呼び出し禁止
// CWsbXml() {
// /*
// m_tag_child = NULL ;
// m_tag_next = NULL ;
// m_tag_parent = NULL ;
// m_attr = NULL ;
// */
// }
//
// std::string m_file_name ; // ファイル名
// std::string m_tag_name ; // タグ名
// std::string m_string ; // 要素の文字列
// int m_s32 ; // 要素の整数
// float m_f32 ; // 要素の少数
//
// CWsbXmlSP m_tag_child ;
// CWsbXmlSP m_tag_next ;
// CWsbXmlWP m_this_week ;
// CWsbXmlWP m_tag_parent ;
// CWsbXmlSP m_attr ;
//
// static int ParseProcess( xmlTextReaderPtr _reader, CWsbXmlSP _parent, int _prevtype ) ;
//
//public:
//
// //=====================================================
// // 要素情報の取得
// //=====================================================
// inline std::string GetFileName(){ return GetElementTop()->m_file_name ; }
// inline std::string GetTagName(){ return m_tag_name ; }
// inline std::string GetString(){ return m_string ; }
// inline int GetInt(){ return m_s32 ; }
// inline float GetFloat(){ return m_f32 ; }
// inline CWsbXmlSP GetParentElement(){ return CWsbXmlSP( m_tag_parent ) ; }
//
// //=====================================================
// // 要素の取得
// //=====================================================
// int GetElementNum( std::string _tag_name = "all_element" ) ;
// CWsbXmlSP GetElement( std::string _tag_name, int _idx = 0 ) ;
// CWsbXmlSP GetElement( int _idx ) ;
// CWsbXmlSP GetElementTop() ;
//
// //=====================================================
// // 属性の取得
// //=====================================================
// int GetAttrNum( std::string _attr_name = "all_attribute" ) ;
// CWsbXmlSP GetAttr( std::string _attr_name, int _idx = 0 ) ;
// CWsbXmlSP GetAttr( int _idx ) ;
//
// //=====================================================
// // テキストベースの XMLを取得
// // arg1... 出力結果
// // arg2... 指定しなくてOK
// //=====================================================
// void GetXmlString( std::string *_string, bool start = true ) ;
//
// //=====================================================
// // 要素の設定
// //=====================================================
// void Set( int _v ) ;
// void Set( float _v ) ;
// void Set( std::string _string ) ;
//
// //=====================================================
// // 子供の追加
// // arg1... タグ名
// // arg2... string, s32, f32 のどれか
// //=====================================================
// template<class T> void AddChild( string _string, const T& _v )
// {
// CWsbXmlSP sarch = CWsbXmlSP( this->m_this_week ) ;
//
// if( sarch->m_tag_child == NULL ){
// sarch->m_tag_child = CWsbXmlSP( new CWsbXml ) ;
// sarch = sarch->m_tag_child ;
// }else{
// sarch = sarch->m_tag_child ;
// while( sarch->m_tag_next != NULL ){
// sarch = sarch->m_tag_next ;
// }
// sarch->m_tag_next = CWsbXmlSP( new CWsbXml ) ;
// sarch = sarch->m_tag_next ;
// }
//
// sarch->m_tag_parent = this->m_this_week ;
// sarch->m_this_week = CWsbXmlWP( sarch ) ;
// sarch->Set( _v ) ;
// sarch->m_tag_name = _string ;
// }
//
// //=====================================================
// // 兄弟の追加
// // arg1... タグ名
// // arg2... string, s32, f32 のどれか
// //=====================================================
// template<class T> bool AddNext( string _string, const T& _v )
// {
// if( this->m_string == "wsb_root_xml" ) return false ;
//
// CWsbXmlSP sarch = CWsbXmlSP( this->m_this_week ) ;
// while( sarch->m_tag_next != NULL ){
// sarch = sarch->m_tag_next ;
// }
// sarch->m_tag_next = CWsbXmlSP( new CWsbXml ) ;
// sarch->m_tag_parent = this->m_tag_parent ;
// sarch = sarch->m_tag_next ;
// sarch->m_this_week = CWsbXmlWP( sarch ) ;
// sarch->Set( _v ) ;
// sarch->m_tag_name = _string ;
// return true ;
// }
//
//
//public:
//
// static CWsbXmlSP CreateXml( std::string _root_name ) ;
// static CWsbXmlSP LoadXmlFile( std::string _filename ) ;
// static CWsbXmlSP LoadXmlString( std::string _xmlstring ) ;
// void SaveXmlFile( std::string _filename ) ;
//
// //=====================================================
// // 自身のコピー
// //=====================================================
// CWsbXml GetInstance() { return (*this) ; }
//
// //=====================================================
// // 要素の取得
// //=====================================================
// CWsbXml operator[]( std::string index ) {
// CWsbXmlSP wkxml = this->GetElement( index ) ;
// return (*wkxml.get()) ;
// }
//
// CWsbXml operator[]( int index ) {
// CWsbXmlSP wkparent = this->GetParentElement() ;
// CWsbXmlSP wkxml = wkparent->GetElement( this->m_tag_name, index ) ;
// return (*wkxml.get()) ;
// }
//
// //=====================================================
// // 属性の取得
// //=====================================================
// CWsbXml operator()( std::string index ) {
// CWsbXmlSP wkxml = this->GetAttr( index ) ;
// return (*wkxml.get()) ;
// }
//
// //=====================================================
// // 文字列データの取得
// //=====================================================
// std::string operator()() {
// return this->GetString() ;
// }
//
//} ;
//
//#endif
| [
"[email protected]"
] | |
1dac26676ae8f708b51939061011622121a2c742 | ff0caeb215ae53383eaaeead610c64316de072b3 | /Chapter5/5.2.cpp | 588dd13c454332a72f8f63cee1ebdf29073a4bc0 | [] | no_license | Chase07/Learning-Opencv | 3ca8d0112c4e609d55e7fccb97b5299f5e9b529a | dbe74fb808662edfd7bd049dbe1dc29da89d679c | refs/heads/master | 2021-08-22T06:26:21.188046 | 2017-11-29T14:12:27 | 2017-11-29T14:12:27 | 112,482,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | cpp | #include<iostream>
#include<opencv2/opencv.hpp>
using namespace::std;
using namespace::cv;
int main()
{
int i = 0;
// Reading as a grayscale image
Mat image = imread("../../images/group.jpg", IMREAD_GRAYSCALE);
imshow("Original group", image);
// That pixels' value from 0 to 60 will set to 0, and that pixels' value from 61 to 255 will set to 255.
threshold(image, image, 60, 255, THRESH_BINARY);// Binarization
bitwise_not(image, image, Mat());// NOT
imshow("Binary group", image);
Mat dilated;
dilate(image, dilated, Mat());
imshow("Dilated group", dilated);
Mat eroded;
erode(image, eroded, cv::Mat(), Point(-1, -1), 3);
/*Mat element(7, 7, CV_8U, cv::Scalar(1));
erode(image, eroded, element);*/
imshow("Eroded group", eroded);// Using own construct element
waitKey(0);
return 0;
} | [
"[email protected]"
] | |
396ac0b18f1676d252d91c06c1a69a44cef5865f | 33dc02c5131e0f3acced5c0740f673099c64b591 | /Boost Codes/FirstStepsWithBGL.cpp | 8b4f9916d006f6c2160e0dbe50e49e7923507097 | [] | no_license | qursaan/C- | a1d1f1b611a03eae8e0b32a62ccdd0b19a5b35ad | 8d0d981db8e2d60727133f2c9a9bf98229801403 | refs/heads/master | 2021-09-07T17:14:09.092845 | 2018-02-26T17:44:21 | 2018-02-26T17:44:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,671 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/tuple/tuple.hpp>
using namespace std;
using namespace boost;
typedef adjacency_list<vecS, vecS, undirectedS,
no_property,
property<edge_weight_t,int> > Graph;
typedef graph_traits<Graph>:: edge_descriptor Edge;
typedef graph_traits<Graph>:: edge_iterator EdgeIt;
typedef property_map<Graph,edge_weight_t>:: type WeightMap;
pair <int,int> solve(Graph& g){
WeightMap wm=get(edge_weight,g);
vector<Edge> mst;
kruskal_minimum_spanning_tree(g,back_inserter(mst));
vector<Edge>::iterator ebeg, eend=mst.end();
int sum=0;
for(ebeg=mst.begin();ebeg!=eend;ebeg++){
sum+=wm[*ebeg];
}
int ver = num_vertices(g);
vector<int> dist(ver);
vector<int> pred(ver);
dijkstra_shortest_paths(g,0,predecessor_map(make_iterator_property_map(pred.begin(),get(vertex_index,g))).
distance_map(make_iterator_property_map(dist.begin(),get(vertex_index,g))));
int maxval=0;
int i;
for(i=0;i<ver;i++){
maxval=max(maxval,dist[i]);
}
return make_pair(sum,maxval);
}
int main(){
ios_base::sync_with_stdio(false);
int T;
cin>>T;
while(T--){
int n,m;
cin>>n>>m;
Graph g(n);
WeightMap wm = get(edge_weight,g);
int i;
for(i=0;i<m;i++){
int start,end,weight;
cin>>start>>end>>weight;
Edge e;
tie(e,tuples::ignore)=add_edge(start,end,g);
wm[e]=weight;
}
pair <int,int> sol=solve(g);
cout<<sol.first<<" "<<sol.second<<endl;
}
return 0;
} | [
"[email protected]"
] | |
5f576299fe617e1e9390e6bb710a39594a2f29ef | e16490260bab9864538045dd1183fe1531a195dc | /c++/kruskal.cpp | 5b76be521a2e09ae7acefde5417ecfea28d37a4b | [] | no_license | XAbirHasan/C-and-Cplus | 6fb49b0610d5a4a39958c3dc22ac059dd6cd3139 | e050b686d2d9a8a0296b158f867bcb6dc9da299b | refs/heads/master | 2023-07-28T06:13:19.647318 | 2021-09-09T17:10:56 | 2021-09-09T17:10:56 | 304,000,579 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,531 | cpp | #include <stdio.h>
#include <algorithm>
#include <vector>
class Edge
{
public:
int u;
int v;
int weight;
Edge(int a, int b, int w);
};
Edge::Edge(int a, int b, int w)
{
u = a;
v = b;
weight = w;
}
bool compareEdge(Edge& e1, Edge& e2)
{
return e1.weight < e2.weight;
}
class EdgeSet
{
public:
std::vector<Edge> list;
void sort_Edges();
void print_EdgeSet();
};
void EdgeSet::sort_Edges()
{
sort(list.begin(), list.end(), compareEdge);
}
void EdgeSet::print_EdgeSet()
{
printf("-------------------------------------------\n");
for(int i=0; i<list.size(); i++)
{
printf("(%d, %d) weight %d\n", list[i].u, list[i].v, list[i].weight);
}
printf("-------------------------------------------\n");
}
class DisjointForest
{
int parent[100];
int rank[100];
public:
void make_set(int u);
int find_set(int u);
void link(int u, int v);
void Union(int u, int v);
};
void DisjointForest::make_set(int u)
{
parent[u] = u;
rank[u] = 0;
}
int DisjointForest::find_set(int u)
{
// used path compression
if(parent[u] == u)
return u;
else
return parent[u] = find_set(parent[u]);
}
void DisjointForest::link(int u, int v)
{
// used union by rank
if(rank[u]>rank[v])
parent[v] = u;
else {
parent[u] = v;
if(rank[u] == rank[v])
rank[v]++;
}
}
void DisjointForest::Union(int u, int v)
{
link(find_set(u), find_set(v));
}
class Graph
{
public:
int nVertices;
bool weighted;
bool directed;
int adjMatrix[100][100];
Graph(int n, bool weighted, bool directed);
void add_edge(int u, int v);
void add_edge(int u, int v, int weight);
void delete_edge(int u, int v);
EdgeSet get_Edgeset();
void print_graph();
};
Graph::Graph(int n, bool weigh, bool dir)
{
nVertices = n;
weighted = weigh;
directed = dir;
for(int i = 0; i < nVertices; i++)
{
for(int j = 0; j< nVertices; j++)
{
adjMatrix[i][j] = 0;
}
}
}
void Graph::add_edge(int u, int v)
{
adjMatrix[u][v] = 1;
if(!directed)
{
adjMatrix[v][u] = 1;
}
}
void Graph::add_edge(int u, int v, int weight)
{
adjMatrix[u][v] = weight;
if(!directed)
{
adjMatrix[v][u] = weight;
}
}
void Graph::delete_edge(int u, int v)
{
adjMatrix[u][v] = 0;
if(!directed)
{
adjMatrix[v][u] = 0;
}
}
EdgeSet Graph::get_Edgeset()
{
EdgeSet E;
for(int j=0; j<nVertices; j++)
{
for(int i=0; i<j; i++)
{
if(adjMatrix[i][j] != 0)
{
Edge e(i, j, adjMatrix[i][j]);
E.list.push_back(e);
}
}
}
return E;
}
void Graph::print_graph()
{
printf("-------------------------------------------\n");
for(int i = 0; i < nVertices; i++)
{
for(int j = 0; j< nVertices; j++)
{
printf("%3d ", adjMatrix[i][j]);
}
printf("\n");
}
printf("-------------------------------------------\n");
}
int main()
{
Graph G(7, true, false);
G.print_graph();
G.add_edge(0, 1, 2);
G.add_edge(1, 2, 19);
G.add_edge(2, 3, 9);
G.add_edge(3, 4, 1);
G.add_edge(4, 5, 13);
G.add_edge(5, 6, 21);
G.add_edge(2, 4, 5);
G.add_edge(1, 5, 25);
G.add_edge(0, 6, 8);
G.add_edge(0, 5, 14);
G.add_edge(2, 5, 17);
G.print_graph();
// write your code here
return 0;
}
| [
"[email protected]"
] | |
287eab27cafbe75bb658b786aef025b49f5d2ac1 | 26354b1d3331e153f5ed4de61245435b1dd3c654 | /2nd/068_text_justification.cpp | e2d5b3c596d40ceb2de4d92ded1b08d2677cc0c0 | [] | no_license | buptlxb/leetcode | 90203be80a038c54a34d4ec829c4805fc26a1689 | b641419de040801c4f54618d7ee26edcf10ee53c | refs/heads/master | 2020-04-05T23:47:54.990923 | 2016-09-11T14:10:30 | 2016-09-11T14:10:30 | 33,243,374 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,041 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
class Solution {
public:
vector<string> fullJustify(vector<string>& words, int maxWidth) {
vector<string> ret;
int cur = 0;
vector<string>::iterator start = words.begin();
for (vector<string>::iterator i = words.begin(), iend = words.end(); i != iend; ++i) {
cur += i->size();
if (cur < maxWidth) {
++cur;
} else if (cur == maxWidth) {
ret.push_back(concatenate(start, i+1, cur, maxWidth));
start = i+1;
cur = 0;
} else {
ret.push_back(concatenate(start, i, cur-i->size()-1, maxWidth));
start = i;
cur = 0;
--i;
}
}
if (start == words.end())
return ret;
ret.push_back(concatenate(start, words.end(), cur-1, maxWidth, true));
return ret;
}
string concatenate(vector<string>::iterator start, vector<string>::iterator end, int cur, int maxWidth, bool isleftAligned = false) {
int total = maxWidth - cur;
int slots = end - start - 1;
ostringstream os;
if (slots == 0) {
os << *start << string(maxWidth-start->size(), ' ');
} else {
int spacesPerSlot = total / slots;
int oneMore = total % slots;
os << *start++;
if (isleftAligned) {
for (int i = 0; i < slots; ++i) {
os << ' ' << *start++;
}
os << string(maxWidth - cur, ' ');
} else {
string spaces(spacesPerSlot+1, ' ');
for (int i = 0; i < slots; ++i) {
os << spaces;
if (i < oneMore)
os << ' ';
os << *start++;
}
}
}
return os.str();
}
};
int main(void)
{
return 0;
}
| [
"[email protected]"
] | |
abe853d150eba5dc86063e77dc43d81145d32abd | 5fb230d5bad4190c052c2a5540a6af7bfb71ac67 | /Source/nebula/ui/Uship_object.h | 3affe88c2be314b26b0be045ab93f64d92090768 | [] | no_license | arkena00/nebula | d4e9163998cb8ba5ae980ff1bf82b140bd0f1ef4 | 7631bfdab71bd0e92cdfd0a7129d99f779406ec9 | refs/heads/master | 2021-08-31T00:06:07.801541 | 2017-12-19T22:40:16 | 2017-12-19T22:40:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 979 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/TextBlock.h"
#include "Components/NamedSlot.h"
#include "Components/ProgressBar.h"
#include "world/Aship_object.h"
#include "ui/Ubutton.h"
#include "Uship_object.generated.h"
/**
*
*/
UCLASS()
class NEBULA_API UUship_object : public UUserWidget
{
GENERATED_BODY()
protected:
public:
virtual void init(Aship_object* object)
{
FString info;
/*
info += "Default description";
info += "\nBuild time : " + FString::FromInt(object->build_time());
info += "\nEnergy / s : " + FString::FromInt(object->eps());*/
description_set(info);
}
void action_set(UUbutton* action)
{
//action_->SetContent(action);
}
void description_set(FString value)
{
description_set(FText::FromString(value));
}
void description_set(FText value)
{
//if (info_) info_->SetText(value);
}
};
| [
"[email protected]"
] | |
97f9b3fb5b80a055ccdb82ff4ae0b58c5a01bf0f | 7f6207aaf9f7365070a01b68c922b69699e90dae | /第一次实验/sort.h | 28924a215df22b29d18476903f4f3b1a4053fdbd | [] | no_license | 15805383399/BUPT-data_structure | dd712fe2c202b3038a40678ee9ab3b3a8182dff8 | 97185d0255af088afacb5a576f3c986c9db38516 | refs/heads/master | 2023-05-29T09:11:07.244822 | 2021-06-05T06:03:21 | 2021-06-05T06:03:21 | 373,146,305 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,550 | h | #pragma once
#ifndef _list_sort_
#define _list_sort_
#include "list.h"
#include <iostream>
using namespace std;
template <typename T>
void List<T>::sort(Node_Posi<T> p, int n)
{
merge_sort(p, n);
}
template <typename T>
Node_Posi<T> List<T>::merge_sort(Node_Posi<T> p, int n)
{
if (n < 2)
return p;
int mid = n >> 1; //取中点
Node_Posi<T> q = p;
for (int i = 0; i < mid; i++)
q = q->succ;
p = merge_sort(p, mid);
q = merge_sort(q, n - mid);
Node_Posi<T> temp = p;
for (int i = 0; i < mid; i++)
temp = temp->succ;
//检查是否合法
if (temp != q)
cout << "不合法";
return merge(p, mid, q, n - mid);
}
template <typename T>
Node_Posi<T> List<T>::merge(Node_Posi<T> p, int n, Node_Posi<T> q, int m)
{
//assert p, q在同一个list中,两端列表紧邻,并且p在前
//并且两端都是有序的
Node_Posi<T> result;
if (p->data <= q->data)
result = p;
else
result = q;
while (n > 0 && m > 0)
{
if (p->data <= q->data)
{
p = p->succ;
n--;
} //如果p的data小,则将p指针后移
else
{
q = q->move_ahead_of(p);
m--;
}
}
return result;
}
template <typename T>
int List<T>::ordered()
{
int result = 0;
Node_Posi<T> p = first();
for (int i = 0; i < _size - 1; i++)
{
result += int(p->data > p->succ->data);
p = p->succ;
}
return result;
}
#endif
template <typename T>
Node_Posi<T> List<T>::insert_ordered(T const &e)
{
Node_Posi<T> p = search(e);
++_size;
return p->Insert_as_pred(e);
} | [
"[email protected]"
] | |
14b7eeba793ec711438bf0166e915414076a1ecb | cc88df859d47b039490941071304889631e57177 | /第二周课堂实验二/exp1_2View.h | bbcd81847f9f93d768a88a334b203817905aaac0 | [] | no_license | ChingJie-116/text | a1ab13d3cd912ce7f06ecf09173843fdb0b2bbbb | 17202b3e040d67de80b3610aee20488692d9be2d | refs/heads/master | 2021-05-18T13:14:34.783020 | 2020-07-08T15:15:09 | 2020-07-08T15:15:09 | 251,256,128 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,102 | h |
// exp1_2View.h : Cexp1_2View 类的接口
//
#pragma once
class Cexp1_2View : public CView
{
protected: // 仅从序列化创建
Cexp1_2View();
DECLARE_DYNCREATE(Cexp1_2View)
// 特性
public:
Cexp1_2Doc* GetDocument() const;
// 操作
public:
CArray<CRect, CRect&> ca;
// 重写
public:
virtual void OnDraw(CDC* pDC); // 重写以绘制该视图
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// 实现
public:
virtual ~Cexp1_2View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
#ifndef _DEBUG // exp1_2View.cpp 中的调试版本
inline Cexp1_2Doc* Cexp1_2View::GetDocument() const
{ return reinterpret_cast<Cexp1_2Doc*>(m_pDocument); }
#endif
| [
"[email protected]"
] | |
eddad76e5381a47f1f68b65b3d3703f4c091d5a1 | 6df09c28e7a07e938012e96682b560e93ef557ab | /HelperFunctions.cpp | c9a938090f1a867ef22102b62d0e3e1711f38f54 | [
"Apache-2.0"
] | permissive | EdwardCalloway/CS112-ImageManipulator | 24f1d2cdd24b817ec2a704351924e4f859821eb8 | 87c4df2838b744776355baa038de2fa0848e3c38 | refs/heads/master | 2020-08-04T15:43:39.518894 | 2019-10-24T06:10:56 | 2019-10-24T06:10:56 | 212,189,228 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 951 | cpp | #include "HelperFunctions.h"
#include <iostream>
#include <exception>
#include <sstream>
#include <fstream>
#include <istream>
using namespace std;
string readLine(string prompt)
{
cout << prompt;
string line;
try
{
getline(cin, line);
}
catch (ios_base::failure ex)
{
cout << "Error reading from keyboard: " << ex.what() << endl;
}
return line;
}
int readInt(string prompt)
{
string result = readLine(prompt);
int number = -1; //define outside of try to maintain
//scope
bool is_valid_number = false;
while (is_valid_number == false)
{
try
{
number = stoi(result);
//this line executes only when stoi succeeds
is_valid_number = true;
}
catch (invalid_argument ex)
{
result = readLine("Please enter a valid integer.\n");
}
catch (out_of_range ex)
{
result = readLine("Number is too big.\n");
}
catch (...)
{
cout << "Something really bad happened." << endl;
}
}
return number;
}
| [
"[email protected]"
] | |
e381a7abfc444e09e9bf336726b947c97541be90 | 14228adc1f6f6a62b73a71ae9b77678315f92fce | /C++ Solutions/timus1083.cpp | 518aa8ff447b42f339ca8de3fe5361c1e1f0b77c | [
"MIT"
] | permissive | MrinmoiHossain/Timus-Oj | 6704fdc0993551d1d8149f6c71f32f8b53c4931e | f4561684a1625d4df26d563a9f533db3c7be9b48 | refs/heads/master | 2021-01-16T19:37:45.137329 | 2017-08-19T16:58:15 | 2017-08-19T16:58:15 | 100,185,028 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 263 | cpp | #include <bits/stdc++.h>
using namespace std;
int fact(int n, int k);
int main(void)
{
int n;
cin >> n;
string s;
cin >> s;
cout << fact(n, s.length()) << endl;
return 0;
}
int fact(int n, int k)
{
if(n <= 0)
return 1;
return n * fact(n - k, k);
}
| [
"[email protected]"
] | |
0d3c99307c515f3457de1771456e5a7d63e8df3d | 802e71f0fba696021f7e9e2bf11fdd7e72e48529 | /project/framework/Source/Graphics/Animation/AnimationChannel.h | d03238539d6b28c530291aa96748ee8dd4e49cef | [] | no_license | Supreeth55/Metronome | 7754e303dbe4c02282f865b2331865deaa19202a | 244a3f1b61a441ab3565137e32b7af3158e8373f | refs/heads/master | 2020-12-20T02:57:31.338973 | 2020-01-24T04:36:43 | 2020-01-24T04:36:43 | 235,939,199 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,494 | h | /**
* @file AnimationChannel.h
* @author Ching-Yen Lin.
* @date 9/21/19
* @brief Channel for animations
* Copyright (C) 2019 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior
written consent of DigiPen Institute of Technology is prohibited.
*/
#pragma once
//#define _HAS_STD_BYTE 0
#include "../../pch.h"
using namespace std;
struct PositionKey
{
PositionKey(double in_time, Vector3 in_V)
{
Time = in_time;
V = in_V;
}
double Time;
Vector3 V;
};
struct RotationKey
{
RotationKey(double in_time, Vector4 in_Q)
{
Time = in_time;
Q = in_Q;
}
double Time;
Vector4 Q;
};
struct ScalingKey
{
ScalingKey(double in_time, Vector3 in_S)
{
Time = in_time;
S = in_S;
}
double Time;
Vector3 S;
};
class AnimationChannel
{
public:
AnimationChannel();
~AnimationChannel();
/**
Adds position key
*/
void AddPositionKey(double time, float v0, float v1, float v2);
/**
Adds rotation key
*/
void AddRotationKey(double time, float v0, float v1, float v2, float v3);
/**
Adds addScaling key
*/
void AddScalingKey(double time, float v0, float v1, float v2);
/**
Interpolates the animation channel
*/
void Interpolate(float t);
Matrix tran;
private:
vector<PositionKey> vlist;
vector<RotationKey> qlist;
vector<ScalingKey> slist;
};
/**
Translation LERP
*/
Vector3 TranslationLERP(Vector3 v0, Vector3 v1, float t);
/**
Scale LERP
*/
Vector3 ScaleLERP(Vector3 s0, Vector3 s1, float t);
| [
"[email protected]"
] | |
de4426b5a85411257e8983ed917a87427693409f | e520ec1b73bc8d3f2cd8e152c0aedcfaab9681ec | /player-x-igameswf/libs/gameswf/gameswf/gameswf_as_classes/.svn/text-base/as_netconnection.h.svn-base | 9f364acdd60d0ae318ee61d48bb67834f0099f67 | [] | no_license | fallending/swfplayer-x | aec5199155d691e7a8b953e7be26d3a760a13732 | 80e03da2a9814eca791a0f644ed1541a84a48a2d | refs/heads/master | 2020-12-30T14:34:38.011647 | 2017-07-08T14:29:11 | 2017-07-08T14:29:11 | 91,070,589 | 7 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 779 | // as_netconnection.h -- Vitaly Alexeev <[email protected]> 2007
// This source code has been donated to the Public Domain. Do
// whatever you want with it.
#ifndef GAMESWF_NETCONNECTION_H
#define GAMESWF_NETCONNECTION_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gameswf/gameswf_action.h" // for as_object
namespace gameswf
{
void as_global_netconnection_ctor(const fn_call& fn);
struct as_netconnection : public as_object
{
// Unique id of a gameswf resource
enum { m_class_id = AS_NETCONNECTION };
virtual bool is(int class_id) const
{
if (m_class_id == class_id) return true;
else return as_object::is(class_id);
}
as_netconnection(player* player);
};
} // end of gameswf namespace
#endif
| [
"[email protected]"
] | ||
2384ec70981b59f2f89adf981e24818d03859f54 | d1ec47ff6acacb9f5368064e4c87f8d3770b016b | /contests/cf719/f.cpp | fe026af6eab4969d46020249942eca12b493f4e8 | [] | no_license | fj0rdingz/Competive_Programming | 8bca0870311b348ea4c38d134f73346edceadf15 | 3dc42a85b7c9f4e77ba8c5488d84fb0f1f3ac75c | refs/heads/master | 2021-10-29T02:25:52.820526 | 2021-10-25T06:23:29 | 2021-10-25T06:23:29 | 252,177,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,227 | cpp | // lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,mini=INF,sum=0,loop;
string str;
cin>>loop>>a>>k;
ll l=1;ll r=200001;
ll lzeros=0;
rep(_,loop){
ll med=r-l;
cout<<"? "<<l<<" "<<med<<endl;
cout.flush();
cin>>n;
//lzeros+=n;
if(k+lzeros>med-l) {
l=med+1;
lzeros+=n;
}else{
r=med;
}
}
cout<<"! "<<l<<endl;
return 0;
}
| [
"[email protected]"
] | |
026c0630e75eb20c2574f7617d8489530423c985 | 5b5ad3fbec0ac7c8b5506a69e7a3380ccbd194a7 | /C Programming (Home Practice)/programming/Exam/real number1.cpp | 4c92f90a7293eb2dccc6386d212449af6bd0f3ac | [] | no_license | CSEKU160212/C_Programming_And_Data_Structure | dd9e5736c0fdc5e443e438ca777554f5acb47420 | 6279d8c097e83fe5174ba33bfe3020abc9d87634 | refs/heads/master | 2021-01-01T07:59:08.373381 | 2017-08-03T10:27:50 | 2017-08-03T10:27:50 | 97,567,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 190 | cpp | #include<stdio.h>
#include<conio.h>
int main()
{
float m;
int n,p;
//clrscr();
printf("Enter the value of m\n");
scanf("%f",&m);
n=(m/1)+1;
p=m;
printf("%d %f %d",n,m,p);
getch();
}
| [
"[email protected]"
] | |
d24ed31c35aca76900ec89b9e739791a0d89d4ed | f0cadc6e99528a8f74c3a9ada97bbcdcd125e355 | /src/server/gameserver/EffectComa.h | 3a59377001f80aec4615eb801c83a0da88dbe542 | [] | no_license | najosky/opendarkeden_server | 0878f5a870224024b01c739822f00b072b1e08b9 | 3cb931caa151ff43d26dfb8fc727d268ae6e1409 | refs/heads/master | 2021-06-18T23:22:28.775384 | 2017-06-16T17:31:48 | 2017-06-16T17:31:48 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,059 | h | //////////////////////////////////////////////////////////////////////////////
// Filename : EffectComa.h
// Written by : excel96
// Description :
// 슬레이어나 뱀파이어가 죽었을 때, 걸리는 이펙트.
// 이 이펙트가 걸린 슬레이어는 움직일 수 없으며, 아이템 및 기술을 사용할
// 수 없으며, 말도 할 수 없다.
// (CGMove, CGUseItem, CGSkillTo..., CGSay)
//////////////////////////////////////////////////////////////////////////////
#ifndef __EFFECT_COMA__
#define __EFFECT_COMA__
#include "Effect.h"
#include "EffectLoader.h"
//////////////////////////////////////////////////////////////////////////////
// class EffectComa
//////////////////////////////////////////////////////////////////////////////
class EffectComa : public Effect
{
public:
EffectComa(Creature* pCreature) throw(Error);
~EffectComa() throw();
public:
EffectClass getEffectClass() const throw() { return EFFECT_CLASS_COMA; }
void affect() throw(Error);
void affect(Creature* pCreature) throw(Error);
void unaffect() throw(Error);
void unaffect(Creature* pCreature) throw(Error);
virtual void create(const string & ownerID) throw(Error);
virtual void save(const string & ownerID) throw(Error);
virtual void destroy(const string & ownerID) throw(Error);
string toString() const throw();
public:
Timeval getStartTime(void) const { return m_StartTime; }
void setStartTime(void);
bool canResurrect(void);
private:
Timeval m_StartTime;
};
//////////////////////////////////////////////////////////////////////////////
// class EffectComaLoader
//////////////////////////////////////////////////////////////////////////////
class EffectComaLoader : public EffectLoader
{
public:
virtual Effect::EffectClass getEffectClass() const throw() { return Effect::EFFECT_CLASS_COMA; }
virtual string getEffectClassName() const throw() { return "EffectComa"; }
public:
virtual void load(Creature* pCreature) throw(Error);
};
extern EffectComaLoader* g_pEffectComaLoader;
#endif // __EFFECT_COMA__
| [
"[email protected]"
] | |
ab34b0e3fd652b2842159d8122cafc885aa807d8 | 8afb5afd38548c631f6f9536846039ef6cb297b9 | /_REPO/MICROSOFT/cocos2d-x/cocos/2d/CCParticleExamples.h | 0b48b83203d74993e4ca5e3fe7dc51be14cc2a1a | [
"MIT"
] | permissive | bgoonz/UsefulResourceRepo2.0 | d87588ffd668bb498f7787b896cc7b20d83ce0ad | 2cb4b45dd14a230aa0e800042e893f8dfb23beda | refs/heads/master | 2023-03-17T01:22:05.254751 | 2022-08-11T03:18:22 | 2022-08-11T03:18:22 | 382,628,698 | 10 | 12 | MIT | 2022-10-10T14:13:54 | 2021-07-03T13:58:52 | null | UTF-8 | C++ | false | false | 11,663 | h | /****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2017 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPARTICLE_EXAMPLE_H__
#define __CCPARTICLE_EXAMPLE_H__
#include "2d/CCParticleSystemQuad.h"
NS_CC_BEGIN
/**
* @addtogroup _2d
* @{
*/
/** @class ParticleFire
* @brief A fire particle system.
*/
class CC_DLL ParticleFire : public ParticleSystemQuad
{
public:
/** Create a fire particle system.
*
* @return An autoreleased ParticleFire object.
*/
static ParticleFire* create();
/** Create a fire particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleFire object.
* @js NA
*/
static ParticleFire* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleFire(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFire(){}
bool init() override { return initWithTotalParticles(250); }
virtual bool initWithTotalParticles(int numberOfParticles) override;
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleFire);
};
/** @class ParticleFireworks
* @brief A fireworks particle system.
*/
class CC_DLL ParticleFireworks : public ParticleSystemQuad
{
public:
/** Create a fireworks particle system.
*
* @return An autoreleased ParticleFireworks object.
*/
static ParticleFireworks* create();
/** Create a fireworks particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleFireworks object.
* @js NA
*/
static ParticleFireworks* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleFireworks(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFireworks(){}
bool init(){ return initWithTotalParticles(1500); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleFireworks);
};
/** @class ParticleSun
* @brief A sun particle system.
*/
class CC_DLL ParticleSun : public ParticleSystemQuad
{
public:
/** Create a sun particle system.
*
* @return An autoreleased ParticleSun object.
*/
static ParticleSun* create();
/** Create a sun particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleSun object.
* @js NA
*/
static ParticleSun* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleSun(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSun(){}
bool init(){ return initWithTotalParticles(350); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSun);
};
/** @class ParticleGalaxy
* @brief A galaxy particle system.
*/
class CC_DLL ParticleGalaxy : public ParticleSystemQuad
{
public:
/** Create a galaxy particle system.
*
* @return An autoreleased ParticleGalaxy object.
*/
static ParticleGalaxy* create();
/** Create a galaxy particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleGalaxy object.
* @js NA
*/
static ParticleGalaxy* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleGalaxy(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleGalaxy(){}
bool init(){ return initWithTotalParticles(200); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleGalaxy);
};
/** @class ParticleFlower
* @brief A flower particle system.
*/
class CC_DLL ParticleFlower : public ParticleSystemQuad
{
public:
/** Create a flower particle system.
*
* @return An autoreleased ParticleFlower object.
*/
static ParticleFlower* create();
/** Create a flower particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleFlower object.
* @js NA
*/
static ParticleFlower* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleFlower(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleFlower(){}
bool init(){ return initWithTotalParticles(250); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleFlower);
};
/** @class ParticleMeteor
* @brief A meteor particle system.
*/
class CC_DLL ParticleMeteor : public ParticleSystemQuad
{
public:
/** Create a meteor particle system.
*
* @return An autoreleased ParticleMeteor object.
*/
static ParticleMeteor * create();
/** Create a meteor particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleMeteor object.
* @js NA
*/
static ParticleMeteor* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleMeteor(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleMeteor(){}
bool init(){ return initWithTotalParticles(150); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleMeteor);
};
/** @class ParticleSpiral
* @brief An spiral particle system.
*/
class CC_DLL ParticleSpiral : public ParticleSystemQuad
{
public:
/** Create a spiral particle system.
*
* @return An autoreleased ParticleSpiral object.
*/
static ParticleSpiral* create();
/** Create a spiral particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleSpiral object.
* @js NA
*/
static ParticleSpiral* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleSpiral(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSpiral(){}
bool init(){ return initWithTotalParticles(500); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSpiral);
};
/** @class ParticleExplosion
* @brief An explosion particle system.
*/
class CC_DLL ParticleExplosion : public ParticleSystemQuad
{
public:
/** Create a explosion particle system.
*
* @return An autoreleased ParticleExplosion object.
*/
static ParticleExplosion* create();
/** Create a explosion particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleExplosion object.
* @js NA
*/
static ParticleExplosion* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleExplosion(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleExplosion(){}
bool init(){ return initWithTotalParticles(700); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleExplosion);
};
/** @class ParticleSmoke
* @brief An smoke particle system.
*/
class CC_DLL ParticleSmoke : public ParticleSystemQuad
{
public:
/** Create a smoke particle system.
*
* @return An autoreleased ParticleSmoke object.
*/
static ParticleSmoke* create();
/** Create a smoke particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleSmoke object.
* @js NA
*/
static ParticleSmoke* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleSmoke(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSmoke(){}
bool init(){ return initWithTotalParticles(200); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSmoke);
};
/** @class ParticleSnow
* @brief An snow particle system.
*/
class CC_DLL ParticleSnow : public ParticleSystemQuad
{
public:
/** Create a snow particle system.
*
* @return An autoreleased ParticleSnow object.
*/
static ParticleSnow* create();
/** Create a snow particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleSnow object.
* @js NA
*/
static ParticleSnow* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleSnow(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleSnow(){}
bool init(){ return initWithTotalParticles(700); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleSnow);
};
/** @class ParticleRain
* @brief A rain particle system.
*/
class CC_DLL ParticleRain : public ParticleSystemQuad
{
public:
/** Create a rain particle system.
*
* @return An autoreleased ParticleRain object.
*/
static ParticleRain* create();
/** Create a rain particle system withe a fixed number of particles.
*
* @param numberOfParticles A given number of particles.
* @return An autoreleased ParticleRain object.
* @js NA
*/
static ParticleRain* createWithTotalParticles(int numberOfParticles);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ParticleRain(){}
/**
* @js NA
* @lua NA
*/
virtual ~ParticleRain(){}
bool init(){ return initWithTotalParticles(1000); }
virtual bool initWithTotalParticles(int numberOfParticles);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ParticleRain);
};
// end of _2d group
/// @}
NS_CC_END
#endif //__CCPARTICLE_EXAMPLE_H__
| [
"[email protected]"
] | |
16e40344df9c41264d031e5248f9d1162e0843ea | fe223b448abc77e89c458754e4251cc08467fd1a | /MFCApplication3/MFCApplication3.0/MFCApplication3.0.cpp | 92ed1c4bb06a80ef8a2bf04d443f7004c5972275 | [] | no_license | huaijian566/Experiment | 0de98ed5ae676d0f09ec48e610e1e2e573310b79 | 6cbe4b52691f2a9762f4087c170bed7fe714858f | refs/heads/master | 2021-04-14T08:58:34.885089 | 2020-05-05T15:10:14 | 2020-05-05T15:10:14 | 249,219,948 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,654 | cpp |
// MFCApplication3.0.cpp : 定义应用程序的类行为。
//
#include "stdafx.h"
#include "afxwinappex.h"
#include "afxdialogex.h"
#include "MFCApplication3.0.h"
#include "MainFrm.h"
#include "MFCApplication3.0Doc.h"
#include "MFCApplication3.0View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMFCApplication30App
BEGIN_MESSAGE_MAP(CMFCApplication30App, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CMFCApplication30App::OnAppAbout)
// 基于文件的标准文档命令
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
END_MESSAGE_MAP()
// CMFCApplication30App 构造
CMFCApplication30App::CMFCApplication30App()
{
// 支持重新启动管理器
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
#ifdef _MANAGED
// 如果应用程序是利用公共语言运行时支持(/clr)构建的,则:
// 1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。
// 2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
#endif
// TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式
//为 CompanyName.ProductName.SubProduct.VersionInformation
SetAppID(_T("MFCApplication3.0.AppID.NoVersion"));
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}
// 唯一的一个 CMFCApplication30App 对象
CMFCApplication30App theApp;
// CMFCApplication30App 初始化
BOOL CMFCApplication30App::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。 文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMFCApplication30Doc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CMFCApplication30View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。 如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
int CMFCApplication30App::ExitInstance()
{
//TODO: 处理可能已添加的附加资源
AfxOleTerm(FALSE);
return CWinApp::ExitInstance();
}
// CMFCApplication30App 消息处理程序
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// 用于运行对话框的应用程序命令
void CMFCApplication30App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CMFCApplication30App 消息处理程序
| [
"[email protected]"
] | |
aa10c11ee6bb12092f65255901f6beb4a7037140 | 45014139581f1211a43b6415a6ee32d442c29fc0 | /src/ozone/ui/desktop_aura/desktop_drag_drop_client_wayland.h | 5816ad232fc9dba81f75bd9b7b026d8953e0f1ce | [
"BSD-3-Clause"
] | permissive | webosose/chromium91 | a31b847e64391c3de98ca5b6dac3ac247d393e78 | b28e2ae83ee2e4907a36a49a4c0f054aa386dbfa | refs/heads/master | 2022-12-12T09:32:30.580155 | 2022-09-01T09:02:15 | 2022-09-18T23:58:11 | 460,692,960 | 1 | 5 | null | 2022-10-05T07:19:39 | 2022-02-18T03:16:04 | null | UTF-8 | C++ | false | false | 7,709 | h | // Copyright 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef OZONE_IMPL_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_WAYLAND_H_
#define OZONE_IMPL_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_WAYLAND_H_
#include <list>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/window_observer.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/gfx/geometry/point.h"
#include "ui/platform_window/platform_window.h"
#include "ui/views/views_export.h"
namespace views {
class VIEWS_EXPORT DesktopDragDropClientWayland
: public aura::client::DragDropClient,
public aura::WindowObserver {
public:
explicit DesktopDragDropClientWayland(aura::Window* root_window,
ui::PlatformWindow* platform_window);
DesktopDragDropClientWayland(const DesktopDragDropClientWayland&) = delete;
DesktopDragDropClientWayland& operator=(const DesktopDragDropClientWayland&) =
delete;
~DesktopDragDropClientWayland() override;
// Overridden from aura::client::DragDropClient:
int StartDragAndDrop(std::unique_ptr<ui::OSExchangeData> data,
aura::Window* root_window,
aura::Window* source_window,
const gfx::Point& screen_location,
int operation,
ui::mojom::DragEventSource source) override;
void DragCancel() override;
bool IsDragDropInProgress() override;
void AddObserver(aura::client::DragDropClientObserver* observer) override;
void RemoveObserver(aura::client::DragDropClientObserver* observer) override;
// Overridden from void aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
// Events received via IPC from the WaylandDataSource in the GPU process.
void OnDragEnter(gfx::AcceleratedWidget windowhandle,
float x,
float y,
const std::vector<std::string>& mime_types,
uint32_t serial);
void OnDragDataReceived(int pipefd);
void OnDragLeave();
void OnDragMotion(float x, float y, uint32_t time);
void OnDragDrop();
private:
// Used to build up an OSExchangeDataProvider and pass it to the
// DragDropDelegate of the target window. This requires round-tripping between
// the browser process and the GPU process once for each type of data to be
// stored in the OSExchangeDataProvider. The GPU process will pass us a file
// descriptor to read the data from, then once the read has completed we will
// close the descriptor and indicate to the GPU process that it is safe to
// request the next file descriptor. This has to happen one-by-one because
// some Wayland clients (e.g. GTK+ applications) expect that after calling
// wl_data_offer_receive() (in the GPU process), we will drain the received
// file descriptor of all data and close it before calling
// wl_data_offer_receive() again. We could read from the pipe either
// asynchronously in the IO thread, or synchronously in the user-blocking file
// thread. The file thread was chosen for simplicity. Either way, a
// RefCountedThreadSafe container is required, since there is a very small
// window in which a DesktopDragDropClientWayland could theoretically be
// destroyed in the middle of an ongoing drag operation, and the drag could be
// cancelled before all data has been received. Note also that a
// DragDataCollector corresponds to exactly one outstanding drag-and-drop
// and should not be reused for a second drag-and-drop session.
class DragDataCollector
: public base::RefCountedThreadSafe<DragDataCollector>,
public base::SupportsWeakPtr<DragDataCollector> {
public:
DragDataCollector(
base::WeakPtr<DesktopDragDropClientWayland> drag_drop_client,
const std::vector<std::string>& mime_types,
gfx::AcceleratedWidget windowhandle);
// DragDropDataController assumes ownership of |pipefd| and will ensure it
// is closed exactly once.
void SetPipeFd(int pipefd);
int GetPipeFd() const { return pipefd_; }
std::string first_received_mime_type() const {
return first_received_mime_type_;
}
bool IsReadingData() const;
void HandleNextMimeType();
const ui::OSExchangeData& GetData() const { return os_exchange_data_; }
// Synchronously read drag-and-drop data from the source process.
static void ReadDragData(scoped_refptr<DragDataCollector>);
private:
friend class base::RefCountedThreadSafe<DragDataCollector>;
~DragDataCollector();
// Returns the next MIME type to be received from the source process, or an
// empty string if there are no more interesting MIME types left to process.
std::string SelectNextMimeType();
base::WeakPtr<DesktopDragDropClientWayland> drag_drop_client_;
ui::OSExchangeData os_exchange_data_;
std::list<std::string> unprocessed_mime_types_;
std::string first_received_mime_type_;
int pipefd_ = 0;
};
public:
// Called by the DragDataCollector when all drag data has been received.
void OnDragDataCollected(DragDataCollector* collector);
private:
// Returns a DropTargetEvent to be passed to the DragDropDelegate, or null to
// abort the drag, using the location of point_ if no root location is passed.
std::unique_ptr<ui::DropTargetEvent> CreateDropTargetEvent(
const gfx::Point& point) const;
std::unique_ptr<ui::DropTargetEvent> CreateDropTargetEvent() const;
void DragDropSessionCompleted();
// Use to provide feedback to the source process on whether the drag will be
// accepted for the current coordinates and available mime types. This might
// be used to change the cursor, for example.
void IndicateDragWillBeAccepted();
void IndicateDragWillBeRejected();
// Valid between the start of a drag operation and when the process of reading
// drag-and-drop data from the source process has completed. No drag events
// can be sent to the DragDropDelegate until all data has been collected.
scoped_refptr<DragDataCollector> data_collector_;
// Unique identifier for the current drag.
uint32_t serial_ = 0;
// Window handle for active drag, or 0 if there is no active drag.
unsigned windowhandle_ = 0;
aura::Window& root_window_;
ui::PlatformWindow& platform_window_;
// Null unless all drag data has been received and the drag is unfinished.
aura::Window* target_window_;
// The most recent native coordinates of a drag.
gfx::Point point_;
// This is the interface that allows us to send drag events from Ozone-Wayland
// to the cross-platform code.
aura::client::DragDropDelegate* delegate_;
// The Wayland sends a drag leave event after a drag drop event, but the
// DragDropDelegate expects only one or the other. This is set to false after
// a successful drop to indicate that the drag leave event should not be
// passed on to the DragDropDelegate.
bool should_emit_drag_exited_ = true;
// Used to keep track of whether IndicateDragWillBeAccepted or
// IndicateDragWillBeRejected was most-recently called.
bool did_most_recently_accept_drag_ = false;
// Null except when a drop has occured but drag data is still being read.
std::unique_ptr<gfx::Point> delayed_drop_location_;
base::WeakPtrFactory<DesktopDragDropClientWayland> weak_ptr_factory_;
};
} // namespace views
#endif // OZONE_IMPL_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_WAYLAND_H_
| [
"[email protected]"
] | |
70ab3887c3d603c0c31a45914f2e08a5ebfb6dd0 | e1071cd8065ed01b8bc42f5f47f964837ec723b8 | /src/ripple/nodestore/backend/NullFactory.cpp | 3e916cf8ea057f016d313a0ee76d565f665fe60f | [
"MIT-Wu",
"MIT",
"ISC",
"BSL-1.0"
] | permissive | SAN-CHAIN/sand | 07355acf0ba4607a5cb1408a1d86d87f03e3a317 | 1c51a7d1b215a7a2e1e06bd3b87a7e1da7239664 | refs/heads/master | 2020-06-22T01:27:21.168067 | 2016-10-15T11:22:18 | 2016-10-15T11:22:18 | 94,208,495 | 0 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 2,939 | cpp | //------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or 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 DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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 <BeastConfig.h>
#include <ripple/nodestore/Factory.h>
#include <ripple/nodestore/Manager.h>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple {
namespace NodeStore {
class NullBackend : public Backend
{
public:
NullBackend ()
{
}
~NullBackend ()
{
}
std::string
getName()
{
return std::string ();
}
void
close() override
{
}
Status
fetch (void const*, std::shared_ptr<NodeObject>*)
{
return notFound;
}
bool
canFetchBatch() override
{
return false;
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch (std::size_t n, void const* const* keys) override
{
throw std::runtime_error("pure virtual called");
return {};
}
void
store (std::shared_ptr<NodeObject> const& object)
{
}
void
storeBatch (Batch const& batch)
{
}
void
for_each (std::function <void(std::shared_ptr<NodeObject>)> f)
{
}
int
getWriteLoad ()
{
return 0;
}
void
setDeletePath() override
{
}
void
verify() override
{
}
private:
};
//------------------------------------------------------------------------------
class NullFactory : public Factory
{
public:
NullFactory()
{
Manager::instance().insert(*this);
}
~NullFactory()
{
Manager::instance().erase(*this);
}
std::string
getName () const
{
return "none";
}
std::unique_ptr <Backend>
createInstance (
size_t,
Section const&,
Scheduler&, beast::Journal)
{
return std::make_unique <NullBackend> ();
}
};
static NullFactory nullFactory;
}
}
| [
"[email protected]"
] | |
57f2da798a7753683aa77bf86dca10bed0d3a1f8 | 41c47786101f8bce66a39a99866d735230c41d19 | /CSC 461/PA5/RVO/No_RVO.cpp | d741577e57818dbca51d97891f776ef2aa56bc89 | [] | no_license | brianabauman/depaul | 2ef5913db9372dabf5522317ca5975f830212665 | c9162e17ad63228046ba4dc7017b8e00acf9fc31 | refs/heads/main | 2023-05-10T14:48:28.840279 | 2021-06-09T19:19:12 | 2021-06-09T19:19:12 | 375,392,462 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,584 | cpp | //-----------------------------------------------------------------------------
// Copyright Ed Keenan 2019
//-----------------------------------------------------------------------------
#include "No_RVO.h"
// DO NOT CHANGE THIS FILE
Vect2D_No_RVO::Vect2D_No_RVO()
: x(0.0f), y(0.0f)
{
};
Vect2D_No_RVO::Vect2D_No_RVO(const float inX, const float inY)
{
this->x = inX;
this->y = inY;
};
Vect2D_No_RVO::~Vect2D_No_RVO()
{
};
void Vect2D_No_RVO::setX(const float inX)
{
this->x = inX;
};
void Vect2D_No_RVO::setY(const float inY)
{
this->y = inY;
};
void Vect2D_No_RVO::set(const float inX, const float inY)
{
this->x = inX;
this->y = inY;
};
float Vect2D_No_RVO::getX() const
{
return this->x;
};
float Vect2D_No_RVO::getY() const
{
return this->y;
};
Vect2D_No_RVO Vect2D_No_RVO::operator + (const Vect2D_No_RVO &tmp) const
{
Vect2D_No_RVO sum;
sum.x = this->x + tmp.x;
sum.y = this->y + tmp.y;
return (sum);
};
Vect2D_No_RVO Vect2D_No_RVO::operator - (const Vect2D_No_RVO &tmp) const
{
Vect2D_No_RVO sum;
sum.x = this->x - tmp.x;
sum.y = this->y - tmp.y;
return (sum);
};
Vect2D_No_RVO Vect2D_No_RVO::operator * (const float scale) const
{
Vect2D_No_RVO tmp;
tmp.x = this->x * scale;
tmp.y = this->y * scale;
return (tmp);
};
// Assume scale != 0.0f
Vect2D_No_RVO Vect2D_No_RVO::operator / (const float scale) const
{
Vect2D_No_RVO tmp;
tmp.x = this->x / scale;
tmp.y = this->y / scale;
return (tmp);
};
// --- End of File ---------------
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.