text stringlengths 1 1.05M |
|---|
.segment "INIT"
.segment "STARTUP"
.segment "ONCE"
.segment "CODE"
.data
start_data:
.code
;=================================================
;=================================================
;
; Headers
;
;-------------------------------------------------
.include "debug.inc"
.include "vera.inc"
.include "system.inc"
.include "math.inc"
.include "kernal.inc"
;=================================================
; Macros
;
;-------------------------------------------------
DEFAULT_SCREEN_ADDR = 0
DEFAULT_SCREEN_SIZE = (128*64)*2
;=================================================
;=================================================
;
; main code
;
;-------------------------------------------------
.code
start:
SYS_INIT_BANK
SYS_INIT_IRQ
SYS_RAND_SEED $34, $56, $fe
SYS_CONFIGURE_MOUSE 0
jsr graphics_init
jsr math_init
lda #2
jsr graphics_fade_out
jsr splash_do
jmp *
;=================================================
;=================================================
;
; Libs
;
;-------------------------------------------------
.include "system.asm"
.include "graphics.asm"
.include "splash.asm"
.include "vera.asm"
.include "math.asm"
.code
DEBUG_LABEL end_of_code |
; LZEee depacker for Z80 sjasm (lzee with f5 option) 72bytes
;
; license:zlib license
;
; Copyright (c) 2020 uniabis
;
; 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.
;
;DEFINE OBSOLETED_F4
;DEFINE ALLOW_LDIR_UNROLLING
;DEFINE ALLOW_INLINE_GETBIT
IFNDEF ALLOW_INLINE_GETBIT
MACRO GET_BIT
call getbit
ENDM
ELSE
MACRO GET_BIT
add a
call z,getbit
ENDM
ENDIF
dlzeee:
ld a,080h
dlze_lp1:
ldi
dlze_lp2:
GET_BIT
jr nc,dlze_lp1
GET_BIT
jr c,dlze_far
ld c,0
GET_BIT
rl c
GET_BIT
rl c
push hl
ld l,(hl)
ld h,-1
dlze_copy:
ld b,0
inc c
add hl,de
IFNDEF ALLOW_LDIR_UNROLLING
inc bc
ldir
ELSE
ldir
ldi
ENDIF
pop hl
inc hl
jr dlze_lp2
dlze_far:
ex af, af';'
ld a,(hl)
or 7
rrca
rrca
rrca
ld b,a
ld a,(hl)
inc hl
ld c,(hl)
and 7
jr nz,dlze_skip
inc hl
or (hl)
ret z
IFNDEF OBSOLETED_F4
ELSE
dec a
ENDIF
dlze_skip:
push hl
ld l,c
ld h,b
ld c,a
ex af, af';'
jr dlze_copy
getbit:
IFNDEF ALLOW_INLINE_GETBIT
add a
ret nz
ENDIF
ld a,(hl)
inc hl
adc a
ret
|
; asmsyntax=nasm
; This GDT does not support multitasking.
; Borrowed with love from a prior operating system development excursion.
; https://github.com/duckinator/dux/blob/main/src/lib/hal/gdt.asm
bits 32
global hal_gdt_init
extern stack_top
section .text
hal_gdt_init:
; Load the GDT and reload cs to 0x8 with a far jump to the next line.
; The code there reloads ds, es, fs, gs, and ss with 0x10.
; See the comments in the GDT for what 0x8 and 0x10 do.
lgdt [_gdt_desc]
jmp 0x8:.reload
.reload:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Load the TSS. Some docs are in the Intel manuals and
; http://wiki.osdev.org/Task_State_Segment
; Fill in the fields of the GDT discriptor for the TSS.
mov eax, _tss_begin ; Beginning of the TSS.
mov ebx, [_tss_end - _tss_begin] ; Size of the TSS.
; The first 16 bits of the limit (size of TSS).
mov ecx, ebx
and ecx, 0xff
mov esi, _gdt_tss
mov word [ds:esi], cx
; The last 4 bits of the limit.
mov ecx, ebx
shl ecx, 16
and ecx, 0xf
mov esi, [_gdt_tss + 6]
mov byte dl, [ds:esi]
or dl, cl
mov byte [ds:esi], dl
; The first 16 bits of the base (location of TSS).
mov ecx, eax
and ecx, 0xffff
mov esi, [_gdt_tss + 2]
mov word [ds:esi], cx
; The middle 8 bits of the base.
mov ecx, eax
shl ecx, 16
and ecx, 0xff
mov esi, [_gdt_tss + 4]
mov byte [ds:esi], cl
; The last 8 bits of the base.
mov ecx, eax
shl ecx, 24
and ecx, 0xff
mov esi, [_gdt_tss + 7]
mov byte [ds:esi], cl
; Now that the GDT is in place, fill in the stack data in the TSS.
; Load ESP0.
mov esi, 4
mov dword [ds:esi], eax
; Load SS0.
mov ax, 0x10
mov esi, 8
mov word [ds:esi], ax
; Load the now-valid TSS into the task register.
; The TSS is at offset 28 in the GDT.
mov ax, 0x28
ltr ax
ret
section .data
_gdt_begin:
; For reference, the format of the GDT can be found in both the
; Intel 64/IA-32 manuals and on http://wiki.osdev.org/GDT
_gdt_null: ; 0x0
dq 0
_gdt_code: ; 0x8
dw 0xffff
dw 0x0
db 0x0
db 10011010b
db 11001111b
db 0x0
_gdt_data: ; 0x10
dw 0xffff
dw 0x0
db 0x0
db 10010010b
db 11001111b
db 0x0
_gdt_user_code: ; 0x18
dw 0xffff
dw 0x0
db 0x0
db 11111010b
db 11001111b
db 0x0
_gdt_user_data: ; 0x20
dw 0xffff
dw 0x0
db 0x0
db 11110010b
db 11001111b
db 0x0
_gdt_tss: ; 0x28
dw 0x0000
dw 0x0
db 0x0
db 10001001b
db 01000000b
db 0x0
_gdt_end:
_gdt_desc:
dw _gdt_end - _gdt_begin - 1
dd _gdt_begin
_tss_begin:
; The entire TSS is set to 0 by default.
times 36 dw 0x0
._tss_data_end:
dw ._tss_data_end - _tss_begin
_tss_end:
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtNetwork>
#include <stdio.h>
#include <string.h>
#include "ui_mainwindow.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QFile>
#include "codificador.h"
#define TOPEVECTOR 200
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_pushButton_2_clicked()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::on_pushButton_3_clicked()
{
ui->stackedWidget->setCurrentIndex(2);
}
void MainWindow::on_pushButton_4_clicked()
{
ui->stackedWidget->setCurrentIndex(3);
}
void MainWindow::on_pushButton_5_clicked()
{
ui->stackedWidget->setCurrentIndex(4);
}
void MainWindow::on_pushButton_7_clicked()
{
ui->dock_albergue->setCurrentIndex(0);
}
void MainWindow::on_pushButton_8_clicked()
{
ui->dock_albergue->setCurrentIndex(2);
}
void MainWindow::on_pushButton_9_clicked()
{
ui->dock_albergue->setCurrentIndex(3);
}
void MainWindow::on_pushButton_10_clicked()
{
ui->dock_albergue->setCurrentIndex(1);
}
void MainWindow::on_pushButton_11_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(this, tr("Open File"),"/path/to/file/",tr("TXT Files (*.txt)"));
cargarArchivo(fileNames);
ui->lineEdit->setText(fileNames);
}
void MainWindow::cargarArchivo(QString ruta)
{
fstream ficheroEntrada;//para leer el archivo
string linea;//
archivito="";
archivo="";
ficheroEntrada.open(ruta.toStdString(), ios::in);//abrimos el archivo con su ubicacion
while (! ficheroEntrada.eof() ) {
getline(ficheroEntrada,linea);//leemos linea por linea el archivo
//archivo.append(QString::fromStdString(linea));//lo adjuntamos al archivo
archivito+=linea;
// qInfo()<<QString::fromStdString(linea);
}
ficheroEntrada.close();
}
void MainWindow::on_pushButton_12_clicked()
{
ListaSimple lst;
string st = archivito;
char str[st.length()+1];
strcpy(str, st.c_str());
char * pch;
//printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str,";");
while (pch != NULL)
{
std::string someString(pch);
lst.agregar(someString);
pch = strtok (NULL, ";");
}
qInfo()<<"Numero de elementos a insertar: "<<lst.size;
nodo *temporal = lst.first;
while(temporal!=nullptr){
ListaSimple lst2;
string st2= temporal->getDato();
char str2[st2.length()+1];
strcpy(str2, st2.c_str());
char *pch2;
//printf ("Splitting string \"%s\" into tokens:\n",str);
qInfo()<<"";
pch2 = strtok (str2,",");
while (pch2 != NULL)
{
std:: string str(pch2);
std::string someString=Decodificar(str);
lst2.agregar(someString);
pch2 = strtok (NULL, ",");
}
nodo *temp = lst2.first;
while(temp!=nullptr){
if(temp==lst2.first)
archivo.append(QString::fromStdString(temp->dato));
else
archivo.append(","+QString::fromStdString(temp->dato));
temp = temp->siguiente;
}
archivo.append(";");
temporal=temporal->siguiente;
}
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/setLocalidad") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.post(req,archivo);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
QNetworkReply *respuesta= mgr.get(req);
eventLoop.exec();
qDebug() << "Success" << respuesta->readAll();
delete respuesta;
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
string MainWindow::Codificar(string str)
{
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
string resultado;
for(int i=0; i<str.length();i++){
//qInfo()<<str[i];
switch (str[i]) {
case 'a':
resultado+="k";
break;
case 'b':
resultado+="j";
break;
case 'c':
resultado+="r";
break;
case 'd':
resultado+="s";
break;
case 'e':
resultado+="z";
break;
case 'f':
resultado+="v";
break;
case 'g':
resultado+="a";
break;
case 'h':
resultado+="c";
break;
case 'i':
resultado+="b";
break;
case 'j':
resultado+="g";
break;
case 'k':
resultado+="h";
break;
case 'l':
resultado+="o";
break;
case 'm':
resultado+="q";
break;
case 'n':
resultado+="m";
break;
case 'o':
resultado+="d";
break;
case 'p':
resultado+="n";
break;
case 'q':
resultado+="t";
break;
case 'r':
resultado+="x";
break;
case 's':
resultado+="i";
break;
case 't':
resultado+="e";
break;
case 'u':
resultado+="y";
break;
case 'v':
resultado+="f";
break;
case 'w':
resultado+="l";
break;
case 'x':
resultado+="p";
break;
case 'y':
resultado+="u";
break;
case 'z':
resultado+="w";
break;
case 0x30:
resultado+="=";
break;
case 0x31:
resultado+="!";
break;
case 0x32:
resultado+="@";
break;
case 0x33:
resultado+="(";
break;
case 0x34:
resultado+=")";
break;
case 0x35:
resultado+="$";
break;
case 0x36:
resultado+="#";
break;
case 0x37:
resultado+=":";
break;
case 0x38:
resultado+="+";
break;
case 0x39:
resultado+="*";
break;
case '.':
resultado+="^";
break;
case '/':
resultado+="_";
break;
case '-':
resultado+=">";
default:
//resultado+=str[i];
break;
}
}
//qInfo()<<"palabra a codificar "<<QString::fromStdString(str)<<" palabra codificada: "<<QString::fromStdString(resultado);
return resultado;
}
string MainWindow::Decodificar(string str)
{
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
string resultado;
for(int i=0; i<str.length();i++){
//qInfo()<<str[i];
switch (str[i]) {
case 'k':
resultado+="a";
break;
case 'j':
resultado+="b";
break;
case 'r':
resultado+="c";
break;
case 's':
resultado+="d";
break;
case 'z':
resultado+="e";
break;
case 'v':
resultado+="f";
break;
case 'a':
resultado+="g";
break;
case 'c':
resultado+="h";
break;
case 'b':
resultado+="i";
break;
case 'g':
resultado+="j";
break;
case 'h':
resultado+="k";
break;
case 'o':
resultado+="l";
break;
case 'q':
resultado+="m";
break;
case 'm':
resultado+="n";
break;
case 'd':
resultado+="o";
break;
case 'n':
resultado+="p";
break;
case 't':
resultado+="q";
break;
case 'x':
resultado+="r";
break;
case 'i':
resultado+="s";
break;
case 'e':
resultado+="t";
break;
case 'y':
resultado+="u";
break;
case 'f':
resultado+="v";
break;
case 'l':
resultado+="w";
break;
case 'p':
resultado+="x";
break;
case 'u':
resultado+="y";
break;
case 'w':
resultado+="z";
break;
case '=':
resultado+="0";
break;
case '!':
resultado+="1";
break;
case '@':
resultado+="2";
break;
case '(':
resultado+="3";
break;
case ')':
resultado+="4";
break;
case '$':
resultado+="5";
break;
case '#':
resultado+="6";
break;
case ':':
resultado+="7";
break;
case '+':
resultado+="8";
break;
case '*':
resultado+="9";
break;
case '^':
resultado+=".";
break;
case '_':
resultado+="/";
break;
case '>':
resultado+="-";
default:
//resultado+=str[i];
break;
}
}
//qInfo()<<"palabra a codificar "<<QString::fromStdString(str)<<" palabra codificada: "<<QString::fromStdString(resultado);
return resultado;
}
void MainWindow::on_pushButton_13_clicked()
{
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/getLocalidades") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << "Success: Localidades traidas con exito";
escribirArchivo(reply->readAll());
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::escribirArchivo(QByteArray cuerpo)
{
ofstream ficheroSalida;
ficheroSalida.open ("/home/andree/Escritorio/EDDArchivos/localidades.txt");
ficheroSalida << cuerpo.toStdString();
ficheroSalida.close();
}
void MainWindow::on_pushButton_16_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(this, tr("Open File"),"/path/to/file/",tr("TXT Files (*.txt)"));
cargarArchivo(fileNames);
ui->lineEdit_2->setText(fileNames);
}
void MainWindow::on_pushButton_14_clicked()
{
ListaSimple lst;
string st = archivito;
char str[st.length()+1];
strcpy(str, st.c_str());
char * pch;
//printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str,";");
while (pch != NULL)
{
std::string someString(pch);
lst.agregar(someString);
pch = strtok (NULL, ";");
}
qInfo()<<"Numero de elementos a insertar: "<<lst.size;
nodo *temporal = lst.first;
while(temporal!=nullptr){
ListaSimple lst2;
string st2= temporal->getDato();
char str2[st2.length()+1];
strcpy(str2, st2.c_str());
char *pch2;
//printf ("Splitting string \"%s\" into tokens:\n",str);
qInfo()<<"";
pch2 = strtok (str2,",");
while (pch2 != NULL)
{
std:: string str(pch2);
std::string someString=Decodificar(str);
lst2.agregar(someString);
pch2 = strtok (NULL, ",");
}
nodo *temp = lst2.first;
while(temp!=nullptr){
if(temp==lst2.first)
archivo.append(QString::fromStdString(temp->dato));
else
archivo.append(","+QString::fromStdString(temp->dato));
temp = temp->siguiente;
}
archivo.append(";");
temporal=temporal->siguiente;
}
qInfo()<<archivo;
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/setDonacion") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.post(req,archivo);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
QNetworkReply *respuesta= mgr.get(req);
eventLoop.exec();
qDebug() << "Success" << respuesta->readAll();
delete respuesta;
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_btn_agregarFamilia_clicked()
{
QString codigo=ui->familia_albergue->text();
QString nombre = ui->nombre_familia->text();
QString apellido = ui->apellidos_familia->text();
QString edad = ui->edad_familia->text();
QString genero = ui->genero_familia->text();
Persona *nuevo = new Persona(codigo,edad,nombre,apellido,genero);
Familia nueva(codigo);
nueva.arbol->insert(codigo.toInt(),nuevo);
nueva.arbol->impreArbol();
lstfamilias.agregar(nueva);
}
void MainWindow::on_btn_agregarPersona_clicked()
{
QString familia = ui->dpi_familia->text();
QString codigo = ui->dpi_individuo->text();
QString nombre = ui->nombre_individuo->text();
QString apellido = ui->apellidos_individuo->text();
QString edad = ui->edad_individuo->text();
QString genero = ui->genero_individuo->text();
Persona *nuevo = new Persona(codigo,edad,nombre,apellido,genero);
if(lstfamilias.existe(familia)==true){
Familia getFamilia = lstfamilias.buscar(familia);
getFamilia.arbol->insert(codigo.toInt(),nuevo);
getFamilia.arbol->impreArbol();
}
}
void MainWindow::on_pushButton_18_clicked()
{
ui->Cfamilia_modificar->clear();
if(lstfamilias.first==nullptr){}
else{
nodo2 *temporal = lstfamilias.first;
while(temporal!=nullptr){
ui->Cfamilia_modificar->addItem(temporal->getDato().codigo);
temporal = temporal->siguiente;
}
}
}
void MainWindow::llenarCombo(nodoABB *pivote)
{
//se verifica si la raiz es nula
if(pivote==nullptr)
return;
llenarCombo(pivote->izquierda);
// qInfo()<<'\t'<<pivote->key;
ui->cIndividuo_modificar->addItem(QString::number(pivote->key));
llenarCombo(pivote->derecha);
}
void MainWindow::on_Cfamilia_modificar_currentIndexChanged(int index)
{
key= index;
}
void MainWindow::on_cIndividuo_modificar_currentIndexChanged(int index)
{
key2=index;
QString codigo = ui->cIndividuo_modificar->itemText(index);
QString fami= ui->Cfamilia_modificar->itemText(key);
//qInfo()<<codigo<<"-"<<fami;
Familia temp= lstfamilias.buscar(fami);
bool temporal = temp.arbol->existe(codigo.toInt(),temp.arbol->raiz);
qInfo()<<temporal;
if(temporal==true){
Persona *nuevo = temp.arbol->buscar(codigo.toInt());
qInfo()<< nuevo->nombre;
ui->nombre_modificar->setText(nuevo->nombre);
ui->apellidos_modificar->setText(nuevo->apellido);
ui->edad_modificar->setText(nuevo->edad);
ui->genero_modificar->setText(nuevo->genero);
}
}
void MainWindow::on_pushButton_19_clicked()
{
ui->cIndividuo_modificar->clear();
QString codigo = ui->Cfamilia_modificar->itemText(key);
llenarCombo(lstfamilias.buscar(codigo).arbol->raiz);
}
void MainWindow::on_pushButton_20_clicked()
{
lstfamilias.buscar( ui->Cfamilia_modificar->itemText(key)).arbol->impreArbol();
}
void MainWindow::on_pushButton_17_clicked()
{
QString codigo = ui->cIndividuo_modificar->itemText(key2);
QString fami= ui->Cfamilia_modificar->itemText(key);
qInfo()<<codigo<<"-"<<fami;
bool temporal = lstfamilias.buscar(fami).arbol->existe(codigo.toInt(),lstfamilias.buscar(fami).arbol->raiz);
qInfo()<<temporal;
if(temporal==true){
Persona *nuevo = lstfamilias.buscar(fami).arbol->buscar(codigo.toInt());
nuevo->apellido=ui->apellidos_modificar->text();
nuevo->nombre=ui->nombre_modificar->text();
nuevo->edad=ui->edad_modificar->text();
nuevo->genero=ui->genero_modificar->text();
}
}
void MainWindow::on_eliminar_familia_clicked()
{
qInfo()<< lstfamilias.eliminar(ui->cFamilia_eliminar->itemText(key));
lstfamilias.imprimir();
}
void MainWindow::on_cFamilia_eliminar_currentIndexChanged(int index)
{
key = index;
}
void MainWindow::on_Cindividuo_eliminar_currentIndexChanged(int index)
{
key2=index;
}
void MainWindow::on_pushButton_21_clicked()
{
ui->cFamilia_eliminar->clear();
nodo2 *temporal = lstfamilias.first;
while(temporal!=nullptr){
ui->cFamilia_eliminar->addItem(temporal->dato.codigo);
temporal=temporal->siguiente;
}
}
void MainWindow::on_pushButton_6_clicked()
{
ui->stackedWidget->setCurrentIndex(5);
}
void MainWindow::on_pushButton_23_clicked()
{
QJsonDocument doc;
ui->puntoa->clear();
ui->puntob->clear();
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/getGrafo") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
QByteArray json;
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << "Localidades traidas";
//escribirArchivo(reply->readAll());
json=reply->readAll();
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
ofstream ff;
ff.open ("/home/andree/Escritorio/EDDArchivos/localidades.json");
ff <<json.toStdString();
ff.close();
doc=QJsonDocument::fromJson(json);
QFile defaultTextFile("/home/andree/Escritorio/EDDArchivos/mapa.html");
defaultTextFile.open(QIODevice::ReadOnly);
QString html = defaultTextFile.readAll();
QString markers = "";
//QString json = ui->textEdit->toPlainText();
//json = tr("[{\"donador\":\"%1\",\"monto\":%2,\"voucher\":\"%3\"},{\"donador\":\"%1\",\"monto\":%2,\"voucher\":\"%3\"}]").arg(1, 2, 3);
//qInfo()<<json.toUtf8();
//QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
qInfo()<< doc.isArray();
if(doc.isArray()){
QJsonArray array = doc.array();
//qInfo()<<array.size();
for(int i = 0; i < array.size(); i++){
QJsonObject elem = array[i].toObject();
/*
var marker = new google.maps.Marker({
map: map,
position: {14.0, -90.0},
title: 'Hello World!'
});*/
ui->puntoa->addItem(elem["codigo"].toString());
ui->puntob->addItem(elem["codigo"].toString());
markers.append(QString("var marker%1 = new google.maps.Marker({map: map,position: {lat:%2, lng:%3},title: '%4',icon:image});\n")
.arg(
QString::number(i),
QString::number(elem["lat"].toDouble()),
QString::number(elem["lng"].toDouble()),
elem["codigo"].toString()
));
}
}
//markers.append(QString("var marker3 = new google.maps.Marker({position: myLatLng,map: map,title: 'Hello World!',icon:image});\n \t\t\t\t"));
//markers.append(QString("var marker4 = new google.maps.Marker({position: {lat:14, lng:-90},map: map,title: 'Hello World!',icon:image2});\n"));
//markers.append(QString("var marker4 = new google.maps.Marker({map: map,position: {lat:44.0, lng:55},title: '2',icon:image});\n"));
//ui->textEdit->setText(html.toUtf8());
//qInfo()<<html;
//view->setContent(html.toUtf8());
view->setContent(html.replace("//###",markers).toUtf8());
ofstream ficheroSalida;
ficheroSalida.open ("/home/andree/Escritorio/EDDArchivos/mapas.html");
ficheroSalida << html.toStdString();
ficheroSalida.close();
//ui->webView->setContent(html.replace("###",markers).toUtf8());
//view->load(QUrl("https://www.google.es/maps"));
ui->gridLayout->removeWidget(view);
ui->gridLayout->addWidget(view);
//view->
//ui->stackedWidget_3->addWidget(view);
view->show();
}
//metodo para traer donaciones
void MainWindow::on_pushButton_15_clicked()
{
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/getDonaciones2") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << "Success: Donaciones traidas con exito";
escribirArchivo(reply->readAll());
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
//Metodo de cifrado
void MainWindow::on_pushButton_24_clicked()
{
QString ruta = QFileDialog::getOpenFileName(this, tr("Open File"),"/path/to/file/",tr("CSV Files (*.csv)"));
fstream ficheroEntrada;//para leer el archivo
string linea;//
archivito="";
archivo="";
ficheroEntrada.open(ruta.toStdString(), ios::in);//abrimos el archivo con su ubicacion
while (! ficheroEntrada.eof() ) {
getline(ficheroEntrada,linea);//leemos linea por linea el archivo
//archivo.append(QString::fromStdString(linea));//lo adjuntamos al archivo
archivito+=linea;
// qInfo()<<QString::fromStdString(linea);
}
ficheroEntrada.close();
ListaSimple lst;
string st = archivito;
char str[st.length()+1];
strcpy(str, st.c_str());
char * pch;
//printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str,";");
while (pch != NULL)
{
std::string someString(pch);
lst.agregar(someString);
pch = strtok (NULL, ";");
}
qInfo()<<"Numero de elementos a insertar: "<<lst.size;
nodo *temporal = lst.first;
while(temporal!=nullptr){
ListaSimple lst2;
string st2= temporal->getDato();
char str2[st2.length()+1];
strcpy(str2, st2.c_str());
char *pch2;
//printf ("Splitting string \"%s\" into tokens:\n",str);
qInfo()<<"";
pch2 = strtok (str2,",");
while (pch2 != NULL)
{
std:: string str(pch2);
std::string someString=Codificar(str);
lst2.agregar(someString);
pch2 = strtok (NULL, ",");
}
nodo *temp = lst2.first;
while(temp!=nullptr){
if(temp==lst2.first)
archivo.append(QString::fromStdString(temp->dato));
else
archivo.append(","+QString::fromStdString(temp->dato));
temp = temp->siguiente;
}
archivo.append(";");
temporal=temporal->siguiente;
}
ofstream ficheroSalida;
ficheroSalida.open ("/home/andree/Escritorio/EDDArchivos/codificado.txt");
ficheroSalida << archivo.toStdString();
ficheroSalida.close();
}
void MainWindow::on_pushButton_25_clicked()
{
QString ruta = QFileDialog::getOpenFileName(this, tr("Open File"),"/path/to/file/",tr("CSV Files (*.txt)"));
fstream ficheroEntrada;//para leer el archivo
string linea;//
archivito="";
archivo="";
ficheroEntrada.open(ruta.toStdString(), ios::in);//abrimos el archivo con su ubicacion
while (! ficheroEntrada.eof() ) {
getline(ficheroEntrada,linea);//leemos linea por linea el archivo
//archivo.append(QString::fromStdString(linea));//lo adjuntamos al archivo
archivito+=linea;
// qInfo()<<QString::fromStdString(linea);
}
ficheroEntrada.close();
ListaSimple lst;
string st = archivito;
char str[st.length()+1];
strcpy(str, st.c_str());
char * pch;
//printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str,";");
while (pch != NULL)
{
std::string someString(pch);
lst.agregar(someString);
pch = strtok (NULL, ";");
}
//qInfo()<<"Numero de elementos a insertar: "<<lst.size;
nodo *temporal = lst.first;
while(temporal!=nullptr){
ListaSimple lst2;
string st2= temporal->getDato();
char str2[st2.length()+1];
strcpy(str2, st2.c_str());
char *pch2;
//printf ("Splitting string \"%s\" into tokens:\n",str);
// qInfo()<<"";
pch2 = strtok (str2,",");
while (pch2 != NULL)
{
std:: string str(pch2);
std::string someString=Decodificar(str);
lst2.agregar(someString);
pch2 = strtok (NULL, ",");
}
nodo *temp = lst2.first;
while(temp!=nullptr){
if(temp==lst2.first)
archivo.append(QString::fromStdString(temp->dato));
else
archivo.append(","+QString::fromStdString(temp->dato));
temp = temp->siguiente;
}
archivo.append(";\n");
temporal=temporal->siguiente;
}
ofstream ficheroSalida;
ficheroSalida.open ("/home/andree/Escritorio/EDDArchivos/decodificado.csv");
ficheroSalida << archivo.toStdString();
ficheroSalida.close();
}
//Boton para eliminar individuo
void MainWindow::on_eliminar_familia_2_clicked()
{
QString codigo = ui->Cindividuo_eliminar->itemText(key2);
QString fami= ui->cFamilia_eliminar->itemText(key);
//qInfo()<<codigo<<"-"<<fami;
Familia temp= lstfamilias.buscar(fami);
}
//Boton para poder insertar una donacion
void MainWindow::on_pushButton_26_clicked()
{
QString codigo = ui->acopio_categoria->text();
QString nombre = ui->acopio_nombre->text();
int cantidad = ui->spinBox->value();
Codificador cod;
int codi = cod.getCodigo(codigo);
Donacion *nuevo = new Donacion(codigo,nombre,cantidad);
Tabla->insertar(codi,nuevo);
ui->textEdit_2->clear();
ui->textEdit_2->setText(Tabla->imprimir());
}
void MainWindow::on_pushButton_27_clicked()
{
Tabla->graficarTabla();
}
void MainWindow::on_pushButton_28_clicked()
{
QString codigo = ui->codigo_locacion->text();
QString nombre = ui->nombre_latitud->text();
double latitud = ui->latitud_locacion->value();
double longitud = ui->longitud_locacion->value();
QString password = ui->pass_locacion->text();
QString nArchivo = ui->archivo_locacion->text();
QString json=tr("%1,%2,%3,%4,%5,%6;").arg(codigo, nombre,password,QString::number(latitud),QString::number(longitud),nArchivo);
string str= json.toStdString();
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
json=QString::fromStdString(str);
QEventLoop eventLoop;
qInfo()<<json.toUtf8();
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/setLocalidad") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.post(req,json.toUtf8());
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
QNetworkReply *respuesta= mgr.get(req);
eventLoop.exec();
qDebug() << "Success" << respuesta->readAll();
delete respuesta;
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_pushButton_29_clicked()
{
QString inicio = ui->inicio_arista->text();
QString destino = ui->destino_arista->text();
double multiplicador = ui->multiplicador_arista->value();
const QString url=tr("http://localhost:8080/WebService/app/setArista?codigo=%1&destino=%2&multiplicador=%3").arg(inicio,destino,QString::number(multiplicador));
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString(url.toUtf8()) ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << reply->readAll();
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_pushButton_30_clicked()
{
QString json;
QString codigo = ui->codigo_locacion->text();
QString nombre = ui->nombre_latitud->text();
double latitud = ui->latitud_locacion->value();
double longitud = ui->longitud_locacion->value();
QString password = ui->pass_locacion->text();
QString nArchivo = ui->archivo_locacion->text();
json=tr("{\"nombre\":\"%1\",\"codigo\":\"%2\",\"password\":\"%3\",\"lat\":%4,\"lng\":%5,\"archivo\":\"%6\"}").arg(nombre,codigo,password,QString::number(latitud),QString::number(longitud),nArchivo);
qInfo()<<json;
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/putLocalidad") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.post(req,json.toUtf8());
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << reply->readAll();
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_pushButton_31_clicked()
{
QString inicio = ui->eliminar_localidad->text();
const QString url=tr("http://localhost:8080/WebService/app/deleteLocalidad?codigo=%1").arg(inicio);
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString(url.toUtf8()) ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << reply->readAll();
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_pushButton_32_clicked()
{
QFile defaultTextFile("/home/andree/Escritorio/EDDArchivos/mapas.html");
defaultTextFile.open(QIODevice::ReadOnly);
QString html = defaultTextFile.readAll();
QString puntoa = ui->puntoa->itemText(key);
QString puntob=ui->puntob->itemText(key2);
const QString url=tr("http://localhost:8080/WebService/app/getCamino?pta=%1&ptb=%2").arg(puntoa,puntob);
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString(url.toUtf8()) ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
qDebug() << "camino mas optimo xd";
QString repla = tr("var puntos_linea = [%1]; var linea = new google.maps.Polyline({path: puntos_linea,geodesic: true, strokeColor: '#FF0000',strokeOpacity: 1.0,strokeWeight: 2}); \n linea.setMap(map);").
arg(QString::fromStdString(reply->readAll().toStdString()));
view->setContent(html.replace("//^",repla).toUtf8());
ofstream ficheroSalida;
ficheroSalida.open ("/home/andree/Escritorio/EDDArchivos/finalizado.html");
ficheroSalida << html.toStdString();
ficheroSalida.close();
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_puntoa_currentIndexChanged(int index)
{
key=index;
}
void MainWindow::on_puntob_currentIndexChanged(int index)
{
key2=index;
}
void MainWindow::on_pushButton_33_clicked()
{
ui->stackedWidget->setCurrentIndex(6);
}
//boton para mandar donacion
void MainWindow::on_pushButton_34_clicked()
{
QString dpi= ui->dpi_donacion->text();
QString nombres = ui->nombres_donacion->text();
QString apellidos = ui->apellidos_donacion->text();
QString fecha = ui->fecha_donacion->text();
QString monto = ui->monto_donacion->text();
QString donacion = tr("%1,%2,%3,%4,%5").arg(dpi,nombres,apellidos,fecha,monto);
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req( QUrl( QString("http://localhost:8080/WebService/app/setDonacion") ) );
req.setRawHeader("Content-Type", "application/json");
QNetworkReply *reply = mgr.post(req,donacion.toUtf8());
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
//success
QNetworkReply *respuesta= mgr.get(req);
eventLoop.exec();
qDebug() << "Success" << respuesta->readAll();
delete respuesta;
delete reply;
} else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
}
void MainWindow::on_Carchivo_informacion_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(this, tr("Open File"),"/path/to/file/",tr("JSON Files (*.json)"));
cargarArchivo(fileNames);
ui->archivo_informacion->setText(fileNames);
}
//BOTON para agregar a lista de donaciones
void MainWindow::on_pushButton_35_clicked()
{
QString codigo = ui->categoria_entrega->text();
QString nombre = ui->nombre_entrega->text();
QString unidad = ui->unidades_entrega->text();
//ui->lst_entrega->clear();
ui->lst_entrega->append(codigo+" --- "+nombre+" --- "+unidad);
//bool ok;
//qInfo()<<unidad.toInt();
Donacion *temp = new Donacion(codigo,nombre,unidad.toInt());
qInfo()<<temp->unidades;
lstDonaciones->agregar(temp);
}
void MainWindow::on_pushButton_36_clicked()
{
ui->lst_entrega->clear();
QString codigo;
QString nombre;
int unidad;
Codificador cod;
nodoD *temp = lstDonaciones->first;
while(temp!=nullptr){
codigo=temp->dato->categoria;
nombre=temp->dato->nombre;
unidad=temp->dato->unidades;
int codi = cod.getCodigo(codigo);
//qInfo()<<"Unidades paso 1 : "<<unidad;
Tabla->Reduce_AND_Delete(codi,nombre,unidad);
temp=temp->siguiente;
}
//lstDonaciones->borrarLista();
lstDonaciones=new ListaDoble();
}
//Boton para actualizar tabla
void MainWindow::on_pushButton_37_clicked()
{
ui->textEdit_2->clear();
ui->textEdit_2->setText(Tabla->imprimir());
}
void MainWindow::on_cIndividuo_modificar_activated(const QString &arg1)
{
}
// metodo para traer familias
void MainWindow::on_pushButton_22_clicked()
{
ui->Cindividuo_eliminar->clear();
QString codigo = ui->cFamilia_eliminar->itemText(key);
llenarCombo2(lstfamilias.buscar(codigo).arbol->raiz);
}
//metodo para llenar combo2
void MainWindow::llenarCombo2(nodoABB *pivote)
{
if(pivote==nullptr)
return;
llenarCombo2(pivote->izquierda);
// qInfo()<<'\t'<<pivote->key;
ui->Cindividuo_eliminar->addItem(QString::number(pivote->key));
llenarCombo2(pivote->derecha);
}
|
;===============================================================================
; Copyright 2014-2018 Intel Corporation
; All Rights Reserved.
;
; If this software was obtained under the Intel Simplified Software License,
; the following terms apply:
;
; The source code, information and material ("Material") contained herein is
; owned by Intel Corporation or its suppliers or licensors, and title to such
; Material remains with Intel Corporation or its suppliers or licensors. The
; Material contains proprietary information of Intel or its suppliers and
; licensors. The Material is protected by worldwide copyright laws and treaty
; provisions. No part of the Material may be used, copied, reproduced,
; modified, published, uploaded, posted, transmitted, distributed or disclosed
; in any way without Intel's prior express written permission. No license under
; any patent, copyright or other intellectual property rights in the Material
; is granted to or conferred upon you, either expressly, by implication,
; inducement, estoppel or otherwise. Any license under such intellectual
; property rights must be express and approved by Intel in writing.
;
; Unless otherwise agreed by Intel in writing, you may not remove or alter this
; notice or any other notice embedded in Materials by Intel or Intel's
; suppliers or licensors in any way.
;
;
; If this software was obtained under the Apache License, Version 2.0 (the
; "License"), the following terms apply:
;
; 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.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Rijndael-128 (AES) cipher functions.
; (It's the special free from Sbox/tables implementation)
;
; Content:
; SafeDecrypt_RIJ128()
;
; History:
;
; Notes.
; The implementation is based on
; isomorphism between native GF(2^8) and composite GF((2^4)^2).
;
;
.686P
.XMM
.MODEL FLAT,C
INCLUDE asmdefs.inc
INCLUDE ia_emm.inc
IF (_IPP GE _IPP_V8)
IFDEF IPP_PIC
LD_ADDR MACRO reg:REQ, addr:REQ
LOCAL LABEL
call LABEL
LABEL: pop reg
sub reg, LABEL-addr
ENDM
ELSE
LD_ADDR MACRO reg:REQ, addr:REQ
lea reg, addr
ENDM
ENDIF
PTRANSFORM MACRO dst,src, memTransLO, memTransHI, tmp, srcLO
movdqa dst, oword ptr [memTransLO] ;; LO transformation
movdqa tmp, oword ptr [memTransHI] ;; HI transformation
movdqa srcLO, src ;; split src:
psrlw src, 4 ;;
pand srcLO, xmm7 ;; low 4 bits -> srcLO
pand src, xmm7 ;; upper 4 bits -> src
pshufb dst, srcLO ;; transformation
pshufb tmp, src
pxor dst, tmp
ENDM
PLOOKUP_MEM MACRO dst, src, Table
movdqa dst, OWORD PTR Table
pshufb dst,src
ENDM
PREDUCE_MOD15 MACRO dst, src
movdqa dst, src
pcmpgtb src, xmm7
psubb dst, src
ENDM
PINVERSE_GF16_INV MACRO xmmB,xmmC, xmmP,xmmQ,xmmD,xmmT
PLOOKUP_MEM xmmT, xmmC, [eax+(GF16_logTbl-DECODE_DATA)] ;; xmmT = index_of(c)
pxor xmmC, xmmB
PLOOKUP_MEM xmmQ, xmmC, [eax+(GF16_logTbl-DECODE_DATA)] ;; xmmQ = index_of(b xor c)
PLOOKUP_MEM xmmD, xmmB, [eax+(GF16_sqr1-DECODE_DATA)] ;; xmmD = sqr(b)*beta^14
PLOOKUP_MEM xmmP, xmmB, [eax+(GF16_logTbl-DECODE_DATA)] ;; xmmP = index_of(b)
paddb xmmT, xmmQ ;; xmmT = index_of(c) + index_of(b xor c)
PREDUCE_MOD15 xmmC, xmmT ;;
PLOOKUP_MEM xmmT, xmmC, [eax+(GF16_expTbl-DECODE_DATA)] ;; c*(b xor c)
pxor xmmD, xmmT ;; xmmD = delta = (c*(b xor c)) xor (sqr(b)*beta^14)
PLOOKUP_MEM xmmT, xmmD, [eax+(GF16_invLog-DECODE_DATA)] ;; xmmT = index_of( inv(delta) )
paddb xmmQ, xmmT ;; xmmQ = index_of((b xor c) * inv(delta))
paddb xmmP, xmmT ;; xmmP = index_of(b * inv(delta))
PREDUCE_MOD15 xmmT, xmmQ
PLOOKUP_MEM xmmC, xmmT, [eax+(GF16_expTbl-DECODE_DATA)]
PREDUCE_MOD15 xmmT, xmmP
PLOOKUP_MEM xmmB, xmmT, [eax+(GF16_expTbl-DECODE_DATA)]
ENDM
IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR)
ALIGN IPP_ALIGN_FACTOR
DECODE_DATA:
;; (forward) native GF(2^8) to composite GF((2^4)^2) transformation : {0x01,0x2E,0x49,0x43,0x35,0xD0,0x3D,0xE9}
TransFwdLO \
DB 000h ;; 000h ;; 0
DB 001h ;; 001h ;; 1
DB 02Eh ;; 02Eh ;; 2
DB 02Fh ;; 02Eh XOR 001h ;; 3
DB 049h ;; 049h ;; 4
DB 048h ;; 049h XOR 001h ;; 5
DB 067h ;; 049h XOR 02Eh ;; 6
DB 066h ;; 049h XOR 02Eh XOR 001h ;; 7
DB 043h ;; 043h ;; 8
DB 042h ;; 043h XOR 001h ;; 9
DB 06Dh ;; 043h XOR 02Eh ;; a
DB 06Ch ;; 043h XOR 02Eh XOR 001h ;; b
DB 00Ah ;; 043h XOR 049h ;; c
DB 00Bh ;; 043h XOR 049h XOR 001h ;; d
DB 024h ;; 043h XOR 049h XOR 02Eh ;; e
DB 025h ;; 043h XOR 049h XOR 02Eh XOR 001h ;; f
TransFwdHI \
DB 000h ;; 000h ;; 0
DB 035h ;; 035h ;; 1
DB 0D0h ;; 0D0h ;; 2
DB 0E5h ;; 0D0h XOR 035h ;; 3
DB 03Dh ;; 03Dh ;; 4
DB 008h ;; 03Dh XOR 035h ;; 5
DB 0EDh ;; 03Dh XOR 0D0h ;; 6
DB 0D8h ;; 03Dh XOR 0D0h XOR 035h ;; 7
DB 0E9h ;; 0E9h ;; 8
DB 0DCh ;; 0E9h XOR 035h ;; 9
DB 039h ;; 0E9h XOR 0D0h ;; a
DB 00Ch ;; 0E9h XOR 0D0h XOR 035h ;; b
DB 0D4h ;; 0E9h XOR 03Dh ;; c
DB 0E1h ;; 0E9h XOR 03Dh XOR 035h ;; d
DB 004h ;; 0E9h XOR 03Dh XOR 0D0h ;; e
DB 031h ;; 0E9h XOR 03Dh XOR 0D0h XOR 035h ;; f
;; (inverse) composite GF((2^4)^2) to native GF(2^8) transformation : {0x01,0x5C,0xE0,0x50,0x1F,0xEE,0x55,0x6A}
TransInvLO \
DB 000h ;; 000h ;; 0
DB 001h ;; 001h ;; 1
DB 05Ch ;; 05Ch ;; 2
DB 05Dh ;; 05Ch XOR 001h ;; 3
DB 0E0h ;; 0E0h ;; 4
DB 0E1h ;; 0E0h XOR 001h ;; 5
DB 0BCh ;; 0E0h XOR 05Ch ;; 6
DB 0BDh ;; 0E0h XOR 05Ch XOR 001h ;; 7
DB 050h ;; 050h ;; 8
DB 051h ;; 050h XOR 001h ;; 9
DB 00Ch ;; 050h XOR 05Ch ;; a
DB 00Dh ;; 050h XOR 05Ch XOR 001h ;; b
DB 0B0h ;; 050h XOR 0E0h ;; c
DB 0B1h ;; 050h XOR 0E0h XOR 001h ;; d
DB 0ECh ;; 050h XOR 0E0h XOR 05Ch ;; e
DB 0EDh ;; 050h XOR 0E0h XOR 05Ch XOR 001h ;; f
TransInvHI \
DB 000h ;; 000h ;; 0
DB 01Fh ;; 01Fh ;; 1
DB 0EEh ;; 0EEh ;; 2
DB 0F1h ;; 0EEh XOR 01Fh ;; 3
DB 055h ;; 055h ;; 4
DB 04Ah ;; 055h XOR 01Fh ;; 5
DB 0BBh ;; 055h XOR 0EEh ;; 6
DB 0A4h ;; 055h XOR 0EEh XOR 01Fh ;; 7
DB 06Ah ;; 06Ah ;; 8
DB 075h ;; 06Ah XOR 01Fh ;; 9
DB 084h ;; 06Ah XOR 0EEh ;; a
DB 09Bh ;; 06Ah XOR 0EEh XOR 01Fh ;; b
DB 03Fh ;; 06Ah XOR 055h ;; c
DB 020h ;; 06Ah XOR 055h XOR 01Fh ;; d
DB 0D1h ;; 06Ah XOR 055h XOR 0EEh ;; e
DB 0CEh ;; 06Ah XOR 055h XOR 0EEh XOR 01Fh ;; f
GF16_csize DB 00Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh,0Fh
;; GF16 elements:
;; 0 1 2 3 4 5 6 7 8 9 A B C D E F
GF16_logTbl \
DB 0C0h,00h,01h,04h,02h,08h,05h,0Ah,03h,0Eh,09h,07h,06h,0Dh,0Bh,0Ch
GF16_expTbl \
DB 001h,02h,04h,08h,03h,06h,0Ch,0Bh,05h,0Ah,07h,0Eh,0Fh,0Dh,09h,01h
GF16_sqr1 \
DB 000h,09h,02h,0Bh,08h,01h,0Ah,03h,06h,0Fh,04h,0Dh,0Eh,07h,0Ch,05h ;; sqr(GF16_element) * beta^14
GF16_invLog \
DB 0C0h,00h,0Eh,0Bh,0Dh,07h,0Ah,05h,0Ch,01h,06h,08h,09h,02h,04h,03h
;; affine transformation matrix (inverse cipher) : {0x50,0x36,0x15,0x82,0x01,0x34,0x40,0x3E}
InvAffineLO \
DB 000h ;; 000h ;; 0
DB 050h ;; 050h ;; 1
DB 036h ;; 036h ;; 2
DB 066h ;; 036h XOR 050h ;; 3
DB 015h ;; 015h ;; 4
DB 045h ;; 015h XOR 050h ;; 5
DB 023h ;; 015h XOR 036h ;; 6
DB 073h ;; 015h XOR 036h XOR 050h ;; 7
DB 082h ;; 082h ;; 8
DB 0D2h ;; 082h XOR 050h ;; 9
DB 0B4h ;; 082h XOR 036h ;; a
DB 0E4h ;; 082h XOR 036h XOR 050h ;; b
DB 097h ;; 082h XOR 015h ;; c
DB 0C7h ;; 082h XOR 015h XOR 050h ;; d
DB 0A1h ;; 082h XOR 015h XOR 036h ;; e
DB 0F1h ;; 082h XOR 015h XOR 036h XOR 050h ;; f
InvAffineHI \
DB 000h ;; 000h ;; 0
DB 001h ;; 001h ;; 1
DB 034h ;; 034h ;; 2
DB 035h ;; 034h XOR 001h ;; 3
DB 040h ;; 040h ;; 4
DB 041h ;; 040h XOR 001h ;; 5
DB 074h ;; 040h XOR 034h ;; 6
DB 075h ;; 040h XOR 034h XOR 001h ;; 7
DB 03Eh ;; 03Eh ;; 8
DB 03Fh ;; 03Eh XOR 001h ;; 9
DB 00Ah ;; 03Eh XOR 034h ;; a
DB 00Bh ;; 03Eh XOR 034h XOR 001h ;; b
DB 07Eh ;; 03Eh XOR 040h ;; c
DB 07Fh ;; 03Eh XOR 040h XOR 001h ;; d
DB 04Ah ;; 03Eh XOR 040h XOR 034h ;; e
DB 04Bh ;; 03Eh XOR 040h XOR 034h XOR 001h ;; f
;; affine transformation constant (inverse cipher)
InvAffineCnt \
DQ 04848484848484848h,04848484848484848h
;; shift rows transformation (inverse cipher)
InvShiftRows \
DB 0,13,10,7,4,1,14,11,8,5,2,15,12,9,6,3
;; mix columns transformation (inverse cipher)
GF16mul_4_2x \
DB 000h,024h,048h,06Ch,083h,0A7h,0CBh,0EFh,036h,012h,07Eh,05Ah,0B5h,091h,0FDh,0D9h ;; *(4+2x)
GF16mul_1_6x \
DB 000h,061h,0C2h,0A3h,0B4h,0D5h,076h,017h,058h,039h,09Ah,0FBh,0ECh,08Dh,02Eh,04Fh ;; *(1+6x)
GF16mul_C_6x \
DB 000h,06Ch,0CBh,0A7h,0B5h,0D9h,07Eh,012h,05Ah,036h,091h,0FDh,0EFh,083h,024h,048h ;; *(C+6x)
GF16mul_3_Ax \
DB 000h,0A3h,076h,0D5h,0ECh,04Fh,09Ah,039h,0FBh,058h,08Dh,02Eh,017h,0B4h,061h,0C2h ;; *(3+Ax)
GF16mul_B_0x \
DB 000h,00Bh,005h,00Eh,00Ah,001h,00Fh,004h,007h,00Ch,002h,009h,00Dh,006h,008h,003h ;; *(B+0x)
GF16mul_0_Bx \
DB 000h,0B0h,050h,0E0h,0A0h,010h,0F0h,040h,070h,0C0h,020h,090h,0D0h,060h,080h,030h ;; *(0+Bx)
GF16mul_2_4x \
DB 000h,042h,084h,0C6h,038h,07Ah,0BCh,0FEh,063h,021h,0E7h,0A5h,05Bh,019h,0DFh,09Dh ;; *(2+4x)
GF16mul_2_6x \
DB 000h,062h,0C4h,0A6h,0B8h,0DAh,07Ch,01Eh,053h,031h,097h,0F5h,0EBh,089h,02Fh,04Dh ;; *(2+6x)
ColumnROR \
DB 1,2,3,0,5,6,7,4,9,10,11,8,13,14,15,12
;*************************************************************
; convert GF(2^128) -> GF((2^4)^2)
;*************************************************************
ALIGN IPP_ALIGN_FACTOR
IPPASM TransformNative2Composite PROC NEAR C PUBLIC \
USES esi edi,\
pOutBlk: PTR DWORD,\ ; output block address
pInpBlk: PTR DWORD ; input block address
LD_ADDR eax, DECODE_DATA
mov edi,pOutBlk ; output data address
mov esi,pInpBlk ; input data address
movdqa xmm7, oword ptr [eax+(GF16_csize-DECODE_DATA)]
;; convert input into the composite GF((2^4)^2)
movdqu xmm0, oword ptr[esi] ; input block
PTRANSFORM xmm1, xmm0, <eax+(TransFwdLO-DECODE_DATA)>,<eax+(TransFwdHI-DECODE_DATA)>, xmm2, xmm3
movdqu oword ptr[edi], xmm1 ; output block
ret
IPPASM TransformNative2Composite ENDP
ALIGN IPP_ALIGN_FACTOR
;*************************************************************
;* void SafeDecrypt_RIJ128(
;* const Ipp32u* pInpBlk,
;* Ipp32u* pOutBlk,
;* int nr,
;* const Ipp32u* pKeys,
;* const void* Tables)
;*************************************************************
;;
;; Lib = V8
;;
IPPASM SafeDecrypt_RIJ128 PROC NEAR C PUBLIC \
USES esi edi,\
pInpBlk: PTR DWORD,\ ; input block address
pOutBlk: PTR DWORD,\ ; output block address
nr: DWORD,\ ; number of rounds
pKey: PTR DWORD ; key material address
RSIZE = sizeof dword ; size of row
SC = 4 ; columns in STATE
SSIZE = RSIZE*SC ; size of state
mov edx, pKey
mov ecx, nr
mov esi,pInpBlk ; input data address
mov edi,pOutBlk ; output data address
lea eax,[ecx*4]
lea edx,[edx+eax*4] ; AES-128-keys
LD_ADDR eax, DECODE_DATA
movdqu xmm0, oword ptr[esi] ; input block
movdqa xmm7, oword ptr [eax+(GF16_csize-DECODE_DATA)]
;; convert input into the composite GF((2^4)^2)
PTRANSFORM xmm2,xmm0, <eax+(TransFwdLO-DECODE_DATA)>,<eax+(TransFwdHI-DECODE_DATA)>, xmm1,xmm3
;; initial whitening
pxor xmm2, oword ptr[edx]
sub edx, SSIZE
;; (nr-1) regular rounds
sub ecx,1
decode_round:
;; InvSubByte() Transformation:
;; affine transformation
PTRANSFORM xmm0,xmm2, <eax+(InvAffineLO-DECODE_DATA)>,<eax+(InvAffineHI-DECODE_DATA)>, xmm1,xmm3
pxor xmm0, oword ptr [eax+(InvAffineCnt-DECODE_DATA)] ; H(c), c=0x05
;; split input by low and upper parts
movdqa xmm1, xmm0
pand xmm0, xmm7 ; upper parts (4 bits)
psrlw xmm1, 4
pand xmm1, xmm7 ; low parts (4 bits)
;; compute multiplicative inverse
PINVERSE_GF16_INV xmm1,xmm0, xmm3,xmm2,xmm4,xmm5
;; InvShiftRows() Transformation:
pshufb xmm0, oword ptr [eax+(InvShiftRows-DECODE_DATA)]
pshufb xmm1, oword ptr [eax+(InvShiftRows-DECODE_DATA)]
;; InvMixColumn() Transformation:
PLOOKUP_MEM xmm2, xmm0, [eax+(GF16mul_4_2x-DECODE_DATA)] ; mul H(0xE) = 0x24
pshufb xmm0, oword ptr [eax+(ColumnROR-DECODE_DATA)]
PLOOKUP_MEM xmm3, xmm1, [eax+(GF16mul_1_6x-DECODE_DATA)]
pshufb xmm1, oword ptr [eax+(ColumnROR-DECODE_DATA)]
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm0, [eax+(GF16mul_C_6x-DECODE_DATA)] ; mul H(0xB) = 0x6C
pshufb xmm0, oword ptr [eax+(ColumnROR-DECODE_DATA)]
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm1, [eax+(GF16mul_3_Ax-DECODE_DATA)]
pshufb xmm1, oword ptr [eax+(ColumnROR-DECODE_DATA)]
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm0, [eax+(GF16mul_B_0x-DECODE_DATA)] ; mul H(0xD) = 0x0B
pshufb xmm0, oword ptr [eax+(ColumnROR-DECODE_DATA)]
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm1, [eax+(GF16mul_0_Bx-DECODE_DATA)]
pshufb xmm1, oword ptr [eax+(ColumnROR-DECODE_DATA)]
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm0, [eax+(GF16mul_2_4x-DECODE_DATA)] ; mul H(0x9) = 0x42
pxor xmm2, xmm3
PLOOKUP_MEM xmm3, xmm1, [eax+(GF16mul_2_6x-DECODE_DATA)]
pxor xmm2, xmm3
;; AddRoundKey() Transformation:
pxor xmm2, oword ptr[edx]
sub edx, SSIZE
sub ecx,1
jg decode_round
;;
;; the last one is irregular
;;
;; InvSubByte() Transformation:
;; affine transformation
PTRANSFORM xmm0,xmm2, <eax+(InvAffineLO-DECODE_DATA)>,<eax+(InvAffineHI-DECODE_DATA)>, xmm1,xmm3
pxor xmm0, oword ptr [eax+(InvAffineCnt-DECODE_DATA)] ; H(c), c=0x05
;; split input by low and upper parts
movdqa xmm1, xmm0
pand xmm0, xmm7 ; low parts (4 bits)
psrlw xmm1, 4
pand xmm1, xmm7 ; upper parts (4 bits)
;; compute multiplicative inverse
PINVERSE_GF16_INV xmm1,xmm0, xmm3,xmm2,xmm4,xmm5
;; InvShiftRows() Transformation:
psllw xmm1, 4
por xmm1, xmm0
pshufb xmm1, oword ptr [eax+(InvShiftRows-DECODE_DATA)]
;; AddRoundKey() Transformation:
pxor xmm1, oword ptr[edx]
sub edx, SSIZE
;; convert output into the native GF(2^8)
PTRANSFORM xmm0,xmm1, <eax+(TransInvLO-DECODE_DATA)>,<eax+(TransInvHI-DECODE_DATA)>, xmm2, xmm3
movdqu oword ptr[edi], xmm0
ret
IPPASM SafeDecrypt_RIJ128 ENDP
ENDIF
END
|
S SEGMENT ;Stack Segment
S ENDS
D SEGMENT ;Data Segment
MSAGE1 DB "Enter Character OR String To Reverse:", '$'
MSAGE2 DB 35 DUP(?)
MSAGE3 DB "Do Show Reverse? (Y/n):", '$'
MSAGE4 DB "You Select No !", '$'
MSAGE5 DB "Your Text Reverse Is:", '$'
D ENDS
C SEGMENT ;Code Segment
MAIN PROC FAR
ASSUME SS:S, DS:D, CS:C
MOV AX, d
MOV DS, AX
MOV AX, 0E00H ;Activating Console
INT 10h
MOV AX, 0002H
MOV BX, 0000H
MOV DX, 1010H
INT 10H
MOV AX, 0600H ;Show Main Rectangular
MOV BX, 4400H
MOV CX, 0412H
MOV DX, 133DH
INT 10H
MOV AX, 0600H ;Show Up Rectangular
MOV BX, 1700H
MOV CX, 0513H
MOV DX, 123CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0816H
INT 10H
MOV DX, OFFSET MSAGE1 ;PRINT FIRST MESSAGE
MOV AX, 0900H
INT 21H
MOV AX, 0600H ;Show A Line
MOV BX, 2000H
MOV CX, 0E13H
MOV DX, 0E3CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0E18H
INT 10H
MOV CX, 0000H
MOV SI, OFFSET MSAGE2
LOOP1: ;Get Array
MOV AX, 0000H
INT 16H
CMP AL, 0DH
JE LOOP2
CMP AL, '$'
JE LOOP1
MOV [SI], AL
MOV AH, 0EH
INT 10H
INC SI
INC CX
CMP CX, 20H
JNE LOOP1
LOOP2: ;Change Array To String
MOV CL, [SI]
MOV CH, 0
INC CX
ADD SI, CX
MOV DL, '$'
MOV [SI], DL
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0E18H
INT 10H
MOV AX, 0600H ;Show Up Rectangular
MOV BX, 1100H
MOV CX, 0513H
MOV DX, 123CH
INT 10H
MOV AX, 0600H ;Show A Line
MOV BX, 2000H
MOV CX, 0B13H
MOV DX, 0B3CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0B1CH
INT 10H
MOV AX, 0900H ;Show String
MOV DX, OFFSET MSAGE3
INT 21H
LOOP3:
MOV AX, 0600H ;Show A Line
MOV BX, 2000H
MOV CX, 0B2CH
MOV DX, 0B2CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0B33H
INT 10H
MOV AX, 0000H ;Get Select
INT 16H
CMP AL, 4EH ;N
JE LOOP4
CMP AL, 6EH ;n
JE LOOP4
CMP AL, 59H ;Y
JE LOOP5
CMP AL, 79H ;y
JE LOOP5
JMP LOOP3
LOOP4:
MOV AX, 0600H ;Show A Line
MOV BX, 2000H
MOV CX, 0B13H
MOV DX, 0B3CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0B20H
INT 10H
MOV AX, 0900H ;Show String
MOV DX, OFFSET MSAGE4
INT 21H
JMP LOOP6
LOOP5:
MOV AX, 0600H ;Show A Line
MOV BX, 2000H
MOV CX, 0B13H
MOV DX, 0B3CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0B1DH
INT 10H
MOV AX, 0900H ;Show String
MOV DX, OFFSET MSAGE5
INT 21H
MOV AX, 0600H ;Show A Line
MOV BX, 0E400H
MOV CX, 0C13H
MOV DX, 0C3CH
INT 10H
MOV AX, 0200H ;Change CURSOR Position
MOV BH, 0000H
MOV DX, 0C18H
INT 10H
;MOV AX, 0900H ;Show String
;MOV DX, OFFSET MSAGE2
;INT 21H
MOV AH, 0EH
MOV CX, 0020H
LOOP7: ;Show Reverse
DEC SI
MOV AL, [SI]
CMP AL, '$'
JE LOOP6
INT 10H
LOOP LOOP7
LOOP6:
MOV AX, 4C00H ;Give Back Control To OS
INT 21H
MAIN ENDP
C ENDS
END MAIN
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %rax
push %rbp
push %rsi
lea addresses_D_ht+0x1302d, %r15
nop
nop
nop
inc %rax
movl $0x61626364, (%r15)
nop
nop
nop
nop
sub %r8, %r8
lea addresses_WT_ht+0x1942d, %rax
and $21188, %r15
and $0xffffffffffffffc0, %rax
vmovaps (%rax), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %rsi
cmp %rsi, %rsi
pop %rsi
pop %rbp
pop %rax
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %r9
push %rbx
push %rcx
// Faulty Load
lea addresses_UC+0x442d, %rbx
nop
cmp $8276, %r15
mov (%rbx), %r9w
lea oracles, %rbx
and $0xff, %r9
shlq $12, %r9
mov (%rbx,%r9,1), %r9
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'same': True, 'size': 2, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
; A132119: A002260 + A000027 - A000012 as infinite lower triangular matrices.
; 1,3,3,6,5,6,10,8,9,10,15,12,13,14,15,21,17,18,19,20,21,28,23,24,25,26,27,28,36,30,31,32,33,34,35,36,45,38,39,40,41,42,43,44,45,55,47,48,49,50,51,52,53,54,55
mov $1,$0
seq $0,130296 ; Triangle read by rows: T[i,1]=i, T[i,j]=1 for 1 < j <= i = 1,2,3,...
add $0,$1
|
0200 12 62 JUMP $262
0202 ea ac UNK 0xeaac
0204 aa ea MVI I,#$aea
0206 ce aa RND VE,#$aa
0208 aa ae MVI I,#$aae
020a e0 a0 UNK 0xe0a0
020c a0 e0 MVI I,#$0e0
020e c0 40 RND V0,#$40
0210 40 e0 SKIP.NE V0,#$e0
0212 e0 20 UNK 0xe020
0214 c0 e0 RND V0,#$e0
0216 e0 60 UNK 0xe060
0218 20 e0 CALL $0e0
021a a0 e0 MVI I,#$0e0
021c 20 20 CALL $020
021e 60 40 MVI V0,#$40
0220 20 40 CALL $040
0222 e0 80 UNK 0xe080
0224 e0 e0 UNK 0xe0e0
0226 e0 20 UNK 0xe020
0228 20 20 CALL $020
022a e0 e0 UNK 0xe0e0
022c a0 e0 MVI I,#$0e0
022e e0 e0 UNK 0xe0e0
0230 20 e0 CALL $0e0
0232 40 a0 SKIP.NE V0,#$a0
0234 e0 a0 UNK 0xe0a0
0236 e0 c0 UNK 0xe0c0
0238 80 e0 MOV V0,VE
023a e0 80 UNK 0xe080
023c c0 80 RND V0,#$80
023e a0 40 MVI I,#$040
0240 a0 a0 MVI I,#$0a0
0242 6b 1a MVI VB,#$1a
0244 a2 32 MVI I,#$232
0246 d8 b4 SPRITE. V8,VB,#$4
0248 a2 3e MVI I,#$23e
024a d9 b4 SPRITE. V9,VB,#$4
024c a2 02 MVI I,#$202
024e da b4 SPRITE. VA,VB,#$4
0250 00 ee RTS
0252 6b 1a MVI VB,#$1a
0254 a2 0e MVI I,#$20e
0256 d8 b4 SPRITE. V8,VB,#$4
0258 a2 3e MVI I,#$23e
025a d9 b4 SPRITE. V9,VB,#$4
025c a2 02 MVI I,#$202
025e da b4 SPRITE. VA,VB,#$4
0260 13 dc JUMP $3dc
0262 68 01 MVI V8,#$01
0264 69 05 MVI V9,#$05
0266 6a 0a MVI VA,#$0a
0268 6b 01 MVI VB,#$01
026a 65 2a MVI V5,#$2a
026c 66 2b MVI V6,#$2b
026e a2 16 MVI I,#$216
0270 d8 b4 SPRITE. V8,VB,#$4
0272 a2 3e MVI I,#$23e
0274 d9 b4 SPRITE. V9,VB,#$4
0276 a2 06 MVI I,#$206
0278 36 2a SKIP.EQ V6,#$2a
027a a2 02 MVI I,#$202
027c da b4 SPRITE. VA,VB,#$4
027e 6b 06 MVI VB,#$06
0280 a2 1a MVI I,#$21a
0282 d8 b4 SPRITE. V8,VB,#$4
0284 a2 3e MVI I,#$23e
0286 d9 b4 SPRITE. V9,VB,#$4
0288 a2 06 MVI I,#$206
028a 45 2a SKIP.NE V5,#$2a
028c a2 02 MVI I,#$202
028e da b4 SPRITE. VA,VB,#$4
0290 6b 0b MVI VB,#$0b
0292 a2 1e MVI I,#$21e
0294 d8 b4 SPRITE. V8,VB,#$4
0296 a2 3e MVI I,#$23e
0298 d9 b4 SPRITE. V9,VB,#$4
029a a2 06 MVI I,#$206
029c 55 60 SKIP.EQ V5,V6
029e a2 02 MVI I,#$202
02a0 da b4 SPRITE. VA,VB,#$4
02a2 6b 10 MVI VB,#$10
02a4 a2 26 MVI I,#$226
02a6 d8 b4 SPRITE. V8,VB,#$4
02a8 a2 3e MVI I,#$23e
02aa d9 b4 SPRITE. V9,VB,#$4
02ac a2 06 MVI I,#$206
02ae 76 ff ADI V6,#$ff
02b0 46 2a SKIP.NE V6,#$2a
02b2 a2 02 MVI I,#$202
02b4 da b4 SPRITE. VA,VB,#$4
02b6 6b 15 MVI VB,#$15
02b8 a2 2e MVI I,#$22e
02ba d8 b4 SPRITE. V8,VB,#$4
02bc a2 3e MVI I,#$23e
02be d9 b4 SPRITE. V9,VB,#$4
02c0 a2 06 MVI I,#$206
02c2 95 60 SKIP.NE V5,V6
02c4 a2 02 MVI I,#$202
02c6 da b4 SPRITE. VA,VB,#$4
02c8 22 42 CALL $242
02ca 68 17 MVI V8,#$17
02cc 69 1b MVI V9,#$1b
02ce 6a 20 MVI VA,#$20
02d0 6b 01 MVI VB,#$01
02d2 a2 0a MVI I,#$20a
02d4 d8 b4 SPRITE. V8,VB,#$4
02d6 a2 36 MVI I,#$236
02d8 d9 b4 SPRITE. V9,VB,#$4
02da a2 02 MVI I,#$202
02dc da b4 SPRITE. VA,VB,#$4
02de 6b 06 MVI VB,#$06
02e0 a2 2a MVI I,#$22a
02e2 d8 b4 SPRITE. V8,VB,#$4
02e4 a2 0a MVI I,#$20a
02e6 d9 b4 SPRITE. V9,VB,#$4
02e8 a2 06 MVI I,#$206
02ea 87 50 MOV V7,V5
02ec 47 2a SKIP.NE V7,#$2a
02ee a2 02 MVI I,#$202
02f0 da b4 SPRITE. VA,VB,#$4
02f2 6b 0b MVI VB,#$0b
02f4 a2 2a MVI I,#$22a
02f6 d8 b4 SPRITE. V8,VB,#$4
02f8 a2 0e MVI I,#$20e
02fa d9 b4 SPRITE. V9,VB,#$4
02fc a2 06 MVI I,#$206
02fe 67 2a MVI V7,#$2a
0300 87 b1 OR V7,VB
0302 47 2b SKIP.NE V7,#$2b
0304 a2 02 MVI I,#$202
0306 da b4 SPRITE. VA,VB,#$4
0308 6b 10 MVI VB,#$10
030a a2 2a MVI I,#$22a
030c d8 b4 SPRITE. V8,VB,#$4
030e a2 12 MVI I,#$212
0310 d9 b4 SPRITE. V9,VB,#$4
0312 a2 06 MVI I,#$206
0314 66 78 MVI V6,#$78
0316 67 1f MVI V7,#$1f
0318 87 62 AND V7,V6
031a 47 18 SKIP.NE V7,#$18
031c a2 02 MVI I,#$202
031e da b4 SPRITE. VA,VB,#$4
0320 6b 15 MVI VB,#$15
0322 a2 2a MVI I,#$22a
0324 d8 b4 SPRITE. V8,VB,#$4
0326 a2 16 MVI I,#$216
0328 d9 b4 SPRITE. V9,VB,#$4
032a a2 06 MVI I,#$206
032c 66 78 MVI V6,#$78
032e 67 1f MVI V7,#$1f
0330 87 63 XOR V7,V6
0332 47 67 SKIP.NE V7,#$67
0334 a2 02 MVI I,#$202
0336 da b4 SPRITE. VA,VB,#$4
0338 6b 1a MVI VB,#$1a
033a a2 2a MVI I,#$22a
033c d8 b4 SPRITE. V8,VB,#$4
033e a2 1a MVI I,#$21a
0340 d9 b4 SPRITE. V9,VB,#$4
0342 a2 06 MVI I,#$206
0344 66 8c MVI V6,#$8c
0346 67 8c MVI V7,#$8c
0348 87 64 ADD. V7,V6
034a 47 18 SKIP.NE V7,#$18
034c a2 02 MVI I,#$202
034e da b4 SPRITE. VA,VB,#$4
0350 68 2c MVI V8,#$2c
0352 69 30 MVI V9,#$30
0354 6a 34 MVI VA,#$34
0356 6b 01 MVI VB,#$01
0358 a2 2a MVI I,#$22a
035a d8 b4 SPRITE. V8,VB,#$4
035c a2 1e MVI I,#$21e
035e d9 b4 SPRITE. V9,VB,#$4
0360 a2 06 MVI I,#$206
0362 66 8c MVI V6,#$8c
0364 67 78 MVI V7,#$78
0366 87 65 SUB. V7,V6
0368 47 ec SKIP.NE V7,#$ec
036a a2 02 MVI I,#$202
036c da b4 SPRITE. VA,VB,#$4
036e 6b 06 MVI VB,#$06
0370 a2 2a MVI I,#$22a
0372 d8 b4 SPRITE. V8,VB,#$4
0374 a2 22 MVI I,#$222
0376 d9 b4 SPRITE. V9,VB,#$4
0378 a2 06 MVI I,#$206
037a 66 e0 MVI V6,#$e0
037c 86 6e SHL. V6
037e 46 c0 SKIP.NE V6,#$c0
0380 a2 02 MVI I,#$202
0382 da b4 SPRITE. VA,VB,#$4
0384 6b 0b MVI VB,#$0b
0386 a2 2a MVI I,#$22a
0388 d8 b4 SPRITE. V8,VB,#$4
038a a2 36 MVI I,#$236
038c d9 b4 SPRITE. V9,VB,#$4
038e a2 06 MVI I,#$206
0390 66 0f MVI V6,#$0f
0392 86 66 SHR. V6
0394 46 07 SKIP.NE V6,#$07
0396 a2 02 MVI I,#$202
0398 da b4 SPRITE. VA,VB,#$4
039a 6b 10 MVI VB,#$10
039c a2 3a MVI I,#$23a
039e d8 b4 SPRITE. V8,VB,#$4
03a0 a2 1e MVI I,#$21e
03a2 d9 b4 SPRITE. V9,VB,#$4
03a4 a3 e8 MVI I,#$3e8
03a6 60 00 MVI V0,#$00
03a8 61 30 MVI V1,#$30
03aa f1 55 MOVM (I),V0-V1
03ac a3 e9 MVI I,#$3e9
03ae f0 65 MOVM V0-V0,(I)
03b0 a2 06 MVI I,#$206
03b2 40 30 SKIP.NE V0,#$30
03b4 a2 02 MVI I,#$202
03b6 da b4 SPRITE. VA,VB,#$4
03b8 6b 15 MVI VB,#$15
03ba a2 3a MVI I,#$23a
03bc d8 b4 SPRITE. V8,VB,#$4
03be a2 16 MVI I,#$216
03c0 d9 b4 SPRITE. V9,VB,#$4
03c2 a3 e8 MVI I,#$3e8
03c4 66 89 MVI V6,#$89
03c6 f6 33 MOVBCD V6
03c8 f2 65 MOVM V0-V2,(I)
03ca a2 02 MVI I,#$202
03cc 30 01 SKIP.EQ V0,#$01
03ce a2 06 MVI I,#$206
03d0 31 03 SKIP.EQ V1,#$03
03d2 a2 06 MVI I,#$206
03d4 32 07 SKIP.EQ V2,#$07
03d6 a2 06 MVI I,#$206
03d8 da b4 SPRITE. VA,VB,#$4
03da 12 52 JUMP $252
03dc 13 dc JUMP $3dc
|
; A099774: Number of divisors of 2*n-1.
; 1,2,2,2,3,2,2,4,2,2,4,2,3,4,2,2,4,4,2,4,2,2,6,2,3,4,2,4,4,2,2,6,4,2,4,2,2,6,4,2,5,2,4,4,2,4,4,4,2,6,2,2,8,2,2,4,2,4,6,4,3,4,4,2,4,2,4,8,2,2,4,4,4,6,2,2,6,4,2,4,4,2,8,2,3,6,2,6,4,2,2,4,4,4,8,2,2,8,2,2,4,4,4,6,4,2,4,4,4,4,4,2,9,2,2,8,2,4,4,2,2,6,6,4,4,2,4,8,2,4,6,2,4,4,2,2,8,6,2,6,2,2,8,4,3,4,2,4,8,4,4,4,4,2,4,2,2,12,2,4,4,4,6,4,4,2,6,4,2,4,4,4,8,2,2,8,2,4,8,2,3,6,4,2,6,4,2,8,4,2,4,2,8,6,2,4,4,4,2,8,2,4,10,4,2,4,4,4,4,2,2,6,6,4,8,2,2,8,4,2,9,2,4,4,2,4,4,8,2,8,2,2,8,2,4,4,4,6,6,2,4,8,4,2,4,2,4,12,4,2
mov $6,$0
mov $8,2
lpb $8,1
mov $0,$6
sub $8,1
add $0,$8
sub $0,1
mov $3,4
mov $5,1
mov $7,2
mov $9,$0
lpb $0,1
sub $0,1
add $3,2
div $4,$5
add $3,$4
sub $3,1
mov $4,$0
add $5,$7
lpe
mov $0,$3
sub $0,1
mov $2,$8
mov $10,$0
sub $10,2
add $10,$9
lpb $2,1
mov $1,$10
sub $2,1
lpe
lpe
lpb $6,1
sub $1,$10
mov $6,0
lpe
|
#ifndef EX5_CODE_GEN
#define EX5_CODE_GEN
#include <vector>
#include <string>
class CodeBuffer{
public:
CodeBuffer();
CodeBuffer(CodeBuffer const&);
void operator=(CodeBuffer const&);
std::vector<std::string> buffer;
std::vector<std::string> dataDefs;
static CodeBuffer &instance();
// ******** Methods to handle the code section ********** //
//generate a jump location label for the next command, writes to buffer
std::string genLabel();
//write command to the buffer, returns its location in the buffer
int emit(const std::string &command);
//accepts a list of buffer locations generated by emit and a label
//backpatches the commands at all buffer locations with the provided label.
//example:
//int loc = emit("j "); //jump missing a location
//bpatch(makelist(loc),"my_label"); //location loc in the buffer will now have the command "j my_label"
void bpatch(const std::vector<int>& address_list, const std::string &loc);
//print the content of the code buffer to stdout including a .text header
void printCodeBuffer();
static std::vector<int> makelist(int litem);
static std::vector<int> merge(const std::vector<int> &l1,const std::vector<int> &l2);
// ******** Methods to handle the data section ********** //
//write a line to the data section
void emitData(const std::string& dataLine);
//print the content of the data buffer to stdout including a .data header
void printDataBuffer();
std::string genDataLabel();
};
#endif
|
; A017292: a(n) = (10*n + 1)^12.
; 1,3138428376721,7355827511386641,787662783788549761,22563490300366186081,309629344375621415601,2654348974297586158321,16409682740640811134241,79766443076872509863361,322475487413604782665681,1126825030131969720661201,3498450596935634189769921,9849732675807611094711841,25542038069936263923006961,61748917974902741368975281,140515219945627518837736801,303326610665644763629211521,625105506678337880602119441,1236354171303115835117980561,2357221572577185690065114881,4348632317396990233762642401,7787345861668898615544483121,13573982477229290545823357041,23085737796000848857434784161,38388797722185519065061084481,62529457064557415999535378001,99927745220846124633825584721,156903087818962082857498424641,242368312385016936196463417761,368736278169776566314796884081,553092726310835924575445943601,818699769887346816976612516321,1196906950228928915420617322241,1729561165382261200512043881361,2472023231929042220921962513681,3496917589577226791795034339201,4898762930960846817716295277921,6799655583865908142394420049841,9356204552249879185458266174961,12767947514633659874603497973281,17287511078984605626766090564801,23232816514396602443039513869521,31001674351559225686692396607441,41089158014054007099883470298561,54108198377272584130510593262881,70813898236538278094070654620401,92132128505596173454447158291121,119193036985710246500182286995041,153370176189268183007030246252161,196326039436028365961428688382481,250064884752295712280965016506001,316993824502572670874954368542721,399993265701109317068886081212641,502497902141583120258735434035761,628589585424465130312977473332081,783103538254824010709579716221601,971749520653969010650290534624321,1201249718626740564963180019260241,1479495296027921174174630123649361,1815723734577332468151810888111681,2220719284911033302994119543767201,2707039063979597279155099296535921,3289267561794796586432994591137841,3984302564291813457966339655092961,4811675759752071123958817122721281,5793911574687201865143063539142801,6956928082211856941544138544277521,8330484142655824678048014536845441,9948677273438057188906683618366561,11850497104030975984667318617160881,14080439653198038396506364992348401,16689188070637629248948480417849121,19734365914790425893382878846383041,23281369493976380470743875853470161,27404286280365141501046272061430481,32186906916727206510367651443384001,37723838875673284825516711307250721,44121730401411477830747380759750641,51500613966215951343360724450403761,59995379109122034297528468395530081,69757385194192116119181424682249601,80956225331421531041301131852482321,93781653446397701682961667766948241,108445687266650227555678831749167361,125184900814733057351483732809459681,144262920861999216020455260748945201,165973142704339215401988956943543921,190641681573470793705176441607975841,218630576996344103142807794339760961,250341268462557039747937124743219281,286218361857094751614277009933470801,326753707264991140811478515720435521,372490809957475540881738158272833441,424029597627673817513439403062184561,482031568259881455640732137886808881,547225344391761231308486996775826401,620412660965527688188300451573157121,702474815464296590198099228001521041,794379610595375902378486843006438161,897188821415476595676138900180228481
mul $0,10
add $0,1
pow $0,12
|
; A089658: Let S1 := (n,t)->add( k^t * add( binomial(n,j), j=0..k), k=0..n); a(n) = S1(n,1).
; 0,2,11,42,136,400,1104,2912,7424,18432,44800,107008,251904,585728,1347584,3072000,6946816,15597568,34799616,77201408,170393600,374341632,818937856,1784676352,3875536896,8388608000,18102616064,38956695552,83617644544,179046449152,382520524800,815506915328,1735166787584,3685081939968,7812545511424,16535624089600,34943853920256,73735998537728,155374736900096,326967270309888,687194767360000,1442559255642112,3024756488011776,6335385999245312
mov $3,$0
add $3,$0
add $0,1
mov $4,3
mul $4,$0
mov $0,$3
mov $2,$3
add $4,2
lpb $0,1
sub $0,2
mov $1,$4
mul $2,2
mul $1,$2
mul $1,2
lpe
div $1,32
|
/* Generated by Cython 0.29.11 */
/* BEGIN: Cython Metadata
{
"distutils": {
"depends": [],
"extra_compile_args": [
"-Wno-unused-function",
"-Wno-maybe-uninitialized",
"-O3",
"-ffast-math",
"-fopenmp",
"-std=c++11"
],
"extra_link_args": [
"-fopenmp",
"-std=c++11"
],
"include_dirs": [
"/home/massquantity/.conda/envs/conda_py36/lib/python3.6/site-packages/numpy/core/include"
],
"language": "c++",
"name": "libreco.algorithms._als",
"sources": [
"libreco/algorithms/_als.pyx"
]
},
"module_name": "libreco.algorithms._als"
}
END: Cython Metadata */
#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 < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_11"
#define CYTHON_HEX_VERSION 0x001D0BF0
#define CYTHON_FUTURE_DIVISION 0
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
#if PY_VERSION_HEX >= 0x02070000
#define HAVE_LONG_LONG
#endif
#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_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#if PY_VERSION_HEX < 0x03050000
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#undef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 1
#undef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 0
#undef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
#define CYTHON_USE_PYTYPE_LOOKUP 1
#endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1
#endif
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#if PY_VERSION_HEX < 0x030300F0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#elif !defined(CYTHON_USE_UNICODE_WRITER)
#define CYTHON_USE_UNICODE_WRITER 1
#endif
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#ifndef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 1
#endif
#ifndef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 1
#endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
#endif
#ifndef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
#endif
#ifndef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#undef SHIFT
#undef BASE
#undef MASK
#ifdef SIZEOF_VOID_P
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
#endif
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#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
#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_MAYBE_UNUSED_VAR
# if defined(__cplusplus)
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
# else
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
# define CYTHON_NCP_UNUSED
# else
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
#ifndef _MSC_STDINT_H_
#if _MSC_VER < 1300
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
#else
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
#if defined(__cplusplus) && __cplusplus >= 201103L
#if __has_cpp_attribute(fallthrough)
#define CYTHON_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
#define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
#endif
#endif
#ifndef CYTHON_FALLTHROUGH
#if __has_attribute(fallthrough)
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
#else
#define CYTHON_FALLTHROUGH
#endif
#endif
#if defined(__clang__ ) && defined(__apple_build_version__)
#if __apple_build_version__ < 7000000
#undef CYTHON_FALLTHROUGH
#define CYTHON_FALLTHROUGH
#endif
#endif
#endif
#ifndef __cplusplus
#error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
#if defined(__clang__)
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
#else
#define CYTHON_INLINE inline
#endif
#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; }
T *operator&() { return ptr; }
operator T&() { return *ptr; }
template<typename U> bool operator ==(U other) { return *ptr == other; }
template<typename U> bool operator !=(U other) { return *ptr != other; }
private:
T *ptr;
};
#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"
#if PY_VERSION_HEX < 0x030800A4
#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)
#elif PY_VERSION_HEX >= 0x030800B2
#define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#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
#ifndef METH_STACKLESS
#define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
#ifndef METH_FASTCALL
#define METH_FASTCALL 0x80
#endif
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
Py_ssize_t nargs, PyObject *kwnames);
#else
#define __Pyx_PyCFunctionFast _PyCFunctionFast
#define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
#define PyObject_Malloc(s) PyMem_Malloc(s)
#define PyObject_Free(p) PyMem_Free(p)
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
#define PyMem_RawMalloc(n) PyMem_Malloc(n)
#define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
#define PyMem_RawFree(p) PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
#define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
#define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
*key = PyThread_create_key();
return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
*key = Py_tss_NEEDS_INIT;
return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
PyThread_delete_key(*key);
*key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
#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
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
#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_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
#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)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
#define PyUnicode_2BYTE_KIND 2
#define PyUnicode_4BYTE_KIND 4
#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_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
#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]))
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#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
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? 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 && !defined(PyObject_ASCII)
#define PyObject_ASCII(o) PyObject_Repr(o)
#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
#define PyObject_Unicode PyObject_Str
#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
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
#else
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
#endif
#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) : (Py_INCREF(func), func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#else
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#endif
#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 defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif
#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
__pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#define __PYX_HAVE__libreco__algorithms___als
#define __PYX_HAVE_API__libreco__algorithms___als
/* Early includes */
#include <string.h>
#include <stdlib.h>
#include "pythread.h"
#include <stdio.h>
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif
typedef struct {PyObject **p; const 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_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#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))) )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
return (size_t) i < (size_t) limit;
}
#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)
#define __Pyx_sst_abs(value) ((Py_ssize_t)_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 const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((const 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)
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);
}
#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)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
(likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#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
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(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) + 1);
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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
/* Header.proto */
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
#elif defined(_Complex_I)
#define CYTHON_CCOMPLEX 1
#else
#define CYTHON_CCOMPLEX 0
#endif
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#include <complex>
#else
#include <complex.h>
#endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
#undef _Complex_I
#define _Complex_I 1.0fj
#endif
static const char *__pyx_f[] = {
"libreco/algorithms/_als.pyx",
"stringsource",
};
/* MemviewSliceStruct.proto */
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 __Pyx_MemoryView_Len(m) (m.shape[0])
/* Atomics.proto */
#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
/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#endif
/* BufferFormatStructs.proto */
#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;
/* "scipy/linalg/cython_lapack.pxd":15
* # The original libraries should be linked directly.
*
* ctypedef float s # <<<<<<<<<<<<<<
* ctypedef double d
* ctypedef float complex c
*/
typedef float __pyx_t_5scipy_6linalg_13cython_lapack_s;
/* "scipy/linalg/cython_lapack.pxd":16
*
* ctypedef float s
* ctypedef double d # <<<<<<<<<<<<<<
* ctypedef float complex c
* ctypedef double complex z
*/
typedef double __pyx_t_5scipy_6linalg_13cython_lapack_d;
/* "scipy/linalg/cython_blas.pxd":15
* # The original libraries should be linked directly.
*
* ctypedef float s # <<<<<<<<<<<<<<
* ctypedef double d
* ctypedef float complex c
*/
typedef float __pyx_t_5scipy_6linalg_11cython_blas_s;
/* "scipy/linalg/cython_blas.pxd":16
*
* ctypedef float s
* ctypedef double d # <<<<<<<<<<<<<<
* ctypedef float complex c
* ctypedef double complex z
*/
typedef double __pyx_t_5scipy_6linalg_11cython_blas_d;
/* Declarations.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< float > __pyx_t_float_complex;
#else
typedef float _Complex __pyx_t_float_complex;
#endif
#else
typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
/* Declarations.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< double > __pyx_t_double_complex;
#else
typedef double _Complex __pyx_t_double_complex;
#endif
#else
typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
/*--- Type declarations ---*/
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;
/* "scipy/linalg/cython_lapack.pxd":22
* # Function pointer type declarations for
* # gees and gges families of functions.
* ctypedef bint cselect1(c*) # <<<<<<<<<<<<<<
* ctypedef bint cselect2(c*, c*)
* ctypedef bint dselect2(d*, d*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_cselect1(__pyx_t_float_complex *);
/* "scipy/linalg/cython_lapack.pxd":23
* # gees and gges families of functions.
* ctypedef bint cselect1(c*)
* ctypedef bint cselect2(c*, c*) # <<<<<<<<<<<<<<
* ctypedef bint dselect2(d*, d*)
* ctypedef bint dselect3(d*, d*, d*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_cselect2(__pyx_t_float_complex *, __pyx_t_float_complex *);
/* "scipy/linalg/cython_lapack.pxd":24
* ctypedef bint cselect1(c*)
* ctypedef bint cselect2(c*, c*)
* ctypedef bint dselect2(d*, d*) # <<<<<<<<<<<<<<
* ctypedef bint dselect3(d*, d*, d*)
* ctypedef bint sselect2(s*, s*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_dselect2(__pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *);
/* "scipy/linalg/cython_lapack.pxd":25
* ctypedef bint cselect2(c*, c*)
* ctypedef bint dselect2(d*, d*)
* ctypedef bint dselect3(d*, d*, d*) # <<<<<<<<<<<<<<
* ctypedef bint sselect2(s*, s*)
* ctypedef bint sselect3(s*, s*, s*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_dselect3(__pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *);
/* "scipy/linalg/cython_lapack.pxd":26
* ctypedef bint dselect2(d*, d*)
* ctypedef bint dselect3(d*, d*, d*)
* ctypedef bint sselect2(s*, s*) # <<<<<<<<<<<<<<
* ctypedef bint sselect3(s*, s*, s*)
* ctypedef bint zselect1(z*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_sselect2(__pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *);
/* "scipy/linalg/cython_lapack.pxd":27
* ctypedef bint dselect3(d*, d*, d*)
* ctypedef bint sselect2(s*, s*)
* ctypedef bint sselect3(s*, s*, s*) # <<<<<<<<<<<<<<
* ctypedef bint zselect1(z*)
* ctypedef bint zselect2(z*, z*)
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_sselect3(__pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *);
/* "scipy/linalg/cython_lapack.pxd":28
* ctypedef bint sselect2(s*, s*)
* ctypedef bint sselect3(s*, s*, s*)
* ctypedef bint zselect1(z*) # <<<<<<<<<<<<<<
* ctypedef bint zselect2(z*, z*)
*
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_zselect1(__pyx_t_double_complex *);
/* "scipy/linalg/cython_lapack.pxd":29
* ctypedef bint sselect3(s*, s*, s*)
* ctypedef bint zselect1(z*)
* ctypedef bint zselect2(z*, z*) # <<<<<<<<<<<<<<
*
* cdef void cbbcsd(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, int *m, int *p, int *q, s *theta, s *phi, c *u1, int *ldu1, c *u2, int *ldu2, c *v1t, int *ldv1t, c *v2t, int *ldv2t, s *b11d, s *b11e, s *b12d, s *b12e, s *b21d, s *b21e, s *b22d, s *b22e, s *rwork, int *lrwork, int *info) nogil
*/
typedef int __pyx_t_5scipy_6linalg_13cython_lapack_zselect2(__pyx_t_double_complex *, __pyx_t_double_complex *);
/* "View.MemoryView":105
*
* @cname("__pyx_array")
* cdef class array: # <<<<<<<<<<<<<<
*
* cdef:
*/
struct __pyx_array_obj {
PyObject_HEAD
struct __pyx_vtabstruct_array *__pyx_vtab;
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":279
*
* @cname('__pyx_MemviewEnum')
* cdef class Enum(object): # <<<<<<<<<<<<<<
* cdef object name
* def __init__(self, name):
*/
struct __pyx_MemviewEnum_obj {
PyObject_HEAD
PyObject *name;
};
/* "View.MemoryView":330
*
* @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":961
*
* @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":105
*
* @cname("__pyx_array")
* cdef class array: # <<<<<<<<<<<<<<
*
* cdef:
*/
struct __pyx_vtabstruct_array {
PyObject *(*get_memview)(struct __pyx_array_obj *);
};
static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
/* "View.MemoryView":330
*
* @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":961
*
* @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) --- */
/* Refnanny.proto */
#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)
/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
/* RaiseArgTupleInvalid.proto */
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);
/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
const char* function_name);
/* IncludeStringH.proto */
#include <string.h>
/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif
/* MemviewSliceInit.proto */
#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);
/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
(version_var) = __PYX_GET_DICT_VERSION(dict);\
(cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
(VAR) = __pyx_dict_cached_value;\
} else {\
(VAR) = __pyx_dict_cached_value = (LOOKUP);\
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
}\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict) (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
#endif
/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
(var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
(likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
__Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name) {\
PY_UINT64_T __pyx_dict_version;\
PyObject *__pyx_dict_cached_value;\
(var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif
/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
#endif
/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
(sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
static size_t __pyx_pyframe_localsplus_offset = 0;
#include "frameobject.h"
#define __Pxy_PyFrame_Initialize_Offsets()\
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
#define __Pyx_PyFrame_GetLocalsplus(frame)\
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif
/* PyObjectCall.proto */
#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
/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif
/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
/* BuildPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
int prepend_sign, char padding_char);
/* CIntToPyUnicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char);
/* JoinPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
Py_UCS4 max_char);
/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
#endif
/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
#endif
/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif
/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif
/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif
/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
#endif
/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
int lineno, const char *filename,
int full_traceback, int nogil);
/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
__Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
/* None.proto */
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
/* UnaryNegOverflows.proto */
#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 *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
/* GetItemInt.proto */
#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 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);
/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
#endif
/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = 0;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = -1;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = 1;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
/* decode_c_string.proto */
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));
/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
#endif
/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
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
/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
(inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif
/* ListExtend.proto */
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
}
/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
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
/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);
/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif
/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif
/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);
/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);
/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif
/* CodeObjectCache.proto */
typedef struct {
PyCodeObject* code_object;
int code_line;
} __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);
/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename);
#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
/* BufferStructDeclare.proto */
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;
/* MemviewSliceIsContig.proto */
static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
/* OverlappingSlices.proto */
static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
__Pyx_memviewslice *slice2,
int ndim, size_t itemsize);
/* Capsule.proto */
static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
/* MemviewDtypeToObject.proto */
static CYTHON_INLINE PyObject *__pyx_memview_get_float(const char *itemp);
static CYTHON_INLINE int __pyx_memview_set_float(const char *itemp, PyObject *obj);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
/* RealImag.proto */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
#define __Pyx_CIMAG(z) ((z).imag())
#else
#define __Pyx_CREAL(z) (__real__(z))
#define __Pyx_CIMAG(z) (__imag__(z))
#endif
#else
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX\
&& (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq_float(a, b) ((a)==(b))
#define __Pyx_c_sum_float(a, b) ((a)+(b))
#define __Pyx_c_diff_float(a, b) ((a)-(b))
#define __Pyx_c_prod_float(a, b) ((a)*(b))
#define __Pyx_c_quot_float(a, b) ((a)/(b))
#define __Pyx_c_neg_float(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero_float(z) ((z)==(float)0)
#define __Pyx_c_conj_float(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs_float(z) (::std::abs(z))
#define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero_float(z) ((z)==0)
#define __Pyx_c_conj_float(z) (conjf(z))
#if 1
#define __Pyx_c_abs_float(z) (cabsf(z))
#define __Pyx_c_pow_float(a, b) (cpowf(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
#if 1
static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
#endif
#endif
/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq_double(a, b) ((a)==(b))
#define __Pyx_c_sum_double(a, b) ((a)+(b))
#define __Pyx_c_diff_double(a, b) ((a)-(b))
#define __Pyx_c_prod_double(a, b) ((a)*(b))
#define __Pyx_c_quot_double(a, b) ((a)/(b))
#define __Pyx_c_neg_double(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero_double(z) ((z)==(double)0)
#define __Pyx_c_conj_double(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs_double(z) (::std::abs(z))
#define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero_double(z) ((z)==0)
#define __Pyx_c_conj_double(z) (conj(z))
#if 1
#define __Pyx_c_abs_double(z) (cabs(z))
#define __Pyx_c_pow_double(a, b) (cpow(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
#if 1
static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
#endif
#endif
/* MemviewSliceCopyTemplate.proto */
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);
/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
/* IsLittleEndian.proto */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
/* BufferFormatCheck.proto */
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
__Pyx_BufFmt_StackElem* stack,
__Pyx_TypeInfo* type);
/* TypeInfoCompare.proto */
static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
/* MemviewSliceValidateAndInit.proto */
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);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float(PyObject *, int writable_flag);
/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);
/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
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.string' */
/* Module declarations from 'libc.stdlib' */
/* Module declarations from 'scipy.linalg.cython_lapack' */
static void (*__pyx_f_5scipy_6linalg_13cython_lapack_sposv)(char *, int *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, int *, int *); /*proto*/
/* Module declarations from 'scipy.linalg.cython_blas' */
static void (*__pyx_f_5scipy_6linalg_11cython_blas_saxpy)(int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *); /*proto*/
static __pyx_t_5scipy_6linalg_11cython_blas_s (*__pyx_f_5scipy_6linalg_11cython_blas_sdot)(int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *); /*proto*/
static void (*__pyx_f_5scipy_6linalg_11cython_blas_sscal)(int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *); /*proto*/
static void (*__pyx_f_5scipy_6linalg_11cython_blas_ssymv)(char *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *); /*proto*/
/* Module declarations from 'libreco.algorithms._als' */
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 int __pyx_memoryview_thread_locks_used;
static PyThread_type_lock __pyx_memoryview_thread_locks[8];
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_axpy(int *, float *, float *, int *, float *, int *); /*proto*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_posv(char *, int *, int *, float *, int *, float *, int *, int *); /*proto*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_symv(char *, int *, float *, float *, int *, float *, int *, float *, float *, int *); /*proto*/
static CYTHON_INLINE float __pyx_f_7libreco_10algorithms_4_als_dot(int *, float *, int *, float *, int *); /*proto*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_scal(int *, float *, float *, int *); /*proto*/
static void __pyx_f_7libreco_10algorithms_4_als__least_squares(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, int, int); /*proto*/
static void __pyx_f_7libreco_10algorithms_4_als__least_squares_cg(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, int, int, int); /*proto*/
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 PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_int__const__ = { "const int", NULL, sizeof(int const ), { 0 }, 0, IS_UNSIGNED(int const ) ? 'U' : 'I', IS_UNSIGNED(int const ), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_float__const__ = { "const float", NULL, sizeof(float const ), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "libreco.algorithms._als"
extern int __pyx_module_is_main_libreco__algorithms___als;
int __pyx_module_is_main_libreco__algorithms___als = 0;
/* Implementation of 'libreco.algorithms._als' */
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_IndexError;
static const char __pyx_k_O[] = "O";
static const char __pyx_k_X[] = "X";
static const char __pyx_k_Y[] = "Y";
static const char __pyx_k_c[] = "c";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_dot[] = "dot";
static const char __pyx_k_eye[] = "eye";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_reg[] = "reg";
static const char __pyx_k_base[] = "base";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_ndim[] = "ndim";
static const char __pyx_k_pack[] = "pack";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_step[] = "step";
static const char __pyx_k_stop[] = "stop";
static const char __pyx_k_task[] = "task";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_ASCII[] = "ASCII";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_indptr[] = "indptr";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_on_row[] = ") on row ";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_rating[] = "rating";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_single[] = "single";
static const char __pyx_k_struct[] = "struct";
static const char __pyx_k_unpack[] = "unpack";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_use_cg[] = "use_cg";
static const char __pyx_k_fortran[] = "fortran";
static const char __pyx_k_indices[] = "indices";
static const char __pyx_k_memview[] = "memview";
static const char __pyx_k_ranking[] = "ranking";
static const char __pyx_k_Ellipsis[] = "Ellipsis";
static const char __pyx_k_cg_steps[] = "cg_steps";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_transpose[] = "transpose";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_als_update[] = "als_update";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_interaction[] = "interaction";
static const char __pyx_k_num_threads[] = "num_threads";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static const char __pyx_k_libreco_algorithms__als[] = "libreco.algorithms._als";
static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static const char __pyx_k_libreco_algorithms__als_pyx[] = "libreco/algorithms/_als.pyx";
static const char __pyx_k_cython_lapack_posv_failed_err[] = "cython_lapack.posv failed (err=";
static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
static const char __pyx_k_Try_increasing_the_regularizati[] = ". Try increasing the regularization parameter.";
static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
static PyObject *__pyx_n_s_ASCII;
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_assign_to_read_only_memor;
static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
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_Incompatible_checksums_s_vs_0xb0;
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_n_b_O;
static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_kp_u_Try_increasing_the_regularizati;
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_n_s_View_MemoryView;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_n_s_Y;
static PyObject *__pyx_n_s_allocate_buffer;
static PyObject *__pyx_n_s_als_update;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_cg_steps;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_kp_s_contiguous_and_direct;
static PyObject *__pyx_kp_s_contiguous_and_indirect;
static PyObject *__pyx_kp_u_cython_lapack_posv_failed_err;
static PyObject *__pyx_n_s_data;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dot;
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_eye;
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_n_s_getstate;
static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_indices;
static PyObject *__pyx_n_s_indptr;
static PyObject *__pyx_n_s_interaction;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
static PyObject *__pyx_n_s_libreco_algorithms__als;
static PyObject *__pyx_kp_s_libreco_algorithms__als_pyx;
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_ndim;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_num_threads;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_kp_u_on_row;
static PyObject *__pyx_n_s_pack;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_Enum;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_ranking;
static PyObject *__pyx_n_s_rating;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_reg;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_single;
static PyObject *__pyx_n_s_size;
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_kp_s_stringsource;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_task;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_transpose;
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_update;
static PyObject *__pyx_n_s_use_cg;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_pf_7libreco_10algorithms_4_als_als_update(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_interaction, PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyObject *__pyx_v_reg, PyObject *__pyx_v_task, PyObject *__pyx_v_use_cg, PyObject *__pyx_v_num_threads, PyObject *__pyx_v_cg_steps); /* 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 Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* 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 PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* 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 PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* 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_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* 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_3;
static PyObject *__pyx_int_184977713;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
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__15;
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__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_codeobj__20;
static PyObject *__pyx_codeobj__27;
/* Late includes */
/* "libreco/algorithms/_als.pyx":11
*
*
* cdef inline void axpy(int *n, float *da, float *dx, int *incx, float *dy, # <<<<<<<<<<<<<<
* int *incy) nogil:
* cython_blas.saxpy(n, da, dx, incx, dy, incy)
*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_axpy(int *__pyx_v_n, float *__pyx_v_da, float *__pyx_v_dx, int *__pyx_v_incx, float *__pyx_v_dy, int *__pyx_v_incy) {
/* "libreco/algorithms/_als.pyx":13
* cdef inline void axpy(int *n, float *da, float *dx, int *incx, float *dy,
* int *incy) nogil:
* cython_blas.saxpy(n, da, dx, incx, dy, incy) # <<<<<<<<<<<<<<
*
*
*/
__pyx_f_5scipy_6linalg_11cython_blas_saxpy(__pyx_v_n, __pyx_v_da, __pyx_v_dx, __pyx_v_incx, __pyx_v_dy, __pyx_v_incy);
/* "libreco/algorithms/_als.pyx":11
*
*
* cdef inline void axpy(int *n, float *da, float *dx, int *incx, float *dy, # <<<<<<<<<<<<<<
* int *incy) nogil:
* cython_blas.saxpy(n, da, dx, incx, dy, incy)
*/
/* function exit code */
}
/* "libreco/algorithms/_als.pyx":16
*
*
* cdef inline void posv(char *u, int *n, int *nrhs, float *a, int *lda, # <<<<<<<<<<<<<<
* float *b, int *ldb, int *info) nogil:
* cython_lapack.sposv(u, n, nrhs, a, lda, b, ldb, info)
*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_posv(char *__pyx_v_u, int *__pyx_v_n, int *__pyx_v_nrhs, float *__pyx_v_a, int *__pyx_v_lda, float *__pyx_v_b, int *__pyx_v_ldb, int *__pyx_v_info) {
/* "libreco/algorithms/_als.pyx":18
* cdef inline void posv(char *u, int *n, int *nrhs, float *a, int *lda,
* float *b, int *ldb, int *info) nogil:
* cython_lapack.sposv(u, n, nrhs, a, lda, b, ldb, info) # <<<<<<<<<<<<<<
*
*
*/
__pyx_f_5scipy_6linalg_13cython_lapack_sposv(__pyx_v_u, __pyx_v_n, __pyx_v_nrhs, __pyx_v_a, __pyx_v_lda, __pyx_v_b, __pyx_v_ldb, __pyx_v_info);
/* "libreco/algorithms/_als.pyx":16
*
*
* cdef inline void posv(char *u, int *n, int *nrhs, float *a, int *lda, # <<<<<<<<<<<<<<
* float *b, int *ldb, int *info) nogil:
* cython_lapack.sposv(u, n, nrhs, a, lda, b, ldb, info)
*/
/* function exit code */
}
/* "libreco/algorithms/_als.pyx":21
*
*
* cdef inline void symv(char *u, int *n, float *alpha, float *a, int *lda, # <<<<<<<<<<<<<<
* float *x, int *incx, float *beta, float *y,
* int *incy) nogil:
*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_symv(char *__pyx_v_u, int *__pyx_v_n, float *__pyx_v_alpha, float *__pyx_v_a, int *__pyx_v_lda, float *__pyx_v_x, int *__pyx_v_incx, float *__pyx_v_beta, float *__pyx_v_y, int *__pyx_v_incy) {
/* "libreco/algorithms/_als.pyx":24
* float *x, int *incx, float *beta, float *y,
* int *incy) nogil:
* cython_blas.ssymv(u, n, alpha, a, lda, x, incx, beta, y, incy) # <<<<<<<<<<<<<<
*
*
*/
__pyx_f_5scipy_6linalg_11cython_blas_ssymv(__pyx_v_u, __pyx_v_n, __pyx_v_alpha, __pyx_v_a, __pyx_v_lda, __pyx_v_x, __pyx_v_incx, __pyx_v_beta, __pyx_v_y, __pyx_v_incy);
/* "libreco/algorithms/_als.pyx":21
*
*
* cdef inline void symv(char *u, int *n, float *alpha, float *a, int *lda, # <<<<<<<<<<<<<<
* float *x, int *incx, float *beta, float *y,
* int *incy) nogil:
*/
/* function exit code */
}
/* "libreco/algorithms/_als.pyx":27
*
*
* cdef inline float dot(int *n, float *sx, int *incx, float *sy, # <<<<<<<<<<<<<<
* int *incy) nogil:
* return cython_blas.sdot(n, sx, incx, sy, incy)
*/
static CYTHON_INLINE float __pyx_f_7libreco_10algorithms_4_als_dot(int *__pyx_v_n, float *__pyx_v_sx, int *__pyx_v_incx, float *__pyx_v_sy, int *__pyx_v_incy) {
float __pyx_r;
/* "libreco/algorithms/_als.pyx":29
* cdef inline float dot(int *n, float *sx, int *incx, float *sy,
* int *incy) nogil:
* return cython_blas.sdot(n, sx, incx, sy, incy) # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_f_5scipy_6linalg_11cython_blas_sdot(__pyx_v_n, __pyx_v_sx, __pyx_v_incx, __pyx_v_sy, __pyx_v_incy);
goto __pyx_L0;
/* "libreco/algorithms/_als.pyx":27
*
*
* cdef inline float dot(int *n, float *sx, int *incx, float *sy, # <<<<<<<<<<<<<<
* int *incy) nogil:
* return cython_blas.sdot(n, sx, incx, sy, incy)
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "libreco/algorithms/_als.pyx":32
*
*
* cdef inline void scal(int *n, float *sa, float *sx, int *incx) nogil: # <<<<<<<<<<<<<<
* cython_blas.sscal(n, sa, sx, incx)
*
*/
static CYTHON_INLINE void __pyx_f_7libreco_10algorithms_4_als_scal(int *__pyx_v_n, float *__pyx_v_sa, float *__pyx_v_sx, int *__pyx_v_incx) {
/* "libreco/algorithms/_als.pyx":33
*
* cdef inline void scal(int *n, float *sa, float *sx, int *incx) nogil:
* cython_blas.sscal(n, sa, sx, incx) # <<<<<<<<<<<<<<
*
*
*/
__pyx_f_5scipy_6linalg_11cython_blas_sscal(__pyx_v_n, __pyx_v_sa, __pyx_v_sx, __pyx_v_incx);
/* "libreco/algorithms/_als.pyx":32
*
*
* cdef inline void scal(int *n, float *sa, float *sx, int *incx) nogil: # <<<<<<<<<<<<<<
* cython_blas.sscal(n, sa, sx, incx)
*
*/
/* function exit code */
}
/* "libreco/algorithms/_als.pyx":36
*
*
* def als_update(interaction, X, Y, reg, task, use_cg=True, # <<<<<<<<<<<<<<
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
*/
/* Python wrapper */
static PyObject *__pyx_pw_7libreco_10algorithms_4_als_1als_update(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7libreco_10algorithms_4_als_1als_update = {"als_update", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7libreco_10algorithms_4_als_1als_update, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7libreco_10algorithms_4_als_1als_update(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_interaction = 0;
PyObject *__pyx_v_X = 0;
PyObject *__pyx_v_Y = 0;
PyObject *__pyx_v_reg = 0;
PyObject *__pyx_v_task = 0;
PyObject *__pyx_v_use_cg = 0;
PyObject *__pyx_v_num_threads = 0;
PyObject *__pyx_v_cg_steps = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("als_update (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_interaction,&__pyx_n_s_X,&__pyx_n_s_Y,&__pyx_n_s_reg,&__pyx_n_s_task,&__pyx_n_s_use_cg,&__pyx_n_s_num_threads,&__pyx_n_s_cg_steps,0};
PyObject* values[8] = {0,0,0,0,0,0,0,0};
values[5] = ((PyObject *)Py_True);
values[6] = ((PyObject *)__pyx_int_1);
values[7] = ((PyObject *)__pyx_int_3);
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
CYTHON_FALLTHROUGH;
case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
CYTHON_FALLTHROUGH;
case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interaction)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("als_update", 0, 5, 8, 1); __PYX_ERR(0, 36, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Y)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("als_update", 0, 5, 8, 2); __PYX_ERR(0, 36, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reg)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("als_update", 0, 5, 8, 3); __PYX_ERR(0, 36, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_task)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("als_update", 0, 5, 8, 4); __PYX_ERR(0, 36, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 5:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_cg);
if (value) { values[5] = value; kw_args--; }
}
CYTHON_FALLTHROUGH;
case 6:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_threads);
if (value) { values[6] = value; kw_args--; }
}
CYTHON_FALLTHROUGH;
case 7:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cg_steps);
if (value) { values[7] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "als_update") < 0)) __PYX_ERR(0, 36, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
CYTHON_FALLTHROUGH;
case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
CYTHON_FALLTHROUGH;
case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
values[3] = PyTuple_GET_ITEM(__pyx_args, 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_interaction = values[0];
__pyx_v_X = values[1];
__pyx_v_Y = values[2];
__pyx_v_reg = values[3];
__pyx_v_task = values[4];
__pyx_v_use_cg = values[5];
__pyx_v_num_threads = values[6];
__pyx_v_cg_steps = values[7];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("als_update", 0, 5, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 36, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("libreco.algorithms._als.als_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_7libreco_10algorithms_4_als_als_update(__pyx_self, __pyx_v_interaction, __pyx_v_X, __pyx_v_Y, __pyx_v_reg, __pyx_v_task, __pyx_v_use_cg, __pyx_v_num_threads, __pyx_v_cg_steps);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_7libreco_10algorithms_4_als_als_update(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_interaction, PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyObject *__pyx_v_reg, PyObject *__pyx_v_task, PyObject *__pyx_v_use_cg, PyObject *__pyx_v_num_threads, PyObject *__pyx_v_cg_steps) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
__Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_5 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
double __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
int __pyx_t_12;
__Pyx_memviewslice __pyx_t_13 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_14 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_15 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_RefNannySetupContext("als_update", 0);
/* "libreco/algorithms/_als.pyx":38
* def als_update(interaction, X, Y, reg, task, use_cg=True,
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg: # <<<<<<<<<<<<<<
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
*/
__pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_task, __pyx_n_s_rating, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 38, __pyx_L1_error)
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_use_cg); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 38, __pyx_L1_error)
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":39
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg:
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "libreco/algorithms/_als.pyx":40
* if task == "rating" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0, cg_steps) # <<<<<<<<<<<<<<
* elif task == "rating" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr,
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_X, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 40, __pyx_L1_error)
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_Y, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 40, __pyx_L1_error)
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_reg); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L1_error)
__pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_num_threads); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L1_error)
__pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_cg_steps); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L1_error)
/* "libreco/algorithms/_als.pyx":39
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg:
*/
__pyx_f_7libreco_10algorithms_4_als__least_squares_cg(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, 0, __pyx_t_11);
__PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
__pyx_t_4.memview = NULL;
__pyx_t_4.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
__pyx_t_5.memview = NULL;
__pyx_t_5.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
__pyx_t_7.memview = NULL;
__pyx_t_7.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
__pyx_t_8.memview = NULL;
__pyx_t_8.data = NULL;
/* "libreco/algorithms/_als.pyx":38
* def als_update(interaction, X, Y, reg, task, use_cg=True,
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg: # <<<<<<<<<<<<<<
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
*/
goto __pyx_L3;
}
/* "libreco/algorithms/_als.pyx":41
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg: # <<<<<<<<<<<<<<
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0)
*/
__pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_task, __pyx_n_s_rating, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 41, __pyx_L1_error)
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_use_cg); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 41, __pyx_L1_error)
__pyx_t_12 = ((!__pyx_t_2) != 0);
__pyx_t_1 = __pyx_t_12;
__pyx_L6_bool_binop_done:;
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":42
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg:
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 42, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 42, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "libreco/algorithms/_als.pyx":43
* elif task == "rating" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0) # <<<<<<<<<<<<<<
* elif task == "ranking" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr,
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(0, 43, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_X, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 43, __pyx_L1_error)
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_Y, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 43, __pyx_L1_error)
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_reg); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
__pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_num_threads); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
/* "libreco/algorithms/_als.pyx":42
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg:
*/
__pyx_f_7libreco_10algorithms_4_als__least_squares(__pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_11, 0);
__PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
__pyx_t_13.memview = NULL;
__pyx_t_13.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
__pyx_t_14.memview = NULL;
__pyx_t_14.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
__pyx_t_15.memview = NULL;
__pyx_t_15.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
__pyx_t_8.memview = NULL;
__pyx_t_8.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
__pyx_t_7.memview = NULL;
__pyx_t_7.data = NULL;
/* "libreco/algorithms/_als.pyx":41
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0, cg_steps)
* elif task == "rating" and not use_cg: # <<<<<<<<<<<<<<
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0)
*/
goto __pyx_L3;
}
/* "libreco/algorithms/_als.pyx":44
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg: # <<<<<<<<<<<<<<
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
*/
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_task, __pyx_n_s_ranking, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 44, __pyx_L1_error)
if (__pyx_t_12) {
} else {
__pyx_t_1 = __pyx_t_12;
goto __pyx_L8_bool_binop_done;
}
__pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_use_cg); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 44, __pyx_L1_error)
__pyx_t_1 = __pyx_t_12;
__pyx_L8_bool_binop_done:;
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":45
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg:
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 45, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 45, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "libreco/algorithms/_als.pyx":46
* elif task == "ranking" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1, cg_steps) # <<<<<<<<<<<<<<
* elif task == "ranking" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr,
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_X, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_Y, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_reg); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_num_threads); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
__pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_cg_steps); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
/* "libreco/algorithms/_als.pyx":45
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg:
* _least_squares_cg(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg:
*/
__pyx_f_7libreco_10algorithms_4_als__least_squares_cg(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_11, 1, __pyx_t_10);
__PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
__pyx_t_4.memview = NULL;
__pyx_t_4.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
__pyx_t_5.memview = NULL;
__pyx_t_5.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
__pyx_t_7.memview = NULL;
__pyx_t_7.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
__pyx_t_8.memview = NULL;
__pyx_t_8.data = NULL;
/* "libreco/algorithms/_als.pyx":44
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 0)
* elif task == "ranking" and use_cg: # <<<<<<<<<<<<<<
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
*/
goto __pyx_L3;
}
/* "libreco/algorithms/_als.pyx":47
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg: # <<<<<<<<<<<<<<
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1)
*/
__pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_task, __pyx_n_s_ranking, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 47, __pyx_L1_error)
if (__pyx_t_12) {
} else {
__pyx_t_1 = __pyx_t_12;
goto __pyx_L10_bool_binop_done;
}
__pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_use_cg); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 47, __pyx_L1_error)
__pyx_t_2 = ((!__pyx_t_12) != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L10_bool_binop_done:;
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":48
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 1)
*
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_indptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "libreco/algorithms/_als.pyx":49
* elif task == "ranking" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_interaction, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(__pyx_t_3, 0); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(0, 49, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_X, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 49, __pyx_L1_error)
__pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_v_Y, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 49, __pyx_L1_error)
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_reg); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L1_error)
__pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_num_threads); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L1_error)
/* "libreco/algorithms/_als.pyx":48
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg:
* _least_squares(interaction.indices, interaction.indptr, # <<<<<<<<<<<<<<
* interaction.data, X, Y, reg, num_threads, 1)
*
*/
__pyx_f_7libreco_10algorithms_4_als__least_squares(__pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
__pyx_t_13.memview = NULL;
__pyx_t_13.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
__pyx_t_14.memview = NULL;
__pyx_t_14.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
__pyx_t_15.memview = NULL;
__pyx_t_15.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
__pyx_t_8.memview = NULL;
__pyx_t_8.data = NULL;
__PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
__pyx_t_7.memview = NULL;
__pyx_t_7.data = NULL;
/* "libreco/algorithms/_als.pyx":47
* _least_squares_cg(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1, cg_steps)
* elif task == "ranking" and not use_cg: # <<<<<<<<<<<<<<
* _least_squares(interaction.indices, interaction.indptr,
* interaction.data, X, Y, reg, num_threads, 1)
*/
}
__pyx_L3:;
/* "libreco/algorithms/_als.pyx":36
*
*
* def als_update(interaction, X, Y, reg, task, use_cg=True, # <<<<<<<<<<<<<<
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
__Pyx_AddTraceback("libreco.algorithms._als.als_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "libreco/algorithms/_als.pyx":55
* @cython.wraparound(False)
* @cython.cdivision(True)
* cdef void _least_squares(const int[:] indices, const int[:] indptr, # <<<<<<<<<<<<<<
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit):
*/
static void __pyx_f_7libreco_10algorithms_4_als__least_squares(__Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_indptr, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_X, __Pyx_memviewslice __pyx_v_Y, double __pyx_v_reg, int __pyx_v_num_threads, int __pyx_v_implicit) {
CYTHON_UNUSED int __pyx_v_n_x;
int __pyx_v_embed_size;
int __pyx_v_m;
int __pyx_v_i;
int __pyx_v_j;
int __pyx_v_index;
int __pyx_v_err;
int __pyx_v_one;
float __pyx_v_rating;
float __pyx_v_confidence;
float __pyx_v_temp;
__Pyx_memviewslice __pyx_v_initialA = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_initialB = { 0, 0, { 0 }, { 0 }, { 0 } };
float *__pyx_v_A;
float *__pyx_v_b;
__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;
PyObject *__pyx_t_7 = NULL;
int __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
__Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_t_12;
int __pyx_t_13;
Py_ssize_t __pyx_t_14;
Py_ssize_t __pyx_t_15;
Py_ssize_t __pyx_t_16;
Py_ssize_t __pyx_t_17;
int __pyx_t_18;
Py_ssize_t __pyx_t_19;
int __pyx_t_20;
int __pyx_t_21;
Py_ssize_t __pyx_t_22;
Py_ssize_t __pyx_t_23;
int __pyx_t_24;
int __pyx_t_25;
int __pyx_t_26;
Py_ssize_t __pyx_t_27;
Py_ssize_t __pyx_t_28;
Py_ssize_t __pyx_t_29;
Py_ssize_t __pyx_t_30;
Py_ssize_t __pyx_t_31;
Py_ssize_t __pyx_t_32;
Py_ssize_t __pyx_t_33;
Py_ssize_t __pyx_t_34;
Py_ssize_t __pyx_t_35;
Py_ssize_t __pyx_t_36;
Py_ssize_t __pyx_t_37;
Py_ssize_t __pyx_t_38;
Py_ssize_t __pyx_t_39;
Py_ssize_t __pyx_t_40;
Py_ssize_t __pyx_t_41;
Py_ssize_t __pyx_t_42;
Py_ssize_t __pyx_t_43;
Py_UCS4 __pyx_t_44;
char const *__pyx_t_45;
PyObject *__pyx_t_46 = NULL;
PyObject *__pyx_t_47 = NULL;
PyObject *__pyx_t_48 = NULL;
PyObject *__pyx_t_49 = NULL;
PyObject *__pyx_t_50 = NULL;
PyObject *__pyx_t_51 = NULL;
__Pyx_RefNannySetupContext("_least_squares", 0);
/* "libreco/algorithms/_als.pyx":58
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit):
* cdef int n_x = X.shape[0], embed_size = X.shape[1] # <<<<<<<<<<<<<<
* cdef int m, i, j, index, err, one = 1
* cdef float rating, confidence, temp
*/
__pyx_v_n_x = (__pyx_v_X.shape[0]);
__pyx_v_embed_size = (__pyx_v_X.shape[1]);
/* "libreco/algorithms/_als.pyx":59
* int num_threads, int implicit):
* cdef int n_x = X.shape[0], embed_size = X.shape[1]
* cdef int m, i, j, index, err, one = 1 # <<<<<<<<<<<<<<
* cdef float rating, confidence, temp
*
*/
__pyx_v_one = 1;
/* "libreco/algorithms/_als.pyx":63
*
* cdef float[:, ::1] initialA
* if implicit > 0: # <<<<<<<<<<<<<<
* initialA = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
*/
__pyx_t_1 = ((__pyx_v_implicit > 0) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":64
* cdef float[:, ::1] initialA
* if implicit > 0:
* initialA = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single) # <<<<<<<<<<<<<<
* else:
* initialA = reg * np.eye(embed_size, dtype=np.single)
*/
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_transpose); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_Y, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
if (likely(__pyx_t_7)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
__Pyx_INCREF(__pyx_t_7);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_6, function);
}
}
__pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_Y, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_5 = NULL;
__pyx_t_8 = 0;
if (CYTHON_UNPACK_METHODS && 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);
__pyx_t_8 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_6};
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_6};
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
{
__pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
if (__pyx_t_5) {
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
}
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_6);
__pyx_t_3 = 0;
__pyx_t_6 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyFloat_FromDouble(__pyx_v_reg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_eye); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_embed_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_single); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyNumber_Multiply(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_t_9, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_initialA = __pyx_t_10;
__pyx_t_10.memview = NULL;
__pyx_t_10.data = NULL;
/* "libreco/algorithms/_als.pyx":63
*
* cdef float[:, ::1] initialA
* if implicit > 0: # <<<<<<<<<<<<<<
* initialA = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
*/
goto __pyx_L3;
}
/* "libreco/algorithms/_als.pyx":66
* initialA = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
* initialA = reg * np.eye(embed_size, dtype=np.single) # <<<<<<<<<<<<<<
* cdef float[:] initialB = np.zeros(embed_size, dtype=np.single)
* cdef float *A
*/
/*else*/ {
__pyx_t_9 = PyFloat_FromDouble(__pyx_v_reg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_eye); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_embed_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_single); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyNumber_Multiply(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_v_initialA = __pyx_t_10;
__pyx_t_10.memview = NULL;
__pyx_t_10.data = NULL;
}
__pyx_L3:;
/* "libreco/algorithms/_als.pyx":67
* else:
* initialA = reg * np.eye(embed_size, dtype=np.single)
* cdef float[:] initialB = np.zeros(embed_size, dtype=np.single) # <<<<<<<<<<<<<<
* cdef float *A
* cdef float *b
*/
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_embed_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_single); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_ds_float(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_initialB = __pyx_t_11;
__pyx_t_11.memview = NULL;
__pyx_t_11.data = NULL;
/* "libreco/algorithms/_als.pyx":71
* cdef float *b
*
* with nogil, parallel(num_threads=num_threads): # <<<<<<<<<<<<<<
* A = <float *> malloc(sizeof(float) * embed_size * embed_size)
* b = <float *> malloc(sizeof(float) * embed_size)
*/
{
#ifdef WITH_THREAD
PyThreadState *_save;
Py_UNBLOCK_THREADS
__Pyx_FastGIL_Remember();
#endif
/*try:*/ {
{
const char *__pyx_parallel_filename = NULL; int __pyx_parallel_lineno = 0, __pyx_parallel_clineno = 0;
PyObject *__pyx_parallel_exc_type = NULL, *__pyx_parallel_exc_value = NULL, *__pyx_parallel_exc_tb = NULL;
int __pyx_parallel_why;
__pyx_parallel_why = 0;
#if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
#undef likely
#undef unlikely
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#ifdef _OPENMP
#pragma omp parallel private(__pyx_v_A, __pyx_v_b) private(__pyx_t_1, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20, __pyx_t_21, __pyx_t_22, __pyx_t_23, __pyx_t_24, __pyx_t_25, __pyx_t_26, __pyx_t_27, __pyx_t_28, __pyx_t_29, __pyx_t_30, __pyx_t_31, __pyx_t_32, __pyx_t_33, __pyx_t_34, __pyx_t_35, __pyx_t_36, __pyx_t_37, __pyx_t_38, __pyx_t_39, __pyx_t_40, __pyx_t_41, __pyx_t_42, __pyx_t_43, __pyx_t_44, __pyx_t_45, __pyx_t_8) firstprivate(__pyx_t_2, __pyx_t_46, __pyx_t_47, __pyx_t_48, __pyx_t_49, __pyx_t_50, __pyx_t_51, __pyx_t_7) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb) num_threads(__pyx_v_num_threads)
#endif /* _OPENMP */
{
#ifdef _OPENMP
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
Py_BEGIN_ALLOW_THREADS
#endif /* _OPENMP */
/* Initialize private variables to invalid values */
__pyx_v_A = ((float *)1);
__pyx_v_b = ((float *)1);
/* "libreco/algorithms/_als.pyx":72
*
* with nogil, parallel(num_threads=num_threads):
* A = <float *> malloc(sizeof(float) * embed_size * embed_size) # <<<<<<<<<<<<<<
* b = <float *> malloc(sizeof(float) * embed_size)
* try:
*/
__pyx_v_A = ((float *)malloc((((sizeof(float)) * __pyx_v_embed_size) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":73
* with nogil, parallel(num_threads=num_threads):
* A = <float *> malloc(sizeof(float) * embed_size * embed_size)
* b = <float *> malloc(sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* try:
* for m in prange(n_x, schedule="guided"):
*/
__pyx_v_b = ((float *)malloc(((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":74
* A = <float *> malloc(sizeof(float) * embed_size * embed_size)
* b = <float *> malloc(sizeof(float) * embed_size)
* try: # <<<<<<<<<<<<<<
* for m in prange(n_x, schedule="guided"):
* memcpy(A, &initialA[0, 0], sizeof(float) * embed_size * embed_size)
*/
/*try:*/ {
/* "libreco/algorithms/_als.pyx":75
* b = <float *> malloc(sizeof(float) * embed_size)
* try:
* for m in prange(n_x, schedule="guided"): # <<<<<<<<<<<<<<
* memcpy(A, &initialA[0, 0], sizeof(float) * embed_size * embed_size)
* memcpy(b, &initialB[0], sizeof(float) * embed_size)
*/
__pyx_t_8 = __pyx_v_n_x;
if (1 == 0) abort();
{
float __pyx_parallel_temp0 = ((float)__PYX_NAN());
int __pyx_parallel_temp1 = ((int)0xbad0bad0);
int __pyx_parallel_temp2 = ((int)0xbad0bad0);
int __pyx_parallel_temp3 = ((int)0xbad0bad0);
int __pyx_parallel_temp4 = ((int)0xbad0bad0);
int __pyx_parallel_temp5 = ((int)0xbad0bad0);
float __pyx_parallel_temp6 = ((float)__PYX_NAN());
float __pyx_parallel_temp7 = ((float)__PYX_NAN());
const char *__pyx_parallel_filename = NULL; int __pyx_parallel_lineno = 0, __pyx_parallel_clineno = 0;
PyObject *__pyx_parallel_exc_type = NULL, *__pyx_parallel_exc_value = NULL, *__pyx_parallel_exc_tb = NULL;
int __pyx_parallel_why;
__pyx_parallel_why = 0;
__pyx_t_13 = (__pyx_t_8 - 0 + 1 - 1/abs(1)) / 1;
if (__pyx_t_13 > 0)
{
#ifdef _OPENMP
#pragma omp for lastprivate(__pyx_v_confidence) lastprivate(__pyx_v_err) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) firstprivate(__pyx_v_m) lastprivate(__pyx_v_m) lastprivate(__pyx_v_rating) lastprivate(__pyx_v_temp) schedule(guided)
#endif /* _OPENMP */
for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12++){
if (__pyx_parallel_why < 2)
{
__pyx_v_m = (int)(0 + 1 * __pyx_t_12);
/* Initialize private variables to invalid values */
__pyx_v_confidence = ((float)__PYX_NAN());
__pyx_v_err = ((int)0xbad0bad0);
__pyx_v_i = ((int)0xbad0bad0);
__pyx_v_index = ((int)0xbad0bad0);
__pyx_v_j = ((int)0xbad0bad0);
__pyx_v_rating = ((float)__PYX_NAN());
__pyx_v_temp = ((float)__PYX_NAN());
/* "libreco/algorithms/_als.pyx":76
* try:
* for m in prange(n_x, schedule="guided"):
* memcpy(A, &initialA[0, 0], sizeof(float) * embed_size * embed_size) # <<<<<<<<<<<<<<
* memcpy(b, &initialB[0], sizeof(float) * embed_size)
*
*/
__pyx_t_14 = 0;
__pyx_t_15 = 0;
(void)(memcpy(__pyx_v_A, (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_initialA.data + __pyx_t_14 * __pyx_v_initialA.strides[0]) )) + __pyx_t_15)) )))), (((sizeof(float)) * __pyx_v_embed_size) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":77
* for m in prange(n_x, schedule="guided"):
* memcpy(A, &initialA[0, 0], sizeof(float) * embed_size * embed_size)
* memcpy(b, &initialB[0], sizeof(float) * embed_size) # <<<<<<<<<<<<<<
*
* for index in range(indptr[m], indptr[m+1]):
*/
__pyx_t_16 = 0;
(void)(memcpy(__pyx_v_b, (&(*((float *) ( /* dim=0 */ (__pyx_v_initialB.data + __pyx_t_16 * __pyx_v_initialB.strides[0]) )))), ((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":79
* memcpy(b, &initialB[0], sizeof(float) * embed_size)
*
* for index in range(indptr[m], indptr[m+1]): # <<<<<<<<<<<<<<
* if implicit > 0:
* i = indices[index]
*/
__pyx_t_17 = (__pyx_v_m + 1);
__pyx_t_18 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_17 * __pyx_v_indptr.strides[0]) )));
__pyx_t_19 = __pyx_v_m;
__pyx_t_20 = __pyx_t_18;
for (__pyx_t_21 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_19 * __pyx_v_indptr.strides[0]) ))); __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
__pyx_v_index = __pyx_t_21;
/* "libreco/algorithms/_als.pyx":80
*
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
__pyx_t_1 = ((__pyx_v_implicit > 0) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":81
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0:
* i = indices[index] # <<<<<<<<<<<<<<
* confidence = data[index]
* # compute partial A = Yu^T @ Cu @ Yu + lambda * I
*/
__pyx_t_22 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_22 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":82
* if implicit > 0:
* i = indices[index]
* confidence = data[index] # <<<<<<<<<<<<<<
* # compute partial A = Yu^T @ Cu @ Yu + lambda * I
* for j in range(embed_size):
*/
__pyx_t_23 = __pyx_v_index;
__pyx_v_confidence = (*((float const *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_23 * __pyx_v_data.strides[0]) )));
/* "libreco/algorithms/_als.pyx":84
* confidence = data[index]
* # compute partial A = Yu^T @ Cu @ Yu + lambda * I
* for j in range(embed_size): # <<<<<<<<<<<<<<
* temp = (confidence - 1) * Y[i, j]
* axpy(&embed_size, &temp, &Y[i, 0], &one,
*/
__pyx_t_24 = __pyx_v_embed_size;
__pyx_t_25 = __pyx_t_24;
for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
__pyx_v_j = __pyx_t_26;
/* "libreco/algorithms/_als.pyx":85
* # compute partial A = Yu^T @ Cu @ Yu + lambda * I
* for j in range(embed_size):
* temp = (confidence - 1) * Y[i, j] # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, &Y[i, 0], &one,
* A + j * embed_size, &one)
*/
__pyx_t_27 = __pyx_v_i;
__pyx_t_28 = __pyx_v_j;
__pyx_v_temp = ((__pyx_v_confidence - 1.0) * (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_27 * __pyx_v_Y.strides[0]) )) + __pyx_t_28)) ))));
/* "libreco/algorithms/_als.pyx":86
* for j in range(embed_size):
* temp = (confidence - 1) * Y[i, j]
* axpy(&embed_size, &temp, &Y[i, 0], &one, # <<<<<<<<<<<<<<
* A + j * embed_size, &one)
*
*/
__pyx_t_29 = __pyx_v_i;
__pyx_t_30 = 0;
/* "libreco/algorithms/_als.pyx":87
* temp = (confidence - 1) * Y[i, j]
* axpy(&embed_size, &temp, &Y[i, 0], &one,
* A + j * embed_size, &one) # <<<<<<<<<<<<<<
*
* # compute partial b = Yu^T @ Ru
*/
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_29 * __pyx_v_Y.strides[0]) )) + __pyx_t_30)) )))), (&__pyx_v_one), (__pyx_v_A + (__pyx_v_j * __pyx_v_embed_size)), (&__pyx_v_one));
}
/* "libreco/algorithms/_als.pyx":90
*
* # compute partial b = Yu^T @ Ru
* axpy(&embed_size, &confidence, &Y[i, 0], &one, b, &one) # <<<<<<<<<<<<<<
* else:
* i = indices[index]
*/
__pyx_t_31 = __pyx_v_i;
__pyx_t_32 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_confidence), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_31 * __pyx_v_Y.strides[0]) )) + __pyx_t_32)) )))), (&__pyx_v_one), __pyx_v_b, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":80
*
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
goto __pyx_L22;
}
/* "libreco/algorithms/_als.pyx":92
* axpy(&embed_size, &confidence, &Y[i, 0], &one, b, &one)
* else:
* i = indices[index] # <<<<<<<<<<<<<<
* rating = data[index]
* # compute partial A = Yu^T @ Yu + lambda * I
*/
/*else*/ {
__pyx_t_33 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_33 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":93
* else:
* i = indices[index]
* rating = data[index] # <<<<<<<<<<<<<<
* # compute partial A = Yu^T @ Yu + lambda * I
* for j in range(embed_size):
*/
__pyx_t_34 = __pyx_v_index;
__pyx_v_rating = (*((float const *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_34 * __pyx_v_data.strides[0]) )));
/* "libreco/algorithms/_als.pyx":95
* rating = data[index]
* # compute partial A = Yu^T @ Yu + lambda * I
* for j in range(embed_size): # <<<<<<<<<<<<<<
* axpy(&embed_size, &Y[i, j], &Y[i, 0], &one, A + j * embed_size, &one)
*
*/
__pyx_t_24 = __pyx_v_embed_size;
__pyx_t_25 = __pyx_t_24;
for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
__pyx_v_j = __pyx_t_26;
/* "libreco/algorithms/_als.pyx":96
* # compute partial A = Yu^T @ Yu + lambda * I
* for j in range(embed_size):
* axpy(&embed_size, &Y[i, j], &Y[i, 0], &one, A + j * embed_size, &one) # <<<<<<<<<<<<<<
*
* # compute partial b = Yu^T @ Ru
*/
__pyx_t_35 = __pyx_v_i;
__pyx_t_36 = __pyx_v_j;
__pyx_t_37 = __pyx_v_i;
__pyx_t_38 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_35 * __pyx_v_Y.strides[0]) )) + __pyx_t_36)) )))), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_37 * __pyx_v_Y.strides[0]) )) + __pyx_t_38)) )))), (&__pyx_v_one), (__pyx_v_A + (__pyx_v_j * __pyx_v_embed_size)), (&__pyx_v_one));
}
/* "libreco/algorithms/_als.pyx":99
*
* # compute partial b = Yu^T @ Ru
* axpy(&embed_size, &rating, &Y[i, 0], &one, b, &one) # <<<<<<<<<<<<<<
*
* err = 0
*/
__pyx_t_39 = __pyx_v_i;
__pyx_t_40 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_rating), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_39 * __pyx_v_Y.strides[0]) )) + __pyx_t_40)) )))), (&__pyx_v_one), __pyx_v_b, (&__pyx_v_one));
}
__pyx_L22:;
}
/* "libreco/algorithms/_als.pyx":101
* axpy(&embed_size, &rating, &Y[i, 0], &one, b, &one)
*
* err = 0 # <<<<<<<<<<<<<<
* # solve Ax = b, x = A^-1 * b
* posv("U", &embed_size, &one, A, &embed_size, b, &embed_size, &err)
*/
__pyx_v_err = 0;
/* "libreco/algorithms/_als.pyx":103
* err = 0
* # solve Ax = b, x = A^-1 * b
* posv("U", &embed_size, &one, A, &embed_size, b, &embed_size, &err) # <<<<<<<<<<<<<<
* if not err:
* memcpy(&X[m, 0], b, sizeof(float) * embed_size)
*/
__pyx_f_7libreco_10algorithms_4_als_posv(((char *)"U"), (&__pyx_v_embed_size), (&__pyx_v_one), __pyx_v_A, (&__pyx_v_embed_size), __pyx_v_b, (&__pyx_v_embed_size), (&__pyx_v_err));
/* "libreco/algorithms/_als.pyx":104
* # solve Ax = b, x = A^-1 * b
* posv("U", &embed_size, &one, A, &embed_size, b, &embed_size, &err)
* if not err: # <<<<<<<<<<<<<<
* memcpy(&X[m, 0], b, sizeof(float) * embed_size)
* else:
*/
__pyx_t_1 = ((!(__pyx_v_err != 0)) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":105
* posv("U", &embed_size, &one, A, &embed_size, b, &embed_size, &err)
* if not err:
* memcpy(&X[m, 0], b, sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* else:
* with gil:
*/
__pyx_t_41 = __pyx_v_m;
__pyx_t_42 = 0;
(void)(memcpy((&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_X.data + __pyx_t_41 * __pyx_v_X.strides[0]) )) + __pyx_t_42)) )))), __pyx_v_b, ((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":104
* # solve Ax = b, x = A^-1 * b
* posv("U", &embed_size, &one, A, &embed_size, b, &embed_size, &err)
* if not err: # <<<<<<<<<<<<<<
* memcpy(&X[m, 0], b, sizeof(float) * embed_size)
* else:
*/
goto __pyx_L27;
}
/* "libreco/algorithms/_als.pyx":107
* memcpy(&X[m, 0], b, sizeof(float) * embed_size)
* else:
* with gil: # <<<<<<<<<<<<<<
* raise ValueError(f"cython_lapack.posv failed (err={err}) on row {m}. "
* "Try increasing the regularization parameter.")
*/
/*else*/ {
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
/*try:*/ {
/* "libreco/algorithms/_als.pyx":108
* else:
* with gil:
* raise ValueError(f"cython_lapack.posv failed (err={err}) on row {m}. " # <<<<<<<<<<<<<<
* "Try increasing the regularization parameter.")
*
*/
__pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L31_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_43 = 0;
__pyx_t_44 = 127;
__Pyx_INCREF(__pyx_kp_u_cython_lapack_posv_failed_err);
__pyx_t_43 += 31;
__Pyx_GIVEREF(__pyx_kp_u_cython_lapack_posv_failed_err);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_cython_lapack_posv_failed_err);
__pyx_t_7 = __Pyx_PyUnicode_From_int(__pyx_v_err, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L31_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_43 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
__pyx_t_7 = 0;
__Pyx_INCREF(__pyx_kp_u_on_row);
__pyx_t_43 += 9;
__Pyx_GIVEREF(__pyx_kp_u_on_row);
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_on_row);
__pyx_t_7 = __Pyx_PyUnicode_From_int(__pyx_v_m, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L31_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_43 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_7);
__pyx_t_7 = 0;
__Pyx_INCREF(__pyx_kp_u_Try_increasing_the_regularizati);
__pyx_t_43 += 46;
__Pyx_GIVEREF(__pyx_kp_u_Try_increasing_the_regularizati);
PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_kp_u_Try_increasing_the_regularizati);
__pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_2, 5, __pyx_t_43, __pyx_t_44); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L31_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L31_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__PYX_ERR(0, 108, __pyx_L31_error)
}
/* "libreco/algorithms/_als.pyx":107
* memcpy(&X[m, 0], b, sizeof(float) * embed_size)
* else:
* with gil: # <<<<<<<<<<<<<<
* raise ValueError(f"cython_lapack.posv failed (err={err}) on row {m}. "
* "Try increasing the regularization parameter.")
*/
/*finally:*/ {
__pyx_L31_error: {
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
goto __pyx_L18_error;
}
}
}
}
__pyx_L27:;
goto __pyx_L34;
__pyx_L18_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
#ifdef _OPENMP
#pragma omp flush(__pyx_parallel_exc_type)
#endif /* _OPENMP */
if (!__pyx_parallel_exc_type) {
__Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb);
__pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno;
__Pyx_GOTREF(__pyx_parallel_exc_type);
}
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_parallel_why = 4;
goto __pyx_L33;
__pyx_L33:;
#ifdef _OPENMP
#pragma omp critical(__pyx_parallel_lastprivates0)
#endif /* _OPENMP */
{
__pyx_parallel_temp0 = __pyx_v_confidence;
__pyx_parallel_temp1 = __pyx_v_err;
__pyx_parallel_temp2 = __pyx_v_i;
__pyx_parallel_temp3 = __pyx_v_index;
__pyx_parallel_temp4 = __pyx_v_j;
__pyx_parallel_temp5 = __pyx_v_m;
__pyx_parallel_temp6 = __pyx_v_rating;
__pyx_parallel_temp7 = __pyx_v_temp;
}
__pyx_L34:;
#ifdef _OPENMP
#pragma omp flush(__pyx_parallel_why)
#endif /* _OPENMP */
}
}
}
if (__pyx_parallel_exc_type) {
/* This may have been overridden by a continue, break or return in another thread. Prefer the error. */
__pyx_parallel_why = 4;
}
if (__pyx_parallel_why) {
__pyx_v_confidence = __pyx_parallel_temp0;
__pyx_v_err = __pyx_parallel_temp1;
__pyx_v_i = __pyx_parallel_temp2;
__pyx_v_index = __pyx_parallel_temp3;
__pyx_v_j = __pyx_parallel_temp4;
__pyx_v_m = __pyx_parallel_temp5;
__pyx_v_rating = __pyx_parallel_temp6;
__pyx_v_temp = __pyx_parallel_temp7;
switch (__pyx_parallel_why) {
case 4:
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_GIVEREF(__pyx_parallel_exc_type);
__Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb);
__pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno;
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
goto __pyx_L14_error;
}
}
}
}
/* "libreco/algorithms/_als.pyx":112
*
* finally:
* free(A) # <<<<<<<<<<<<<<
* free(b)
*
*/
/*finally:*/ {
/*normal exit:*/{
free(__pyx_v_A);
/* "libreco/algorithms/_als.pyx":113
* finally:
* free(A)
* free(b) # <<<<<<<<<<<<<<
*
*
*/
free(__pyx_v_b);
goto __pyx_L15;
}
__pyx_L14_error:;
/*exception exit:*/{
__Pyx_PyThreadState_declare
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save;
#endif
#ifdef WITH_THREAD
__pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_PyThreadState_assign
__pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_49 = 0; __pyx_t_50 = 0; __pyx_t_51 = 0;
__PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__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;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_49, &__pyx_t_50, &__pyx_t_51);
if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48) < 0)) __Pyx_ErrFetch(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
__Pyx_XGOTREF(__pyx_t_46);
__Pyx_XGOTREF(__pyx_t_47);
__Pyx_XGOTREF(__pyx_t_48);
__Pyx_XGOTREF(__pyx_t_49);
__Pyx_XGOTREF(__pyx_t_50);
__Pyx_XGOTREF(__pyx_t_51);
__pyx_t_13 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_45 = __pyx_filename;
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
{
/* "libreco/algorithms/_als.pyx":112
*
* finally:
* free(A) # <<<<<<<<<<<<<<
* free(b)
*
*/
free(__pyx_v_A);
/* "libreco/algorithms/_als.pyx":113
* finally:
* free(A)
* free(b) # <<<<<<<<<<<<<<
*
*
*/
free(__pyx_v_b);
}
#ifdef WITH_THREAD
__pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
if (PY_MAJOR_VERSION >= 3) {
__Pyx_XGIVEREF(__pyx_t_49);
__Pyx_XGIVEREF(__pyx_t_50);
__Pyx_XGIVEREF(__pyx_t_51);
__Pyx_ExceptionReset(__pyx_t_49, __pyx_t_50, __pyx_t_51);
}
__Pyx_XGIVEREF(__pyx_t_46);
__Pyx_XGIVEREF(__pyx_t_47);
__Pyx_XGIVEREF(__pyx_t_48);
__Pyx_ErrRestore(__pyx_t_46, __pyx_t_47, __pyx_t_48);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
__pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_49 = 0; __pyx_t_50 = 0; __pyx_t_51 = 0;
__pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_45;
goto __pyx_L9_error;
}
__pyx_L15:;
}
goto __pyx_L40;
__pyx_L9_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
#ifdef _OPENMP
#pragma omp flush(__pyx_parallel_exc_type)
#endif /* _OPENMP */
if (!__pyx_parallel_exc_type) {
__Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb);
__pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno;
__Pyx_GOTREF(__pyx_parallel_exc_type);
}
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_parallel_why = 4;
goto __pyx_L40;
__pyx_L40:;
#ifdef _OPENMP
Py_END_ALLOW_THREADS
#else
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
#endif /* _OPENMP */
/* Clean up any temporaries */
__Pyx_XDECREF(__pyx_t_2);
__pyx_t_2 = NULL;
__Pyx_XDECREF(__pyx_t_46);
__pyx_t_46 = NULL;
__Pyx_XDECREF(__pyx_t_47);
__pyx_t_47 = NULL;
__Pyx_XDECREF(__pyx_t_48);
__pyx_t_48 = NULL;
__Pyx_XDECREF(__pyx_t_49);
__pyx_t_49 = NULL;
__Pyx_XDECREF(__pyx_t_50);
__pyx_t_50 = NULL;
__Pyx_XDECREF(__pyx_t_51);
__pyx_t_51 = NULL;
__Pyx_XDECREF(__pyx_t_7);
__pyx_t_7 = NULL;
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
#ifndef _OPENMP
}
#endif /* _OPENMP */
}
if (__pyx_parallel_exc_type) {
/* This may have been overridden by a continue, break or return in another thread. Prefer the error. */
__pyx_parallel_why = 4;
}
if (__pyx_parallel_why) {
switch (__pyx_parallel_why) {
case 4:
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_GIVEREF(__pyx_parallel_exc_type);
__Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb);
__pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno;
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
goto __pyx_L5_error;
}
}
}
#if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
#undef likely
#undef unlikely
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
}
/* "libreco/algorithms/_als.pyx":71
* cdef float *b
*
* with nogil, parallel(num_threads=num_threads): # <<<<<<<<<<<<<<
* A = <float *> malloc(sizeof(float) * embed_size * embed_size)
* b = <float *> malloc(sizeof(float) * embed_size)
*/
/*finally:*/ {
/*normal exit:*/{
#ifdef WITH_THREAD
__Pyx_FastGIL_Forget();
Py_BLOCK_THREADS
#endif
goto __pyx_L6;
}
__pyx_L5_error: {
#ifdef WITH_THREAD
__Pyx_FastGIL_Forget();
Py_BLOCK_THREADS
#endif
goto __pyx_L1_error;
}
__pyx_L6:;
}
}
/* "libreco/algorithms/_als.pyx":55
* @cython.wraparound(False)
* @cython.cdivision(True)
* cdef void _least_squares(const int[:] indices, const int[:] indptr, # <<<<<<<<<<<<<<
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit):
*/
/* function exit code */
goto __pyx_L0;
__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_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_9);
__PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
__PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
__Pyx_WriteUnraisable("libreco.algorithms._als._least_squares", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_initialA, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_initialB, 1);
__Pyx_RefNannyFinishContext();
}
/* "libreco/algorithms/_als.pyx":119
* @cython.wraparound(False)
* @cython.cdivision(True)
* cdef void _least_squares_cg(const int[:] indices, const int[:] indptr, # <<<<<<<<<<<<<<
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit, int cg_steps):
*/
static void __pyx_f_7libreco_10algorithms_4_als__least_squares_cg(__Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_indptr, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_X, __Pyx_memviewslice __pyx_v_Y, double __pyx_v_reg, int __pyx_v_num_threads, int __pyx_v_implicit, int __pyx_v_cg_steps) {
CYTHON_UNUSED int __pyx_v_n_x;
int __pyx_v_embed_size;
int __pyx_v_m;
int __pyx_v_i;
CYTHON_UNUSED int __pyx_v_j;
int __pyx_v_index;
int __pyx_v_one;
float __pyx_v_rating;
float __pyx_v_confidence;
float __pyx_v_temp;
float __pyx_v_rsold;
float __pyx_v_rsnew;
float __pyx_v_ak;
float __pyx_v_zero;
__Pyx_memviewslice __pyx_v_initialA = { 0, 0, { 0 }, { 0 }, { 0 } };
CYTHON_UNUSED PyObject *__pyx_v_YtY = NULL;
float *__pyx_v_x;
float *__pyx_v_p;
float *__pyx_v_r;
float *__pyx_v_Ap;
__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;
PyObject *__pyx_t_7 = NULL;
int __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
__Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_t_11;
int __pyx_t_12;
Py_ssize_t __pyx_t_13;
Py_ssize_t __pyx_t_14;
Py_ssize_t __pyx_t_15;
Py_ssize_t __pyx_t_16;
Py_ssize_t __pyx_t_17;
int __pyx_t_18;
Py_ssize_t __pyx_t_19;
int __pyx_t_20;
int __pyx_t_21;
Py_ssize_t __pyx_t_22;
Py_ssize_t __pyx_t_23;
Py_ssize_t __pyx_t_24;
Py_ssize_t __pyx_t_25;
Py_ssize_t __pyx_t_26;
Py_ssize_t __pyx_t_27;
Py_ssize_t __pyx_t_28;
Py_ssize_t __pyx_t_29;
Py_ssize_t __pyx_t_30;
Py_ssize_t __pyx_t_31;
Py_ssize_t __pyx_t_32;
Py_ssize_t __pyx_t_33;
Py_ssize_t __pyx_t_34;
Py_ssize_t __pyx_t_35;
Py_ssize_t __pyx_t_36;
int __pyx_t_37;
Py_ssize_t __pyx_t_38;
int __pyx_t_39;
int __pyx_t_40;
Py_ssize_t __pyx_t_41;
Py_ssize_t __pyx_t_42;
Py_ssize_t __pyx_t_43;
Py_ssize_t __pyx_t_44;
Py_ssize_t __pyx_t_45;
Py_ssize_t __pyx_t_46;
Py_ssize_t __pyx_t_47;
Py_ssize_t __pyx_t_48;
Py_ssize_t __pyx_t_49;
Py_ssize_t __pyx_t_50;
Py_ssize_t __pyx_t_51;
__Pyx_RefNannySetupContext("_least_squares_cg", 0);
/* "libreco/algorithms/_als.pyx":122
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit, int cg_steps):
* cdef int n_x = X.shape[0], embed_size = X.shape[1] # <<<<<<<<<<<<<<
* cdef int m, i, j, index, err, one = 1
* cdef float rating, confidence, temp, rsold, rsnew, ak
*/
__pyx_v_n_x = (__pyx_v_X.shape[0]);
__pyx_v_embed_size = (__pyx_v_X.shape[1]);
/* "libreco/algorithms/_als.pyx":123
* int num_threads, int implicit, int cg_steps):
* cdef int n_x = X.shape[0], embed_size = X.shape[1]
* cdef int m, i, j, index, err, one = 1 # <<<<<<<<<<<<<<
* cdef float rating, confidence, temp, rsold, rsnew, ak
* cdef float zero = 0.0
*/
__pyx_v_one = 1;
/* "libreco/algorithms/_als.pyx":125
* cdef int m, i, j, index, err, one = 1
* cdef float rating, confidence, temp, rsold, rsnew, ak
* cdef float zero = 0.0 # <<<<<<<<<<<<<<
*
* cdef float[:, ::1] initialA
*/
__pyx_v_zero = 0.0;
/* "libreco/algorithms/_als.pyx":128
*
* cdef float[:, ::1] initialA
* if implicit > 0: # <<<<<<<<<<<<<<
* initialA = YtY = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
*/
__pyx_t_1 = ((__pyx_v_implicit > 0) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":129
* cdef float[:, ::1] initialA
* if implicit > 0:
* initialA = YtY = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single) # <<<<<<<<<<<<<<
* else:
* initialA = reg * np.eye(embed_size, dtype=np.single)
*/
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_transpose); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_Y, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_7 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
if (likely(__pyx_t_7)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
__Pyx_INCREF(__pyx_t_7);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_6, function);
}
}
__pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_Y, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_5 = NULL;
__pyx_t_8 = 0;
if (CYTHON_UNPACK_METHODS && 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);
__pyx_t_8 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_6};
__pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_6};
__pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
{
__pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
if (__pyx_t_5) {
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
}
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_6);
__pyx_t_3 = 0;
__pyx_t_6 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyFloat_FromDouble(__pyx_v_reg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_eye); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_embed_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_single); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyNumber_Multiply(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_t_9, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 129, __pyx_L1_error)
__PYX_INC_MEMVIEW(&__pyx_t_10, 0);
__pyx_v_initialA = __pyx_t_10;
__Pyx_INCREF(__pyx_t_9);
__pyx_v_YtY = __pyx_t_9;
__PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
__pyx_t_10.memview = NULL;
__pyx_t_10.data = NULL;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* "libreco/algorithms/_als.pyx":128
*
* cdef float[:, ::1] initialA
* if implicit > 0: # <<<<<<<<<<<<<<
* initialA = YtY = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
*/
goto __pyx_L3;
}
/* "libreco/algorithms/_als.pyx":131
* initialA = YtY = np.dot(np.transpose(Y), Y) + reg * np.eye(embed_size, dtype=np.single)
* else:
* initialA = reg * np.eye(embed_size, dtype=np.single) # <<<<<<<<<<<<<<
*
* cdef float *x
*/
/*else*/ {
__pyx_t_9 = PyFloat_FromDouble(__pyx_v_reg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_eye); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_embed_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_single); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyNumber_Multiply(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_v_initialA = __pyx_t_10;
__pyx_t_10.memview = NULL;
__pyx_t_10.data = NULL;
}
__pyx_L3:;
/* "libreco/algorithms/_als.pyx":138
* cdef float *Ap
*
* with nogil, parallel(num_threads=num_threads): # <<<<<<<<<<<<<<
* Ap = <float *> malloc(sizeof(float) * embed_size)
* p = <float *> malloc(sizeof(float) * embed_size)
*/
{
#ifdef WITH_THREAD
PyThreadState *_save;
Py_UNBLOCK_THREADS
__Pyx_FastGIL_Remember();
#endif
/*try:*/ {
{
#if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
#undef likely
#undef unlikely
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#ifdef _OPENMP
#pragma omp parallel private(__pyx_v_Ap, __pyx_v_p, __pyx_v_r) private(__pyx_t_1, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15, __pyx_t_16, __pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20, __pyx_t_21, __pyx_t_22, __pyx_t_23, __pyx_t_24, __pyx_t_25, __pyx_t_26, __pyx_t_27, __pyx_t_28, __pyx_t_29, __pyx_t_30, __pyx_t_31, __pyx_t_32, __pyx_t_33, __pyx_t_34, __pyx_t_35, __pyx_t_36, __pyx_t_37, __pyx_t_38, __pyx_t_39, __pyx_t_40, __pyx_t_41, __pyx_t_42, __pyx_t_43, __pyx_t_44, __pyx_t_45, __pyx_t_46, __pyx_t_47, __pyx_t_48, __pyx_t_49, __pyx_t_50, __pyx_t_51, __pyx_t_8) num_threads(__pyx_v_num_threads)
#endif /* _OPENMP */
{
/* Initialize private variables to invalid values */
__pyx_v_Ap = ((float *)1);
__pyx_v_p = ((float *)1);
__pyx_v_r = ((float *)1);
/* "libreco/algorithms/_als.pyx":139
*
* with nogil, parallel(num_threads=num_threads):
* Ap = <float *> malloc(sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* p = <float *> malloc(sizeof(float) * embed_size)
* r = <float *> malloc(sizeof(float) * embed_size)
*/
__pyx_v_Ap = ((float *)malloc(((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":140
* with nogil, parallel(num_threads=num_threads):
* Ap = <float *> malloc(sizeof(float) * embed_size)
* p = <float *> malloc(sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* r = <float *> malloc(sizeof(float) * embed_size)
* try:
*/
__pyx_v_p = ((float *)malloc(((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":141
* Ap = <float *> malloc(sizeof(float) * embed_size)
* p = <float *> malloc(sizeof(float) * embed_size)
* r = <float *> malloc(sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* try:
* for m in prange(n_x, schedule="guided"):
*/
__pyx_v_r = ((float *)malloc(((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":142
* p = <float *> malloc(sizeof(float) * embed_size)
* r = <float *> malloc(sizeof(float) * embed_size)
* try: # <<<<<<<<<<<<<<
* for m in prange(n_x, schedule="guided"):
* x = &X[m, 0]
*/
/*try:*/ {
/* "libreco/algorithms/_als.pyx":143
* r = <float *> malloc(sizeof(float) * embed_size)
* try:
* for m in prange(n_x, schedule="guided"): # <<<<<<<<<<<<<<
* x = &X[m, 0]
*
*/
__pyx_t_8 = __pyx_v_n_x;
if (1 == 0) abort();
{
__pyx_t_12 = (__pyx_t_8 - 0 + 1 - 1/abs(1)) / 1;
if (__pyx_t_12 > 0)
{
#ifdef _OPENMP
#pragma omp for lastprivate(__pyx_v_ak) lastprivate(__pyx_v_confidence) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) firstprivate(__pyx_v_m) lastprivate(__pyx_v_m) lastprivate(__pyx_v_rating) lastprivate(__pyx_v_rsnew) lastprivate(__pyx_v_rsold) lastprivate(__pyx_v_temp) lastprivate(__pyx_v_x) schedule(guided)
#endif /* _OPENMP */
for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){
{
__pyx_v_m = (int)(0 + 1 * __pyx_t_11);
/* Initialize private variables to invalid values */
__pyx_v_ak = ((float)__PYX_NAN());
__pyx_v_confidence = ((float)__PYX_NAN());
__pyx_v_i = ((int)0xbad0bad0);
__pyx_v_index = ((int)0xbad0bad0);
__pyx_v_j = ((int)0xbad0bad0);
__pyx_v_rating = ((float)__PYX_NAN());
__pyx_v_rsnew = ((float)__PYX_NAN());
__pyx_v_rsold = ((float)__PYX_NAN());
__pyx_v_temp = ((float)__PYX_NAN());
__pyx_v_x = ((float *)1);
/* "libreco/algorithms/_als.pyx":144
* try:
* for m in prange(n_x, schedule="guided"):
* x = &X[m, 0] # <<<<<<<<<<<<<<
*
* temp = -1.0
*/
__pyx_t_13 = __pyx_v_m;
__pyx_t_14 = 0;
__pyx_v_x = (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_X.data + __pyx_t_13 * __pyx_v_X.strides[0]) )) + __pyx_t_14)) ))));
/* "libreco/algorithms/_als.pyx":146
* x = &X[m, 0]
*
* temp = -1.0 # <<<<<<<<<<<<<<
* # compute residual r = b - Ax
* # first step: r = -(YtY + lambdaI)^T @ x or -(lambdaI @ x)
*/
__pyx_v_temp = -1.0;
/* "libreco/algorithms/_als.pyx":149
* # compute residual r = b - Ax
* # first step: r = -(YtY + lambdaI)^T @ x or -(lambdaI @ x)
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, x, &one, &zero, r, &one) # <<<<<<<<<<<<<<
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0:
*/
__pyx_t_15 = 0;
__pyx_t_16 = 0;
__pyx_f_7libreco_10algorithms_4_als_symv(((char *)"U"), (&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_initialA.data + __pyx_t_15 * __pyx_v_initialA.strides[0]) )) + __pyx_t_16)) )))), (&__pyx_v_embed_size), __pyx_v_x, (&__pyx_v_one), (&__pyx_v_zero), __pyx_v_r, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":150
* # first step: r = -(YtY + lambdaI)^T @ x or -(lambdaI @ x)
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, x, &one, &zero, r, &one)
* for index in range(indptr[m], indptr[m+1]): # <<<<<<<<<<<<<<
* if implicit > 0:
* i = indices[index]
*/
__pyx_t_17 = (__pyx_v_m + 1);
__pyx_t_18 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_17 * __pyx_v_indptr.strides[0]) )));
__pyx_t_19 = __pyx_v_m;
__pyx_t_20 = __pyx_t_18;
for (__pyx_t_21 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_19 * __pyx_v_indptr.strides[0]) ))); __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
__pyx_v_index = __pyx_t_21;
/* "libreco/algorithms/_als.pyx":151
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, x, &one, &zero, r, &one)
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
__pyx_t_1 = ((__pyx_v_implicit > 0) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":152
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0:
* i = indices[index] # <<<<<<<<<<<<<<
* confidence = data[index]
* # second step: r += (c - (c-1)y @ x) * y
*/
__pyx_t_22 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_22 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":153
* if implicit > 0:
* i = indices[index]
* confidence = data[index] # <<<<<<<<<<<<<<
* # second step: r += (c - (c-1)y @ x) * y
* temp = confidence - (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, x, &one)
*/
__pyx_t_23 = __pyx_v_index;
__pyx_v_confidence = (*((float const *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_23 * __pyx_v_data.strides[0]) )));
/* "libreco/algorithms/_als.pyx":155
* confidence = data[index]
* # second step: r += (c - (c-1)y @ x) * y
* temp = confidence - (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, x, &one) # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one)
* else:
*/
__pyx_t_24 = __pyx_v_i;
__pyx_t_25 = 0;
__pyx_v_temp = (__pyx_v_confidence - ((__pyx_v_confidence - 1.0) * __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_24 * __pyx_v_Y.strides[0]) )) + __pyx_t_25)) )))), (&__pyx_v_one), __pyx_v_x, (&__pyx_v_one))));
/* "libreco/algorithms/_als.pyx":156
* # second step: r += (c - (c-1)y @ x) * y
* temp = confidence - (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, x, &one)
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one) # <<<<<<<<<<<<<<
* else:
* i = indices[index]
*/
__pyx_t_26 = __pyx_v_i;
__pyx_t_27 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_26 * __pyx_v_Y.strides[0]) )) + __pyx_t_27)) )))), (&__pyx_v_one), __pyx_v_r, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":151
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, x, &one, &zero, r, &one)
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
goto __pyx_L22;
}
/* "libreco/algorithms/_als.pyx":158
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one)
* else:
* i = indices[index] # <<<<<<<<<<<<<<
* rating = data[index]
* # second step: r += (rating - y @ x) * y
*/
/*else*/ {
__pyx_t_28 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_28 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":159
* else:
* i = indices[index]
* rating = data[index] # <<<<<<<<<<<<<<
* # second step: r += (rating - y @ x) * y
* temp = rating - dot(&embed_size, &Y[i, 0], &one, x, &one)
*/
__pyx_t_29 = __pyx_v_index;
__pyx_v_rating = (*((float const *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_29 * __pyx_v_data.strides[0]) )));
/* "libreco/algorithms/_als.pyx":161
* rating = data[index]
* # second step: r += (rating - y @ x) * y
* temp = rating - dot(&embed_size, &Y[i, 0], &one, x, &one) # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one)
*
*/
__pyx_t_30 = __pyx_v_i;
__pyx_t_31 = 0;
__pyx_v_temp = (__pyx_v_rating - __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_30 * __pyx_v_Y.strides[0]) )) + __pyx_t_31)) )))), (&__pyx_v_one), __pyx_v_x, (&__pyx_v_one)));
/* "libreco/algorithms/_als.pyx":162
* # second step: r += (rating - y @ x) * y
* temp = rating - dot(&embed_size, &Y[i, 0], &one, x, &one)
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one) # <<<<<<<<<<<<<<
*
* memcpy(p, r, sizeof(float) * embed_size)
*/
__pyx_t_32 = __pyx_v_i;
__pyx_t_33 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_32 * __pyx_v_Y.strides[0]) )) + __pyx_t_33)) )))), (&__pyx_v_one), __pyx_v_r, (&__pyx_v_one));
}
__pyx_L22:;
}
/* "libreco/algorithms/_als.pyx":164
* axpy(&embed_size, &temp, &Y[i, 0], &one, r, &one)
*
* memcpy(p, r, sizeof(float) * embed_size) # <<<<<<<<<<<<<<
* rsold = dot(&embed_size, r, &one, r, &one)
* if rsold < 1e-10:
*/
(void)(memcpy(__pyx_v_p, __pyx_v_r, ((sizeof(float)) * __pyx_v_embed_size)));
/* "libreco/algorithms/_als.pyx":165
*
* memcpy(p, r, sizeof(float) * embed_size)
* rsold = dot(&embed_size, r, &one, r, &one) # <<<<<<<<<<<<<<
* if rsold < 1e-10:
* continue
*/
__pyx_v_rsold = __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), __pyx_v_r, (&__pyx_v_one), __pyx_v_r, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":166
* memcpy(p, r, sizeof(float) * embed_size)
* rsold = dot(&embed_size, r, &one, r, &one)
* if rsold < 1e-10: # <<<<<<<<<<<<<<
* continue
*
*/
__pyx_t_1 = ((__pyx_v_rsold < 1e-10) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":167
* rsold = dot(&embed_size, r, &one, r, &one)
* if rsold < 1e-10:
* continue # <<<<<<<<<<<<<<
*
* for j in range(cg_steps):
*/
goto __pyx_L16_continue;
/* "libreco/algorithms/_als.pyx":166
* memcpy(p, r, sizeof(float) * embed_size)
* rsold = dot(&embed_size, r, &one, r, &one)
* if rsold < 1e-10: # <<<<<<<<<<<<<<
* continue
*
*/
}
/* "libreco/algorithms/_als.pyx":169
* continue
*
* for j in range(cg_steps): # <<<<<<<<<<<<<<
* temp = 1.0
* # compute Ap
*/
__pyx_t_18 = __pyx_v_cg_steps;
__pyx_t_20 = __pyx_t_18;
for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
__pyx_v_j = __pyx_t_21;
/* "libreco/algorithms/_als.pyx":170
*
* for j in range(cg_steps):
* temp = 1.0 # <<<<<<<<<<<<<<
* # compute Ap
* # first step: Ap = -(YtY + lambdaI)^T @ p or -(lambdaI @ p)
*/
__pyx_v_temp = 1.0;
/* "libreco/algorithms/_als.pyx":173
* # compute Ap
* # first step: Ap = -(YtY + lambdaI)^T @ p or -(lambdaI @ p)
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, p, &one, &zero, Ap, &one) # <<<<<<<<<<<<<<
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0:
*/
__pyx_t_34 = 0;
__pyx_t_35 = 0;
__pyx_f_7libreco_10algorithms_4_als_symv(((char *)"U"), (&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_initialA.data + __pyx_t_34 * __pyx_v_initialA.strides[0]) )) + __pyx_t_35)) )))), (&__pyx_v_embed_size), __pyx_v_p, (&__pyx_v_one), (&__pyx_v_zero), __pyx_v_Ap, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":174
* # first step: Ap = -(YtY + lambdaI)^T @ p or -(lambdaI @ p)
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, p, &one, &zero, Ap, &one)
* for index in range(indptr[m], indptr[m+1]): # <<<<<<<<<<<<<<
* if implicit > 0:
* i = indices[index]
*/
__pyx_t_36 = (__pyx_v_m + 1);
__pyx_t_37 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_36 * __pyx_v_indptr.strides[0]) )));
__pyx_t_38 = __pyx_v_m;
__pyx_t_39 = __pyx_t_37;
for (__pyx_t_40 = (*((int const *) ( /* dim=0 */ (__pyx_v_indptr.data + __pyx_t_38 * __pyx_v_indptr.strides[0]) ))); __pyx_t_40 < __pyx_t_39; __pyx_t_40+=1) {
__pyx_v_index = __pyx_t_40;
/* "libreco/algorithms/_als.pyx":175
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, p, &one, &zero, Ap, &one)
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
__pyx_t_1 = ((__pyx_v_implicit > 0) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":176
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0:
* i = indices[index] # <<<<<<<<<<<<<<
* confidence = data[index]
* # second step: Ap += (c-1) * (y @ x) * y
*/
__pyx_t_41 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_41 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":177
* if implicit > 0:
* i = indices[index]
* confidence = data[index] # <<<<<<<<<<<<<<
* # second step: Ap += (c-1) * (y @ x) * y
* temp = (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, p, &one)
*/
__pyx_t_42 = __pyx_v_index;
__pyx_v_confidence = (*((float const *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_42 * __pyx_v_data.strides[0]) )));
/* "libreco/algorithms/_als.pyx":179
* confidence = data[index]
* # second step: Ap += (c-1) * (y @ x) * y
* temp = (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, p, &one) # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, &Y[i, 0], &one, Ap, &one)
* else:
*/
__pyx_t_43 = __pyx_v_i;
__pyx_t_44 = 0;
__pyx_v_temp = ((__pyx_v_confidence - 1.0) * __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_43 * __pyx_v_Y.strides[0]) )) + __pyx_t_44)) )))), (&__pyx_v_one), __pyx_v_p, (&__pyx_v_one)));
/* "libreco/algorithms/_als.pyx":180
* # second step: Ap += (c-1) * (y @ x) * y
* temp = (confidence - 1) * dot(&embed_size, &Y[i, 0], &one, p, &one)
* axpy(&embed_size, &temp, &Y[i, 0], &one, Ap, &one) # <<<<<<<<<<<<<<
* else:
* i = indices[index]
*/
__pyx_t_45 = __pyx_v_i;
__pyx_t_46 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_45 * __pyx_v_Y.strides[0]) )) + __pyx_t_46)) )))), (&__pyx_v_one), __pyx_v_Ap, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":175
* symv("U", &embed_size, &temp, &initialA[0, 0], &embed_size, p, &one, &zero, Ap, &one)
* for index in range(indptr[m], indptr[m+1]):
* if implicit > 0: # <<<<<<<<<<<<<<
* i = indices[index]
* confidence = data[index]
*/
goto __pyx_L28;
}
/* "libreco/algorithms/_als.pyx":182
* axpy(&embed_size, &temp, &Y[i, 0], &one, Ap, &one)
* else:
* i = indices[index] # <<<<<<<<<<<<<<
* # second step: Ap += (y @ x) * y
* temp = dot(&embed_size, &Y[i, 0], &one, p, &one)
*/
/*else*/ {
__pyx_t_47 = __pyx_v_index;
__pyx_v_i = (*((int const *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_47 * __pyx_v_indices.strides[0]) )));
/* "libreco/algorithms/_als.pyx":184
* i = indices[index]
* # second step: Ap += (y @ x) * y
* temp = dot(&embed_size, &Y[i, 0], &one, p, &one) # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, &Y[i, 0], &one, Ap, &one)
*
*/
__pyx_t_48 = __pyx_v_i;
__pyx_t_49 = 0;
__pyx_v_temp = __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_48 * __pyx_v_Y.strides[0]) )) + __pyx_t_49)) )))), (&__pyx_v_one), __pyx_v_p, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":185
* # second step: Ap += (y @ x) * y
* temp = dot(&embed_size, &Y[i, 0], &one, p, &one)
* axpy(&embed_size, &temp, &Y[i, 0], &one, Ap, &one) # <<<<<<<<<<<<<<
*
* # ak = rsold / p.dot(Ap)
*/
__pyx_t_50 = __pyx_v_i;
__pyx_t_51 = 0;
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_Y.data + __pyx_t_50 * __pyx_v_Y.strides[0]) )) + __pyx_t_51)) )))), (&__pyx_v_one), __pyx_v_Ap, (&__pyx_v_one));
}
__pyx_L28:;
}
/* "libreco/algorithms/_als.pyx":188
*
* # ak = rsold / p.dot(Ap)
* ak = rsold / dot(&embed_size, p, &one, Ap, &one) # <<<<<<<<<<<<<<
* # x += ak * p
* axpy(&embed_size, &ak, p, &one, x, &one)
*/
__pyx_v_ak = (__pyx_v_rsold / __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), __pyx_v_p, (&__pyx_v_one), __pyx_v_Ap, (&__pyx_v_one)));
/* "libreco/algorithms/_als.pyx":190
* ak = rsold / dot(&embed_size, p, &one, Ap, &one)
* # x += ak * p
* axpy(&embed_size, &ak, p, &one, x, &one) # <<<<<<<<<<<<<<
* # r -= alpha * Ap
* temp = ak * -1
*/
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_ak), __pyx_v_p, (&__pyx_v_one), __pyx_v_x, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":192
* axpy(&embed_size, &ak, p, &one, x, &one)
* # r -= alpha * Ap
* temp = ak * -1 # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, Ap, &one, r, &one)
*
*/
__pyx_v_temp = (__pyx_v_ak * -1.0);
/* "libreco/algorithms/_als.pyx":193
* # r -= alpha * Ap
* temp = ak * -1
* axpy(&embed_size, &temp, Ap, &one, r, &one) # <<<<<<<<<<<<<<
*
* rsnew = dot(&embed_size, r, &one, r, &one)
*/
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), __pyx_v_Ap, (&__pyx_v_one), __pyx_v_r, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":195
* axpy(&embed_size, &temp, Ap, &one, r, &one)
*
* rsnew = dot(&embed_size, r, &one, r, &one) # <<<<<<<<<<<<<<
* if rsnew < 1e-10:
* break
*/
__pyx_v_rsnew = __pyx_f_7libreco_10algorithms_4_als_dot((&__pyx_v_embed_size), __pyx_v_r, (&__pyx_v_one), __pyx_v_r, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":196
*
* rsnew = dot(&embed_size, r, &one, r, &one)
* if rsnew < 1e-10: # <<<<<<<<<<<<<<
* break
*
*/
__pyx_t_1 = ((__pyx_v_rsnew < 1e-10) != 0);
if (__pyx_t_1) {
/* "libreco/algorithms/_als.pyx":197
* rsnew = dot(&embed_size, r, &one, r, &one)
* if rsnew < 1e-10:
* break # <<<<<<<<<<<<<<
*
* # p = r + (rsnew/rsold) * p
*/
goto __pyx_L25_break;
/* "libreco/algorithms/_als.pyx":196
*
* rsnew = dot(&embed_size, r, &one, r, &one)
* if rsnew < 1e-10: # <<<<<<<<<<<<<<
* break
*
*/
}
/* "libreco/algorithms/_als.pyx":200
*
* # p = r + (rsnew/rsold) * p
* temp = rsnew / rsold # <<<<<<<<<<<<<<
* scal(&embed_size, &temp, p, &one)
* temp = 1.0
*/
__pyx_v_temp = (__pyx_v_rsnew / __pyx_v_rsold);
/* "libreco/algorithms/_als.pyx":201
* # p = r + (rsnew/rsold) * p
* temp = rsnew / rsold
* scal(&embed_size, &temp, p, &one) # <<<<<<<<<<<<<<
* temp = 1.0
* axpy(&embed_size, &temp, r, &one, p, &one)
*/
__pyx_f_7libreco_10algorithms_4_als_scal((&__pyx_v_embed_size), (&__pyx_v_temp), __pyx_v_p, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":202
* temp = rsnew / rsold
* scal(&embed_size, &temp, p, &one)
* temp = 1.0 # <<<<<<<<<<<<<<
* axpy(&embed_size, &temp, r, &one, p, &one)
* rsold = rsnew
*/
__pyx_v_temp = 1.0;
/* "libreco/algorithms/_als.pyx":203
* scal(&embed_size, &temp, p, &one)
* temp = 1.0
* axpy(&embed_size, &temp, r, &one, p, &one) # <<<<<<<<<<<<<<
* rsold = rsnew
*
*/
__pyx_f_7libreco_10algorithms_4_als_axpy((&__pyx_v_embed_size), (&__pyx_v_temp), __pyx_v_r, (&__pyx_v_one), __pyx_v_p, (&__pyx_v_one));
/* "libreco/algorithms/_als.pyx":204
* temp = 1.0
* axpy(&embed_size, &temp, r, &one, p, &one)
* rsold = rsnew # <<<<<<<<<<<<<<
*
* finally:
*/
__pyx_v_rsold = __pyx_v_rsnew;
}
__pyx_L25_break:;
goto __pyx_L31;
__pyx_L16_continue:;
goto __pyx_L31;
__pyx_L31:;
}
}
}
}
}
/* "libreco/algorithms/_als.pyx":207
*
* finally:
* free(Ap) # <<<<<<<<<<<<<<
* free(p)
* free(r)
*/
/*finally:*/ {
/*normal exit:*/{
free(__pyx_v_Ap);
/* "libreco/algorithms/_als.pyx":208
* finally:
* free(Ap)
* free(p) # <<<<<<<<<<<<<<
* free(r)
*
*/
free(__pyx_v_p);
/* "libreco/algorithms/_als.pyx":209
* free(Ap)
* free(p)
* free(r) # <<<<<<<<<<<<<<
*
*/
free(__pyx_v_r);
goto __pyx_L15;
}
__pyx_L15:;
}
}
}
#if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
#undef likely
#undef unlikely
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
}
/* "libreco/algorithms/_als.pyx":138
* cdef float *Ap
*
* with nogil, parallel(num_threads=num_threads): # <<<<<<<<<<<<<<
* Ap = <float *> malloc(sizeof(float) * embed_size)
* p = <float *> malloc(sizeof(float) * embed_size)
*/
/*finally:*/ {
/*normal exit:*/{
#ifdef WITH_THREAD
__Pyx_FastGIL_Forget();
Py_BLOCK_THREADS
#endif
goto __pyx_L6;
}
__pyx_L6:;
}
}
/* "libreco/algorithms/_als.pyx":119
* @cython.wraparound(False)
* @cython.cdivision(True)
* cdef void _least_squares_cg(const int[:] indices, const int[:] indptr, # <<<<<<<<<<<<<<
* const float[:] data, float[:, ::1] X, float[:, ::1] Y, double reg,
* int num_threads, int implicit, int cg_steps):
*/
/* function exit code */
goto __pyx_L0;
__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_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_9);
__PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
__Pyx_WriteUnraisable("libreco.algorithms._als._least_squares_cg", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_initialA, 1);
__Pyx_XDECREF(__pyx_v_YtY);
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":122
* 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_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);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(1, 122, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(1, 122, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
if (value) { values[3] = value; kw_args--; }
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__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_ERR(1, 122, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
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_ERR(1, 122, __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_ERR(1, 123, __pyx_L3_error)
} else {
/* "View.MemoryView":123
*
* 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_ERR(1, 122, __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_ERR(1, 122, __pyx_L1_error)
if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(1, 122, __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":122
* 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;
PyObject *__pyx_t_6 = NULL;
char *__pyx_t_7;
int __pyx_t_8;
Py_ssize_t __pyx_t_9;
PyObject *__pyx_t_10 = NULL;
Py_ssize_t __pyx_t_11;
__Pyx_RefNannySetupContext("__cinit__", 0);
__Pyx_INCREF(__pyx_v_format);
/* "View.MemoryView":129
* 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_ERR(1, 129, __pyx_L1_error)
}
__pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 129, __pyx_L1_error)
__pyx_v_self->ndim = ((int)__pyx_t_1);
/* "View.MemoryView":130
*
* self.ndim = <int> len(shape)
* self.itemsize = itemsize # <<<<<<<<<<<<<<
*
* if not self.ndim:
*/
__pyx_v_self->itemsize = __pyx_v_itemsize;
/* "View.MemoryView":132
* 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 (unlikely(__pyx_t_2)) {
/* "View.MemoryView":133
*
* 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_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __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_ERR(1, 133, __pyx_L1_error)
/* "View.MemoryView":132
* self.itemsize = itemsize
*
* if not self.ndim: # <<<<<<<<<<<<<<
* raise ValueError("Empty shape tuple for cython.array")
*
*/
}
/* "View.MemoryView":135
* 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 (unlikely(__pyx_t_2)) {
/* "View.MemoryView":136
*
* 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__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __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_ERR(1, 136, __pyx_L1_error)
/* "View.MemoryView":135
* raise ValueError("Empty shape tuple for cython.array")
*
* if itemsize <= 0: # <<<<<<<<<<<<<<
* raise ValueError("itemsize <= 0 for cython.array")
*
*/
}
/* "View.MemoryView":138
* 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":139
*
* 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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 139, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_6)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
}
}
__pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 139, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":138
* 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":140
* 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_ERR(1, 140, __pyx_L1_error)
__pyx_t_3 = __pyx_v_format;
__Pyx_INCREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__Pyx_GOTREF(__pyx_v_self->_format);
__Pyx_DECREF(__pyx_v_self->_format);
__pyx_v_self->_format = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":141
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
* self.format = self._format # <<<<<<<<<<<<<<
*
*
*/
if (unlikely(__pyx_v_self->_format == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
__PYX_ERR(1, 141, __pyx_L1_error)
}
__pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(1, 141, __pyx_L1_error)
__pyx_v_self->format = __pyx_t_7;
/* "View.MemoryView":144
*
*
* self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<<
* self._strides = self._shape + self.ndim
*
*/
__pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
/* "View.MemoryView":145
*
* self._shape = <Py_ssize_t *> PyObject_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":147
* 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 (unlikely(__pyx_t_4)) {
/* "View.MemoryView":148
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __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_ERR(1, 148, __pyx_L1_error)
/* "View.MemoryView":147
* self._strides = self._shape + self.ndim
*
* if not self._shape: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate shape and strides.")
*
*/
}
/* "View.MemoryView":151
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
__pyx_t_8 = 0;
__pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
for (;;) {
if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 151, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 151, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 151, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_dim = __pyx_t_9;
__pyx_v_idx = __pyx_t_8;
__pyx_t_8 = (__pyx_t_8 + 1);
/* "View.MemoryView":152
*
* 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 (unlikely(__pyx_t_4)) {
/* "View.MemoryView":153
* 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_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
__pyx_t_5 = 0;
__pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 153, __pyx_L1_error)
/* "View.MemoryView":152
*
* 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":154
* 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":151
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":157
*
* 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_ERR(1, 157, __pyx_L1_error)
if (__pyx_t_4) {
/* "View.MemoryView":158
* cdef char order
* if mode == 'fortran':
* order = b'F' # <<<<<<<<<<<<<<
* self.mode = u'fortran'
* elif mode == 'c':
*/
__pyx_v_order = 'F';
/* "View.MemoryView":159
* 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":157
*
* cdef char order
* if mode == 'fortran': # <<<<<<<<<<<<<<
* order = b'F'
* self.mode = u'fortran'
*/
goto __pyx_L10;
}
/* "View.MemoryView":160
* 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_ERR(1, 160, __pyx_L1_error)
if (likely(__pyx_t_4)) {
/* "View.MemoryView":161
* self.mode = u'fortran'
* elif mode == 'c':
* order = b'C' # <<<<<<<<<<<<<<
* self.mode = u'c'
* else:
*/
__pyx_v_order = 'C';
/* "View.MemoryView":162
* 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":160
* order = b'F'
* self.mode = u'fortran'
* elif mode == 'c': # <<<<<<<<<<<<<<
* order = b'C'
* self.mode = u'c'
*/
goto __pyx_L10;
}
/* "View.MemoryView":164
* 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_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 164, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 164, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 164, __pyx_L1_error)
}
__pyx_L10:;
/* "View.MemoryView":166
* 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":169
* 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":170
*
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<<
* if allocate_buffer:
*
*/
__pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 170, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 170, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__pyx_v_self->dtype_is_object = __pyx_t_4;
/* "View.MemoryView":171
* 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":174
*
*
* 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":175
*
* 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 (unlikely(__pyx_t_4)) {
/* "View.MemoryView":176
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 176, __pyx_L1_error)
/* "View.MemoryView":175
*
* self.data = <char *>malloc(self.len)
* if not self.data: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate array data.")
*
*/
}
/* "View.MemoryView":178
* 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":179
*
* 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":180
* 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_ERR(1, 180, __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_ERR(1, 180, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
__pyx_t_9 = __pyx_t_1;
for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
__pyx_v_i = __pyx_t_11;
/* "View.MemoryView":181
* 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":182
* for i in range(self.len / itemsize):
* p[i] = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
Py_INCREF(Py_None);
}
/* "View.MemoryView":178
* 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":171
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O'
* if allocate_buffer: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":122
* 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_6);
__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":185
*
* @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;
if (__pyx_v_info == NULL) {
PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
return -1;
}
__Pyx_RefNannySetupContext("__getbuffer__", 0);
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
/* "View.MemoryView":186
* @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":187
* 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_ERR(1, 187, __pyx_L1_error)
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":188
* 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":187
* 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":189
* 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_ERR(1, 189, __pyx_L1_error)
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":190
* 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":189
* 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":191
* 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 (unlikely(__pyx_t_1)) {
/* "View.MemoryView":192
* 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__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __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_ERR(1, 192, __pyx_L1_error)
/* "View.MemoryView":191
* 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":193
* 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":194
* 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":195
* 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":196
* 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":197
* 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":198
* 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":199
* 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":200
* info.suboffsets = NULL
* info.itemsize = self.itemsize
* info.readonly = 0 # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
__pyx_v_info->readonly = 0;
/* "View.MemoryView":202
* 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":203
*
* 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":202
* info.readonly = 0
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.format
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":205
* info.format = self.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.obj = self
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L5:;
/* "View.MemoryView":207
* 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":185
*
* @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->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":211
* __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":212
*
* 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":213
* 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":212
*
* 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":214
* 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":215
* 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":216
* 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":215
* 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":218
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
* free(self.data) # <<<<<<<<<<<<<<
* PyObject_Free(self._shape)
*
*/
free(__pyx_v_self->data);
/* "View.MemoryView":214
* 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":219
* self._strides, self.ndim, False)
* free(self.data)
* PyObject_Free(self._shape) # <<<<<<<<<<<<<<
*
* @property
*/
PyObject_Free(__pyx_v_self->_shape);
/* "View.MemoryView":211
* __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":222
*
* @property
* def memview(self): # <<<<<<<<<<<<<<
* return self.get_memview()
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(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) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":223
* @property
* def memview(self):
* return self.get_memview() # <<<<<<<<<<<<<<
*
* @cname('get_memview')
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":222
*
* @property
* def memview(self): # <<<<<<<<<<<<<<
* return self.get_memview()
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__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":226
*
* @cname('get_memview')
* cdef get_memview(self): # <<<<<<<<<<<<<<
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object)
*/
static PyObject *__pyx_array_get_memview(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;
__Pyx_RefNannySetupContext("get_memview", 0);
/* "View.MemoryView":227
* @cname('get_memview')
* cdef get_memview(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":228
* cdef get_memview(self):
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __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_ERR(1, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __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_ERR(1, 228, __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":226
*
* @cname('get_memview')
* cdef get_memview(self): # <<<<<<<<<<<<<<
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object)
*/
/* 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.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":230
* return memoryview(self, flags, self.dtype_is_object)
*
* def __len__(self): # <<<<<<<<<<<<<<
* return self._shape[0]
*
*/
/* Python wrapper */
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
/* "View.MemoryView":231
*
* def __len__(self):
* return self._shape[0] # <<<<<<<<<<<<<<
*
* def __getattr__(self, attr):
*/
__pyx_r = (__pyx_v_self->_shape[0]);
goto __pyx_L0;
/* "View.MemoryView":230
* return memoryview(self, flags, self.dtype_is_object)
*
* def __len__(self): # <<<<<<<<<<<<<<
* return self._shape[0]
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":233
* return self._shape[0]
*
* 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_8__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_8__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;
__Pyx_RefNannySetupContext("__getattr__", 0);
/* "View.MemoryView":234
*
* 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_ERR(1, 234, __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_ERR(1, 234, __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":233
* return self._shape[0]
*
* 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":236
* 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_10__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_10__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;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":237
*
* 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_ERR(1, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 237, __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":236
* 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":239
* 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_12__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_12__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;
__Pyx_RefNannySetupContext("__setitem__", 0);
/* "View.MemoryView":240
*
* 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_ERR(1, 240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(1, 240, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":239
* 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;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":244
*
* @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;
__Pyx_RefNannySetupContext("array_cwrapper", 0);
/* "View.MemoryView":248
* 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":249
*
* 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_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __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_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 249, __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_ERR(1, 249, __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":248
* cdef array result
*
* if buf == NULL: # <<<<<<<<<<<<<<
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":251
* 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_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __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_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __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":252
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'),
* allocate_buffer=False) # <<<<<<<<<<<<<<
* result.data = buf
*
*/
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
/* "View.MemoryView":251
* 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_ERR(1, 251, __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":253
* 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":255
* 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":244
*
* @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":281
* 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_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);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__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_ERR(1, 281, __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_ERR(1, 281, __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":282
* 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":281
* 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":283
* 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":284
* 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":283
* 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;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* cdef tuple state
* cdef object _dict
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
PyObject *__pyx_v_state = 0;
PyObject *__pyx_v__dict = 0;
int __pyx_v_use_setstate;
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;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":5
* cdef object _dict
* cdef bint use_setstate
* state = (self.name,) # <<<<<<<<<<<<<<
* _dict = getattr(self, '__dict__', None)
* if _dict is not None:
*/
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_self->name);
__Pyx_GIVEREF(__pyx_v_self->name);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
__pyx_v_state = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "(tree fragment)":6
* cdef bint use_setstate
* state = (self.name,)
* _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
* if _dict is not None:
* state += (_dict,)
*/
__pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v__dict = __pyx_t_1;
__pyx_t_1 = 0;
/* "(tree fragment)":7
* state = (self.name,)
* _dict = getattr(self, '__dict__', None)
* if _dict is not None: # <<<<<<<<<<<<<<
* state += (_dict,)
* use_setstate = True
*/
__pyx_t_2 = (__pyx_v__dict != Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
/* "(tree fragment)":8
* _dict = getattr(self, '__dict__', None)
* if _dict is not None:
* state += (_dict,) # <<<<<<<<<<<<<<
* use_setstate = True
* else:
*/
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v__dict);
__Pyx_GIVEREF(__pyx_v__dict);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
__pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
__pyx_t_4 = 0;
/* "(tree fragment)":9
* if _dict is not None:
* state += (_dict,)
* use_setstate = True # <<<<<<<<<<<<<<
* else:
* use_setstate = self.name is not None
*/
__pyx_v_use_setstate = 1;
/* "(tree fragment)":7
* state = (self.name,)
* _dict = getattr(self, '__dict__', None)
* if _dict is not None: # <<<<<<<<<<<<<<
* state += (_dict,)
* use_setstate = True
*/
goto __pyx_L3;
}
/* "(tree fragment)":11
* use_setstate = True
* else:
* use_setstate = self.name is not None # <<<<<<<<<<<<<<
* if use_setstate:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
*/
/*else*/ {
__pyx_t_3 = (__pyx_v_self->name != Py_None);
__pyx_v_use_setstate = __pyx_t_3;
}
__pyx_L3:;
/* "(tree fragment)":12
* else:
* use_setstate = self.name is not None
* if use_setstate: # <<<<<<<<<<<<<<
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
*/
__pyx_t_3 = (__pyx_v_use_setstate != 0);
if (__pyx_t_3) {
/* "(tree fragment)":13
* use_setstate = self.name is not None
* if use_setstate:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<<
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_INCREF(__pyx_int_184977713);
__Pyx_GIVEREF(__pyx_int_184977713);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
__Pyx_INCREF(__pyx_v_state);
__Pyx_GIVEREF(__pyx_v_state);
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
__pyx_t_4 = 0;
__pyx_t_1 = 0;
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "(tree fragment)":12
* else:
* use_setstate = self.name is not None
* if use_setstate: # <<<<<<<<<<<<<<
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
*/
}
/* "(tree fragment)":15
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_INCREF(__pyx_int_184977713);
__Pyx_GIVEREF(__pyx_int_184977713);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
__Pyx_INCREF(__pyx_v_state);
__Pyx_GIVEREF(__pyx_v_state);
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
__pyx_t_5 = 0;
__pyx_t_1 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* cdef tuple state
* cdef object _dict
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_state);
__Pyx_XDECREF(__pyx_v__dict);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":16
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":17
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state):
* __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
*/
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
__pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "(tree fragment)":16
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/* 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.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":298
*
* @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":300
* 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":304
*
* with cython.cdivision(True):
* offset = aligned_p % alignment # <<<<<<<<<<<<<<
*
* if offset > 0:
*/
__pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
/* "View.MemoryView":306
* 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":307
*
* 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":306
* offset = aligned_p % alignment
*
* if offset > 0: # <<<<<<<<<<<<<<
* aligned_p += alignment - offset
*
*/
}
/* "View.MemoryView":309
* aligned_p += alignment - offset
*
* return <void *> aligned_p # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = ((void *)__pyx_v_aligned_p);
goto __pyx_L0;
/* "View.MemoryView":298
*
* @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":345
* 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_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);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(1, 345, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__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_ERR(1, 345, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
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_ERR(1, 345, __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_ERR(1, 345, __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_ERR(1, 345, __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;
__Pyx_RefNannySetupContext("__cinit__", 0);
/* "View.MemoryView":346
*
* 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":347
* 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":348
* 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":349
* 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 == ((int)-1))) __PYX_ERR(1, 349, __pyx_L1_error)
/* "View.MemoryView":350
* 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":351
* __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":352
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* global __pyx_memoryview_thread_locks_used
*/
Py_INCREF(Py_None);
/* "View.MemoryView":350
* 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":348
* 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":355
*
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
*/
__pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":356
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL:
*/
__pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
/* "View.MemoryView":357
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<<
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
*/
__pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
/* "View.MemoryView":355
*
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
*/
}
/* "View.MemoryView":358
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL: # <<<<<<<<<<<<<<
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
*/
__pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":359
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<<
* if self.lock is NULL:
* raise MemoryError
*/
__pyx_v_self->lock = PyThread_allocate_lock();
/* "View.MemoryView":360
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
__pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":361
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
* raise MemoryError # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
PyErr_NoMemory(); __PYX_ERR(1, 361, __pyx_L1_error)
/* "View.MemoryView":360
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
}
/* "View.MemoryView":358
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL: # <<<<<<<<<<<<<<
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
*/
}
/* "View.MemoryView":363
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":364
*
* if flags & PyBUF_FORMAT:
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<<
* else:
* self.dtype_is_object = dtype_is_object
*/
__pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L11_bool_binop_done:;
__pyx_v_self->dtype_is_object = __pyx_t_1;
/* "View.MemoryView":363
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* else:
*/
goto __pyx_L10;
}
/* "View.MemoryView":366
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* 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_L10:;
/* "View.MemoryView":368
* 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":370
* 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":345
* 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_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":372
* 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) {
int __pyx_v_i;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
PyThread_type_lock __pyx_t_6;
PyThread_type_lock __pyx_t_7;
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":373
*
* 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":374
* def __dealloc__(memoryview self):
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<<
*
* cdef int i
*/
__Pyx_ReleaseBuffer((&__pyx_v_self->view));
/* "View.MemoryView":373
*
* def __dealloc__(memoryview self):
* if self.obj is not None: # <<<<<<<<<<<<<<
* __Pyx_ReleaseBuffer(&self.view)
*
*/
}
/* "View.MemoryView":378
* cdef int i
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL: # <<<<<<<<<<<<<<
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
*/
__pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":379
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<<
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
*/
__pyx_t_3 = __pyx_memoryview_thread_locks_used;
__pyx_t_4 = __pyx_t_3;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":380
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
*/
__pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":381
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<<
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
*/
__pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
/* "View.MemoryView":382
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
*/
__pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":384
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<<
* break
* else:
*/
__pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
__pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
/* "View.MemoryView":383
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
* break
*/
(__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
(__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
/* "View.MemoryView":382
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
*/
}
/* "View.MemoryView":385
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
* break # <<<<<<<<<<<<<<
* else:
* PyThread_free_lock(self.lock)
*/
goto __pyx_L6_break;
/* "View.MemoryView":380
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
*/
}
}
/*else*/ {
/* "View.MemoryView":387
* break
* else:
* PyThread_free_lock(self.lock) # <<<<<<<<<<<<<<
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL:
*/
PyThread_free_lock(__pyx_v_self->lock);
}
__pyx_L6_break:;
/* "View.MemoryView":378
* cdef int i
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL: # <<<<<<<<<<<<<<
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
*/
}
/* "View.MemoryView":372
* self.typeinfo = NULL
*
* def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":389
* 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;
__Pyx_RefNannySetupContext("get_item_pointer", 0);
/* "View.MemoryView":391
* 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":393
* 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_ERR(1, 393, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 393, __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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 393, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 393, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
} else {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 393, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 393, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 393, __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":394
*
* 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_ERR(1, 394, __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 == ((char *)NULL))) __PYX_ERR(1, 394, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_7;
/* "View.MemoryView":393
* 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":396
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
* return itemp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_itemp;
goto __pyx_L0;
/* "View.MemoryView":389
* 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":399
*
*
* 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;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":400
*
* 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":401
* 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":400
*
* def __getitem__(memoryview self, object index):
* if index is Ellipsis: # <<<<<<<<<<<<<<
* return self
*
*/
}
/* "View.MemoryView":403
* 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_ERR(1, 403, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (likely(__pyx_t_3 != Py_None)) {
PyObject* sequence = __pyx_t_3;
Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
__PYX_ERR(1, 403, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 403, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 403, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 403, __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":406
*
* 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_ERR(1, 406, __pyx_L1_error)
if (__pyx_t_2) {
/* "View.MemoryView":407
* 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_ERR(1, 407, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":406
*
* cdef char *itemp
* if have_slices: # <<<<<<<<<<<<<<
* return memview_slice(self, indices)
* else:
*/
}
/* "View.MemoryView":409
* 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 == ((char *)NULL))) __PYX_ERR(1, 409, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_6;
/* "View.MemoryView":410
* 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_ERR(1, 410, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":399
*
*
* 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":412
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview")
*/
/* 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
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
__Pyx_RefNannySetupContext("__setitem__", 0);
__Pyx_INCREF(__pyx_v_index);
/* "View.MemoryView":413
*
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly: # <<<<<<<<<<<<<<
* raise TypeError("Cannot assign to read-only memoryview")
*
*/
__pyx_t_1 = (__pyx_v_self->view.readonly != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":414
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
*
* have_slices, index = _unellipsify(index, self.view.ndim)
*/
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 414, __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_ERR(1, 414, __pyx_L1_error)
/* "View.MemoryView":413
*
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly: # <<<<<<<<<<<<<<
* raise TypeError("Cannot assign to read-only memoryview")
*
*/
}
/* "View.MemoryView":416
* raise TypeError("Cannot assign to read-only memoryview")
*
* have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
*
* if have_slices:
*/
__pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 416, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (likely(__pyx_t_2 != Py_None)) {
PyObject* sequence = __pyx_t_2;
Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
__PYX_ERR(1, 416, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
#else
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 416, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 416, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 416, __pyx_L1_error)
}
__pyx_v_have_slices = __pyx_t_3;
__pyx_t_3 = 0;
__Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":418
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 418, __pyx_L1_error)
if (__pyx_t_1) {
/* "View.MemoryView":419
*
* if have_slices:
* obj = self.is_slice(value) # <<<<<<<<<<<<<<
* if obj:
* self.setitem_slice_assignment(self[index], obj)
*/
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 419, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_v_obj = __pyx_t_2;
__pyx_t_2 = 0;
/* "View.MemoryView":420
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 420, __pyx_L1_error)
if (__pyx_t_1) {
/* "View.MemoryView":421
* 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_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 421, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 421, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
/* "View.MemoryView":420
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":423
* 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_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 423, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(1, 423, __pyx_L1_error)
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L5:;
/* "View.MemoryView":418
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
goto __pyx_L4;
}
/* "View.MemoryView":425
* self.setitem_slice_assign_scalar(self[index], value)
* else:
* self.setitem_indexed(index, value) # <<<<<<<<<<<<<<
*
* cdef is_slice(self, obj):
*/
/*else*/ {
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L4:;
/* "View.MemoryView":412
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview")
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__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":427
* 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;
__Pyx_RefNannySetupContext("is_slice", 0);
__Pyx_INCREF(__pyx_v_obj);
/* "View.MemoryView":428
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | 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":429
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__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":430
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 430, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":431
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | 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_ERR(1, 431, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_7);
/* "View.MemoryView":430
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 430, __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_ERR(1, 430, __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":429
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | 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_L9_try_end;
__pyx_L4_error:;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
/* "View.MemoryView":432
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
* except TypeError: # <<<<<<<<<<<<<<
* return None
*
*/
__pyx_t_9 = __Pyx_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_ERR(1, 432, __pyx_L6_except_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":433
* self.dtype_is_object)
* except TypeError:
* return None # <<<<<<<<<<<<<<
*
* return obj
*/
__Pyx_XDECREF(__pyx_r);
__pyx_r = Py_None; __Pyx_INCREF(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":429
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | 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_L9_try_end:;
}
/* "View.MemoryView":428
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
*/
}
/* "View.MemoryView":435
* 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":427
* 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":437
* 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;
__Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
/* "View.MemoryView":441
* 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_ERR(1, 441, __pyx_L1_error)
/* "View.MemoryView":442
*
* 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_ERR(1, 442, __pyx_L1_error)
/* "View.MemoryView":443
* 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_ERR(1, 443, __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_ERR(1, 443, __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_ERR(1, 443, __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_ERR(1, 443, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":441
* 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 == ((int)-1))) __PYX_ERR(1, 441, __pyx_L1_error)
/* "View.MemoryView":437
* 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":445
* 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;
__Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
/* "View.MemoryView":447
* 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":452
* 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":454
* 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":455
*
* 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":456
* 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 (unlikely(__pyx_t_1)) {
/* "View.MemoryView":457
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
* raise MemoryError # <<<<<<<<<<<<<<
* item = tmp
* else:
*/
PyErr_NoMemory(); __PYX_ERR(1, 457, __pyx_L1_error)
/* "View.MemoryView":456
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
* item = tmp
*/
}
/* "View.MemoryView":458
* if tmp == NULL:
* raise MemoryError
* item = tmp # <<<<<<<<<<<<<<
* else:
* item = <void *> array
*/
__pyx_v_item = __pyx_v_tmp;
/* "View.MemoryView":454
* 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":460
* item = tmp
* else:
* item = <void *> array # <<<<<<<<<<<<<<
*
* try:
*/
/*else*/ {
__pyx_v_item = ((void *)__pyx_v_array);
}
__pyx_L3:;
/* "View.MemoryView":462
* item = <void *> array
*
* try: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* (<PyObject **> item)[0] = <PyObject *> value
*/
/*try:*/ {
/* "View.MemoryView":463
*
* 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":464
* 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":463
*
* try:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* (<PyObject **> item)[0] = <PyObject *> value
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":466
* (<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_ERR(1, 466, __pyx_L6_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L8:;
/* "View.MemoryView":470
*
*
* 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":471
*
* 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_ERR(1, 471, __pyx_L6_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":470
*
*
* 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":472
* 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":475
* 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;
}
__pyx_L6_error:;
/*exception exit:*/{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__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":445
* 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":477
* 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;
__Pyx_RefNannySetupContext("setitem_indexed", 0);
/* "View.MemoryView":478
*
* 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 == ((char *)NULL))) __PYX_ERR(1, 478, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_1;
/* "View.MemoryView":479
* 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_ERR(1, 479, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":477
* 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":481
* 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;
int __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
size_t __pyx_t_10;
int __pyx_t_11;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":484
* """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_ERR(1, 484, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":487
* 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_ERR(1, 487, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":488
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__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":489
* 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_ERR(1, 489, __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_ERR(1, 489, __pyx_L3_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = NULL;
__pyx_t_8 = 0;
if (CYTHON_UNPACK_METHODS && 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;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_5)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
__pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 489, __pyx_L3_error)
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
__pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 489, __pyx_L3_error)
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
{
__pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 489, __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_ERR(1, 489, __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":488
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
}
/* "View.MemoryView":493
* 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":494
* 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)) __PYX_ERR(1, 494, __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":493
* raise ValueError("Unable to convert item to object")
* else:
* if len(self.view.format) == 1: # <<<<<<<<<<<<<<
* return result[0]
* return result
*/
}
/* "View.MemoryView":495
* 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_1); __pyx_t_1 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
/* "View.MemoryView":490
* try:
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error: # <<<<<<<<<<<<<<
* raise ValueError("Unable to convert item to object")
* else:
*/
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 490, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
__pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
if (__pyx_t_8) {
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 490, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GOTREF(__pyx_t_1);
/* "View.MemoryView":491
* 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__9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 491, __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_ERR(1, 491, __pyx_L5_except_error)
}
goto __pyx_L5_except_error;
__pyx_L5_except_error:;
/* "View.MemoryView":488
*
* 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":481
* 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":497
* 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;
int __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
Py_ssize_t __pyx_t_9;
PyObject *__pyx_t_10 = NULL;
char *__pyx_t_11;
char *__pyx_t_12;
char *__pyx_t_13;
char *__pyx_t_14;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":500
* """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_ERR(1, 500, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":505
* 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":506
*
* 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_ERR(1, 506, __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_ERR(1, 506, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 506, __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 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 506, __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_ERR(1, 506, __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_ERR(1, 506, __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_ERR(1, 506, __pyx_L1_error)
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":505
* cdef Py_ssize_t i
*
* if isinstance(value, tuple): # <<<<<<<<<<<<<<
* bytesvalue = struct.pack(self.view.format, *value)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":508
* 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_ERR(1, 508, __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_ERR(1, 508, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = NULL;
__pyx_t_7 = 0;
if (CYTHON_UNPACK_METHODS && 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;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_6)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
__pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 508, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
__pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 508, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
{
__pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 508, __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_ERR(1, 508, __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_ERR(1, 508, __pyx_L1_error)
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
}
__pyx_L3:;
/* "View.MemoryView":510
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_9 = 0;
if (unlikely(__pyx_v_bytesvalue == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
__PYX_ERR(1, 510, __pyx_L1_error)
}
__Pyx_INCREF(__pyx_v_bytesvalue);
__pyx_t_10 = __pyx_v_bytesvalue;
__pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
__pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
__pyx_t_11 = __pyx_t_14;
__pyx_v_c = (__pyx_t_11[0]);
/* "View.MemoryView":511
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
__pyx_v_i = __pyx_t_9;
/* "View.MemoryView":510
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_9 = (__pyx_t_9 + 1);
/* "View.MemoryView":511
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
(__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
}
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
/* "View.MemoryView":497
* 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_10);
__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":514
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*/
/* 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;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
Py_ssize_t *__pyx_t_4;
char *__pyx_t_5;
void *__pyx_t_6;
int __pyx_t_7;
Py_ssize_t __pyx_t_8;
if (__pyx_v_info == NULL) {
PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
return -1;
}
__Pyx_RefNannySetupContext("__getbuffer__", 0);
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
/* "View.MemoryView":515
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
*/
__pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = (__pyx_v_self->view.readonly != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":516
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
*
* if flags & PyBUF_ND:
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 516, __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_ERR(1, 516, __pyx_L1_error)
/* "View.MemoryView":515
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
*/
}
/* "View.MemoryView":518
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
* if flags & PyBUF_ND: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":519
*
* if flags & PyBUF_ND:
* info.shape = self.view.shape # <<<<<<<<<<<<<<
* else:
* info.shape = NULL
*/
__pyx_t_4 = __pyx_v_self->view.shape;
__pyx_v_info->shape = __pyx_t_4;
/* "View.MemoryView":518
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
* if flags & PyBUF_ND: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":521
* info.shape = self.view.shape
* else:
* info.shape = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_STRIDES:
*/
/*else*/ {
__pyx_v_info->shape = NULL;
}
__pyx_L6:;
/* "View.MemoryView":523
* 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":524
*
* if flags & PyBUF_STRIDES:
* info.strides = self.view.strides # <<<<<<<<<<<<<<
* else:
* info.strides = NULL
*/
__pyx_t_4 = __pyx_v_self->view.strides;
__pyx_v_info->strides = __pyx_t_4;
/* "View.MemoryView":523
* info.shape = NULL
*
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.strides = self.view.strides
* else:
*/
goto __pyx_L7;
}
/* "View.MemoryView":526
* info.strides = self.view.strides
* else:
* info.strides = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_INDIRECT:
*/
/*else*/ {
__pyx_v_info->strides = NULL;
}
__pyx_L7:;
/* "View.MemoryView":528
* 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":529
*
* if flags & PyBUF_INDIRECT:
* info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<<
* else:
* info.suboffsets = NULL
*/
__pyx_t_4 = __pyx_v_self->view.suboffsets;
__pyx_v_info->suboffsets = __pyx_t_4;
/* "View.MemoryView":528
* info.strides = NULL
*
* if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
* info.suboffsets = self.view.suboffsets
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":531
* info.suboffsets = self.view.suboffsets
* else:
* info.suboffsets = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
/*else*/ {
__pyx_v_info->suboffsets = NULL;
}
__pyx_L8:;
/* "View.MemoryView":533
* 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":534
*
* if flags & PyBUF_FORMAT:
* info.format = self.view.format # <<<<<<<<<<<<<<
* else:
* info.format = NULL
*/
__pyx_t_5 = __pyx_v_self->view.format;
__pyx_v_info->format = __pyx_t_5;
/* "View.MemoryView":533
* info.suboffsets = NULL
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.view.format
* else:
*/
goto __pyx_L9;
}
/* "View.MemoryView":536
* info.format = self.view.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.buf = self.view.buf
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L9:;
/* "View.MemoryView":538
* info.format = NULL
*
* info.buf = self.view.buf # <<<<<<<<<<<<<<
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
*/
__pyx_t_6 = __pyx_v_self->view.buf;
__pyx_v_info->buf = __pyx_t_6;
/* "View.MemoryView":539
*
* info.buf = self.view.buf
* info.ndim = self.view.ndim # <<<<<<<<<<<<<<
* info.itemsize = self.view.itemsize
* info.len = self.view.len
*/
__pyx_t_7 = __pyx_v_self->view.ndim;
__pyx_v_info->ndim = __pyx_t_7;
/* "View.MemoryView":540
* info.buf = self.view.buf
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize # <<<<<<<<<<<<<<
* info.len = self.view.len
* info.readonly = self.view.readonly
*/
__pyx_t_8 = __pyx_v_self->view.itemsize;
__pyx_v_info->itemsize = __pyx_t_8;
/* "View.MemoryView":541
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
* info.len = self.view.len # <<<<<<<<<<<<<<
* info.readonly = self.view.readonly
* info.obj = self
*/
__pyx_t_8 = __pyx_v_self->view.len;
__pyx_v_info->len = __pyx_t_8;
/* "View.MemoryView":542
* info.itemsize = self.view.itemsize
* info.len = self.view.len
* info.readonly = self.view.readonly # <<<<<<<<<<<<<<
* info.obj = self
*
*/
__pyx_t_1 = __pyx_v_self->view.readonly;
__pyx_v_info->readonly = __pyx_t_1;
/* "View.MemoryView":543
* info.len = self.view.len
* info.readonly = self.view.readonly
* 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":514
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
if (__pyx_v_info->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":549
*
* @property
* def T(self): # <<<<<<<<<<<<<<
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":550
* @property
* def T(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_ERR(1, 550, __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_ERR(1, 550, __pyx_L1_error)
__pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":551
* def T(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 == ((int)0))) __PYX_ERR(1, 551, __pyx_L1_error)
/* "View.MemoryView":552
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
* return result # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":549
*
* @property
* def T(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":555
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(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":556
* @property
* def base(self):
* return self.obj # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->obj);
__pyx_r = __pyx_v_self->obj;
goto __pyx_L0;
/* "View.MemoryView":555
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":559
*
* @property
* def shape(self): # <<<<<<<<<<<<<<
* return tuple([length for length in self.view.shape[:self.view.ndim]])
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":560
* @property
* def shape(self):
* return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 560, __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_ERR(1, 560, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 560, __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_ERR(1, 560, __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":559
*
* @property
* def shape(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":563
*
* @property
* def strides(self): # <<<<<<<<<<<<<<
* if self.view.strides == NULL:
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":564
* @property
* def strides(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 (unlikely(__pyx_t_1)) {
/* "View.MemoryView":566
* 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__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 566, __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_ERR(1, 566, __pyx_L1_error)
/* "View.MemoryView":564
* @property
* def strides(self):
* if self.view.strides == NULL: # <<<<<<<<<<<<<<
*
* raise ValueError("Buffer view does not expose strides")
*/
}
/* "View.MemoryView":568
* raise ValueError("Buffer view does not expose strides")
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 568, __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_ERR(1, 568, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 568, __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_ERR(1, 568, __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":563
*
* @property
* def strides(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":571
*
* @property
* def suboffsets(self): # <<<<<<<<<<<<<<
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":572
* @property
* def suboffsets(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":573
* def suboffsets(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_ERR(1, 573, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Multiply(__pyx_tuple__12, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 573, __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":572
* @property
* def suboffsets(self):
* if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
* return (-1,) * self.view.ndim
*
*/
}
/* "View.MemoryView":575
* return (-1,) * self.view.ndim
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 575, __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_ERR(1, 575, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 575, __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_ERR(1, 575, __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":571
*
* @property
* def suboffsets(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":578
*
* @property
* def ndim(self): # <<<<<<<<<<<<<<
* return self.view.ndim
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":579
* @property
* def ndim(self):
* return self.view.ndim # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 579, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":578
*
* @property
* def ndim(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":582
*
* @property
* def itemsize(self): # <<<<<<<<<<<<<<
* return self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":583
* @property
* def itemsize(self):
* return self.view.itemsize # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":582
*
* @property
* def itemsize(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":586
*
* @property
* def nbytes(self): # <<<<<<<<<<<<<<
* return self.size * self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":587
* @property
* def nbytes(self):
* return self.size * self.view.itemsize # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 587, __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_ERR(1, 587, __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_ERR(1, 587, __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":586
*
* @property
* def nbytes(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":590
*
* @property
* def size(self): # <<<<<<<<<<<<<<
* if self._size is None:
* result = 1
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(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;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":591
* @property
* def size(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":592
* def size(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":594
* 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_ERR(1, 594, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
__pyx_t_6 = 0;
/* "View.MemoryView":595
*
* 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_ERR(1, 595, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
__pyx_t_6 = 0;
}
/* "View.MemoryView":597
* 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":591
* @property
* def size(self):
* if self._size is None: # <<<<<<<<<<<<<<
* result = 1
*
*/
}
/* "View.MemoryView":599
* 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":590
*
* @property
* def size(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":601
* 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":602
*
* 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":603
* 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":602
*
* def __len__(self):
* if self.view.ndim >= 1: # <<<<<<<<<<<<<<
* return self.view.shape[0]
*
*/
}
/* "View.MemoryView":605
* return self.view.shape[0]
*
* return 0 # <<<<<<<<<<<<<<
*
* def __repr__(self):
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":601
* 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":607
* 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;
__Pyx_RefNannySetupContext("__repr__", 0);
/* "View.MemoryView":608
*
* 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_ERR(1, 608, __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_ERR(1, 608, __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_ERR(1, 608, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":609
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self)) # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 609, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
/* "View.MemoryView":608
*
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
* id(self))
*
*/
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 608, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 608, __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":607
* 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":611
* 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;
__Pyx_RefNannySetupContext("__str__", 0);
/* "View.MemoryView":612
*
* 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_ERR(1, 612, __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_ERR(1, 612, __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_ERR(1, 612, __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_ERR(1, 612, __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_ERR(1, 612, __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":611
* 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":615
*
*
* 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;
__Pyx_RefNannySetupContext("is_c_contig", 0);
/* "View.MemoryView":618
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice[0], 'C', self.view.ndim)
*
*/
__pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));
/* "View.MemoryView":619
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice[0], '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[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 619, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":615
*
*
* 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":621
* return slice_is_contig(mslice[0], '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;
__Pyx_RefNannySetupContext("is_f_contig", 0);
/* "View.MemoryView":624
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice[0], 'F', self.view.ndim)
*
*/
__pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));
/* "View.MemoryView":625
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<<
*
* def copy(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 625, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":621
* return slice_is_contig(mslice[0], '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":627
* return slice_is_contig(mslice[0], '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;
__Pyx_RefNannySetupContext("copy", 0);
/* "View.MemoryView":629
* 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":631
* 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":632
*
* 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), ((char *)"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_ERR(1, 632, __pyx_L1_error)
__pyx_v_mslice = __pyx_t_1;
/* "View.MemoryView":637
* 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_ERR(1, 637, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":627
* return slice_is_contig(mslice[0], '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":639
* 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;
__Pyx_RefNannySetupContext("copy_fortran", 0);
/* "View.MemoryView":641
* 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":643
* 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":644
*
* 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), ((char *)"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_ERR(1, 644, __pyx_L1_error)
__pyx_v_dst = __pyx_t_1;
/* "View.MemoryView":649
* 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_ERR(1, 649, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":639
* 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;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":653
*
* @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;
__Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
/* "View.MemoryView":654
* @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_ERR(1, 654, __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_ERR(1, 654, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 654, __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_ERR(1, 654, __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":655
* 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":656
* 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":653
*
* @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":659
*
* @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":660
* @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":659
*
* @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":662
* 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;
__Pyx_RefNannySetupContext("_unellipsify", 0);
/* "View.MemoryView":667
* 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":668
* """
* if not isinstance(index, tuple):
* tup = (index,) # <<<<<<<<<<<<<<
* else:
* tup = index
*/
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 668, __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":667
* full slices.
* """
* if not isinstance(index, tuple): # <<<<<<<<<<<<<<
* tup = (index,)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":670
* tup = (index,)
* else:
* tup = index # <<<<<<<<<<<<<<
*
* result = []
*/
/*else*/ {
__Pyx_INCREF(__pyx_v_index);
__pyx_v_tup = __pyx_v_index;
}
__pyx_L3:;
/* "View.MemoryView":672
* tup = index
*
* result = [] # <<<<<<<<<<<<<<
* have_slices = False
* seen_ellipsis = False
*/
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_v_result = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":673
*
* result = []
* have_slices = False # <<<<<<<<<<<<<<
* seen_ellipsis = False
* for idx, item in enumerate(tup):
*/
__pyx_v_have_slices = 0;
/* "View.MemoryView":674
* result = []
* have_slices = False
* seen_ellipsis = False # <<<<<<<<<<<<<<
* for idx, item in enumerate(tup):
* if item is Ellipsis:
*/
__pyx_v_seen_ellipsis = 0;
/* "View.MemoryView":675
* 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_ERR(1, 675, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 675, __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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 675, __pyx_L1_error)
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 675, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
#endif
} else {
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 675, __pyx_L1_error)
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 675, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 675, __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, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 675, __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":676
* 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":677
* 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":678
* 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 == ((Py_ssize_t)-1))) __PYX_ERR(1, 678, __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_ERR(1, 678, __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__15);
__Pyx_GIVEREF(__pyx_slice__15);
PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__15);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 678, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
/* "View.MemoryView":679
* 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":677
* 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":681
* seen_ellipsis = True
* else:
* result.append(slice(None)) # <<<<<<<<<<<<<<
* have_slices = True
* else:
*/
/*else*/ {
__pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__15); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 681, __pyx_L1_error)
}
__pyx_L7:;
/* "View.MemoryView":682
* 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":676
* 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":684
* 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 (unlikely(__pyx_t_1)) {
/* "View.MemoryView":685
* 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_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 685, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 685, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_Raise(__pyx_t_11, 0, 0, 0);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
__PYX_ERR(1, 685, __pyx_L1_error)
/* "View.MemoryView":684
* 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":687
* 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":688
*
* 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 == ((int)-1))) __PYX_ERR(1, 688, __pyx_L1_error)
}
__pyx_L6:;
/* "View.MemoryView":675
* 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":690
* 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 == ((Py_ssize_t)-1))) __PYX_ERR(1, 690, __pyx_L1_error)
__pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
/* "View.MemoryView":691
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
__pyx_t_1 = (__pyx_v_nslices != 0);
if (__pyx_t_1) {
/* "View.MemoryView":692
* 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_ERR(1, 692, __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__15);
__Pyx_GIVEREF(__pyx_slice__15);
PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__15);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 692, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":691
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
}
/* "View.MemoryView":694
* 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_ERR(1, 694, __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_ERR(1, 694, __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_ERR(1, 694, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 694, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
__pyx_t_3 = 0;
__pyx_t_4 = 0;
__pyx_r = ((PyObject*)__pyx_t_11);
__pyx_t_11 = 0;
goto __pyx_L0;
/* "View.MemoryView":662
* 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":696
* 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;
__Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
/* "View.MemoryView":697
*
* 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":698
* 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 (unlikely(__pyx_t_4)) {
/* "View.MemoryView":699
* 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__16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 699, __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_ERR(1, 699, __pyx_L1_error)
/* "View.MemoryView":698
* 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":696
* 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":706
*
* @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;
__Pyx_RefNannySetupContext("memview_slice", 0);
/* "View.MemoryView":707
* @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":714
*
*
* memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<<
*
* cdef _memoryviewslice memviewsliceobj
*/
(void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
/* "View.MemoryView":718
* 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_ERR(1, 718, __pyx_L1_error)
}
}
#endif
/* "View.MemoryView":720
* 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":721
*
* 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_ERR(1, 721, __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":722
* 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":720
* assert memview.view.ndim > 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice
*/
goto __pyx_L3;
}
/* "View.MemoryView":724
* 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":725
* else:
* slice_copy(memview, &src)
* p_src = &src # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_p_src = (&__pyx_v_src);
}
__pyx_L3:;
/* "View.MemoryView":731
*
*
* 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":732
*
* 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":737
*
*
* 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":738
*
* 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":742
* 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_ERR(1, 742, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 742, __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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 742, __pyx_L1_error)
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 742, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
#endif
} else {
if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__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_ERR(1, 742, __pyx_L1_error)
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 742, __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(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 742, __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":743
*
* 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":747
* 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_ERR(1, 747, __pyx_L1_error)
/* "View.MemoryView":744
* 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 == ((int)-1))) __PYX_ERR(1, 744, __pyx_L1_error)
/* "View.MemoryView":743
*
* 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":750
* 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":751
* 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":752
* 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":753
* 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":754
* 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":750
* 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":756
* 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_ERR(1, 756, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 756, __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_ERR(1, 756, __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":757
* 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_ERR(1, 757, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 757, __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_ERR(1, 757, __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":758
* 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_ERR(1, 758, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 758, __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_ERR(1, 758, __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":760
* 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_ERR(1, 760, __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":761
*
* 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_ERR(1, 761, __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":762
* 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_ERR(1, 762, __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":764
* 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 == ((int)-1))) __PYX_ERR(1, 764, __pyx_L1_error)
/* "View.MemoryView":770
* 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":742
* 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":772
* 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":773
*
* 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":774
* 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_ERR(1, 774, __pyx_L1_error) }
/* "View.MemoryView":775
* 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_ERR(1, 775, __pyx_L1_error) }
/* "View.MemoryView":773
*
* 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_ERR(1, 773, __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_ERR(1, 773, __pyx_L1_error)
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":772
* new_ndim += 1
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
*/
}
/* "View.MemoryView":778
* 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":779
* 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_ERR(1, 778, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
/* "View.MemoryView":778
* 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_ERR(1, 778, __pyx_L1_error)
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":706
*
* @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":803
*
* @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;
/* "View.MemoryView":823
* 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":825
* 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":826
*
* 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":825
* if not is_slice:
*
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if not 0 <= start < shape:
*/
}
/* "View.MemoryView":827
* 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":828
* 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, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 828, __pyx_L1_error)
/* "View.MemoryView":827
* if start < 0:
* start += shape
* if not 0 <= start < shape: # <<<<<<<<<<<<<<
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
* else:
*/
}
/* "View.MemoryView":823
* cdef bint negative_step
*
* if not is_slice: # <<<<<<<<<<<<<<
*
* if start < 0:
*/
goto __pyx_L3;
}
/* "View.MemoryView":831
* 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":833
* 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":834
*
* 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, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 834, __pyx_L1_error)
/* "View.MemoryView":833
* 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":837
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
__pyx_t_2 = (__pyx_v_have_start != 0);
if (__pyx_t_2) {
/* "View.MemoryView":838
*
* 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":839
* if have_start:
* if start < 0:
* start += shape # <<<<<<<<<<<<<<
* if start < 0:
* start = 0
*/
__pyx_v_start = (__pyx_v_start + __pyx_v_shape);
/* "View.MemoryView":840
* 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":841
* start += shape
* if start < 0:
* start = 0 # <<<<<<<<<<<<<<
* elif start >= shape:
* if negative_step:
*/
__pyx_v_start = 0;
/* "View.MemoryView":840
* if start < 0:
* start += shape
* if start < 0: # <<<<<<<<<<<<<<
* start = 0
* elif start >= shape:
*/
}
/* "View.MemoryView":838
*
* if have_start:
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if start < 0:
*/
goto __pyx_L12;
}
/* "View.MemoryView":842
* 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":843
* 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":844
* elif start >= shape:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = shape
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":843
* start = 0
* elif start >= shape:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L14;
}
/* "View.MemoryView":846
* start = shape - 1
* else:
* start = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
/*else*/ {
__pyx_v_start = __pyx_v_shape;
}
__pyx_L14:;
/* "View.MemoryView":842
* if start < 0:
* start = 0
* elif start >= shape: # <<<<<<<<<<<<<<
* if negative_step:
* start = shape - 1
*/
}
__pyx_L12:;
/* "View.MemoryView":837
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
goto __pyx_L11;
}
/* "View.MemoryView":848
* 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":849
* else:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = 0
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":848
* start = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L15;
}
/* "View.MemoryView":851
* start = shape - 1
* else:
* start = 0 # <<<<<<<<<<<<<<
*
* if have_stop:
*/
/*else*/ {
__pyx_v_start = 0;
}
__pyx_L15:;
}
__pyx_L11:;
/* "View.MemoryView":853
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
__pyx_t_2 = (__pyx_v_have_stop != 0);
if (__pyx_t_2) {
/* "View.MemoryView":854
*
* 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":855
* if have_stop:
* if stop < 0:
* stop += shape # <<<<<<<<<<<<<<
* if stop < 0:
* stop = 0
*/
__pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
/* "View.MemoryView":856
* 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":857
* stop += shape
* if stop < 0:
* stop = 0 # <<<<<<<<<<<<<<
* elif stop > shape:
* stop = shape
*/
__pyx_v_stop = 0;
/* "View.MemoryView":856
* if stop < 0:
* stop += shape
* if stop < 0: # <<<<<<<<<<<<<<
* stop = 0
* elif stop > shape:
*/
}
/* "View.MemoryView":854
*
* if have_stop:
* if stop < 0: # <<<<<<<<<<<<<<
* stop += shape
* if stop < 0:
*/
goto __pyx_L17;
}
/* "View.MemoryView":858
* 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":859
* stop = 0
* elif stop > shape:
* stop = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
__pyx_v_stop = __pyx_v_shape;
/* "View.MemoryView":858
* if stop < 0:
* stop = 0
* elif stop > shape: # <<<<<<<<<<<<<<
* stop = shape
* else:
*/
}
__pyx_L17:;
/* "View.MemoryView":853
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
goto __pyx_L16;
}
/* "View.MemoryView":861
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
/*else*/ {
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":862
* else:
* if negative_step:
* stop = -1 # <<<<<<<<<<<<<<
* else:
* stop = shape
*/
__pyx_v_stop = -1L;
/* "View.MemoryView":861
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
goto __pyx_L19;
}
/* "View.MemoryView":864
* stop = -1
* else:
* stop = shape # <<<<<<<<<<<<<<
*
* if not have_step:
*/
/*else*/ {
__pyx_v_stop = __pyx_v_shape;
}
__pyx_L19:;
}
__pyx_L16:;
/* "View.MemoryView":866
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
__pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":867
*
* if not have_step:
* step = 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_step = 1;
/* "View.MemoryView":866
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
}
/* "View.MemoryView":871
*
* 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":873
* 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":874
*
* if (stop - start) - step * new_shape:
* new_shape += 1 # <<<<<<<<<<<<<<
*
* if new_shape < 0:
*/
__pyx_v_new_shape = (__pyx_v_new_shape + 1);
/* "View.MemoryView":873
* new_shape = (stop - start) // step
*
* if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
* new_shape += 1
*
*/
}
/* "View.MemoryView":876
* 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":877
*
* if new_shape < 0:
* new_shape = 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_new_shape = 0;
/* "View.MemoryView":876
* new_shape += 1
*
* if new_shape < 0: # <<<<<<<<<<<<<<
* new_shape = 0
*
*/
}
/* "View.MemoryView":880
*
*
* 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":881
*
* 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":882
* 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":885
*
*
* 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":886
*
* 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":885
*
*
* if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
* dst.data += start * stride
* else:
*/
goto __pyx_L23;
}
/* "View.MemoryView":888
* 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":890
* 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":891
*
* 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":892
* 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":893
* 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":892
* if suboffset >= 0:
* if not is_slice:
* if new_ndim == 0: # <<<<<<<<<<<<<<
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
*/
goto __pyx_L26;
}
/* "View.MemoryView":895
* 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":896
* 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, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 895, __pyx_L1_error)
}
__pyx_L26:;
/* "View.MemoryView":891
*
* if suboffset >= 0:
* if not is_slice: # <<<<<<<<<<<<<<
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset
*/
goto __pyx_L25;
}
/* "View.MemoryView":898
* "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":890
* dst.suboffsets[suboffset_dim[0]] += start * stride
*
* if suboffset >= 0: # <<<<<<<<<<<<<<
* if not is_slice:
* if new_ndim == 0:
*/
}
/* "View.MemoryView":900
* suboffset_dim[0] = new_ndim
*
* return 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":803
*
* @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 = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":906
*
* @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;
__Pyx_RefNannySetupContext("pybuffer_index", 0);
/* "View.MemoryView":908
* 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":909
* 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":912
* 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":913
*
* 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_ERR(1, 913, __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_ERR(1, 913, __pyx_L1_error)
}
__pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
/* "View.MemoryView":914
* if view.ndim == 0:
* shape = view.len / itemsize
* stride = itemsize # <<<<<<<<<<<<<<
* else:
* shape = view.shape[dim]
*/
__pyx_v_stride = __pyx_v_itemsize;
/* "View.MemoryView":912
* cdef char *resultp
*
* if view.ndim == 0: # <<<<<<<<<<<<<<
* shape = view.len / itemsize
* stride = itemsize
*/
goto __pyx_L3;
}
/* "View.MemoryView":916
* 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":917
* 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":918
* 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":919
* 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":918
* shape = view.shape[dim]
* stride = view.strides[dim]
* if view.suboffsets != NULL: # <<<<<<<<<<<<<<
* suboffset = view.suboffsets[dim]
*
*/
}
}
__pyx_L3:;
/* "View.MemoryView":921
* 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":922
*
* 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":923
* 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 (unlikely(__pyx_t_2)) {
/* "View.MemoryView":924
* 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_ERR(1, 924, __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_ERR(1, 924, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 924, __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_ERR(1, 924, __pyx_L1_error)
/* "View.MemoryView":923
* if index < 0:
* index += view.shape[dim]
* if index < 0: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
}
/* "View.MemoryView":921
* suboffset = view.suboffsets[dim]
*
* if index < 0: # <<<<<<<<<<<<<<
* index += view.shape[dim]
* if index < 0:
*/
}
/* "View.MemoryView":926
* 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 (unlikely(__pyx_t_2)) {
/* "View.MemoryView":927
*
* if index >= shape:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
*
* resultp = bufp + index * stride
*/
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 927, __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_ERR(1, 927, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 927, __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_ERR(1, 927, __pyx_L1_error)
/* "View.MemoryView":926
* 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":929
* 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":930
*
* 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":931
* 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":930
*
* resultp = bufp + index * stride
* if suboffset >= 0: # <<<<<<<<<<<<<<
* resultp = (<char **> resultp)[0] + suboffset
*
*/
}
/* "View.MemoryView":933
* resultp = (<char **> resultp)[0] + suboffset
*
* return resultp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_resultp;
goto __pyx_L0;
/* "View.MemoryView":906
*
* @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":939
*
* @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;
long __pyx_t_4;
Py_ssize_t __pyx_t_5;
Py_ssize_t __pyx_t_6;
int __pyx_t_7;
int __pyx_t_8;
int __pyx_t_9;
/* "View.MemoryView":940
* @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":942
* 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":943
*
* 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":947
*
* 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);
__pyx_t_4 = __pyx_t_3;
for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":948
* 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":949
* 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_5 = (__pyx_v_strides[__pyx_v_j]);
__pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
(__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
(__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
/* "View.MemoryView":950
* 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_6 = (__pyx_v_shape[__pyx_v_j]);
__pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
(__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
(__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
/* "View.MemoryView":952
* 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_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
if (!__pyx_t_8) {
} else {
__pyx_t_7 = __pyx_t_8;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
__pyx_t_7 = __pyx_t_8;
__pyx_L6_bool_binop_done:;
if (__pyx_t_7) {
/* "View.MemoryView":953
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<<
*
* return 1
*/
__pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 953, __pyx_L1_error)
/* "View.MemoryView":952
* 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":955
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
* return 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 1;
goto __pyx_L0;
/* "View.MemoryView":939
*
* @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 = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":972
* 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":973
*
* 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":972
* 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":975
* __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;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":976
*
* 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":977
* 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_ERR(1, 977, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":976
*
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL: # <<<<<<<<<<<<<<
* return self.to_object_func(itemp)
* else:
*/
}
/* "View.MemoryView":979
* 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_ERR(1, 979, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":975
* __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":981
* 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;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":982
*
* 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":983
* 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 == ((int)0))) __PYX_ERR(1, 983, __pyx_L1_error)
/* "View.MemoryView":982
*
* 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":985
* self.to_dtype_func(itemp, value)
* else:
* memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<<
*
* @property
*/
/*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_ERR(1, 985, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_L3:;
/* "View.MemoryView":981
* 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":988
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(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":989
* @property
* def base(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":988
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":995
*
* @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;
__Pyx_RefNannySetupContext("memoryview_fromslice", 0);
/* "View.MemoryView":1003
* 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":1004
*
* if <PyObject *> memviewslice.memview == Py_None:
* return None # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
/* "View.MemoryView":1003
* cdef _memoryviewslice result
*
* if <PyObject *> memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
* return None
*
*/
}
/* "View.MemoryView":1009
*
*
* 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_ERR(1, 1009, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1009, __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_ERR(1, 1009, __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":1011
* 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":1012
*
* 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":1014
* __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_ERR(1, 1014, __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":1015
*
* 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":1017
* 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":1018
*
* 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":1019
* 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":1020
* 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":1021
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
*/
Py_INCREF(Py_None);
/* "View.MemoryView":1023
* Py_INCREF(Py_None)
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
* result.flags = PyBUF_RECORDS
* else:
*/
__pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1024
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
* result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<<
* else:
* result.flags = PyBUF_RECORDS_RO
*/
__pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
/* "View.MemoryView":1023
* Py_INCREF(Py_None)
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
* result.flags = PyBUF_RECORDS
* else:
*/
goto __pyx_L4;
}
/* "View.MemoryView":1026
* result.flags = PyBUF_RECORDS
* else:
* result.flags = PyBUF_RECORDS_RO # <<<<<<<<<<<<<<
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape
*/
/*else*/ {
__pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
}
__pyx_L4:;
/* "View.MemoryView":1028
* result.flags = PyBUF_RECORDS_RO
*
* 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":1029
*
* 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":1032
*
*
* 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":1033
*
* 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":1034
* 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":1035
* 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":1036
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break # <<<<<<<<<<<<<<
*
* result.view.len = result.view.itemsize
*/
goto __pyx_L6_break;
/* "View.MemoryView":1034
* 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_L6_break:;
/* "View.MemoryView":1038
* 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":1039
*
* 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_ERR(1, 1039, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":1040
* 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_ERR(1, 1040, __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_ERR(1, 1040, __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_ERR(1, 1040, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result->__pyx_base.view.len = __pyx_t_9;
}
/* "View.MemoryView":1042
* 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":1043
*
* 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":1045
* 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":995
*
* @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":1048
*
* @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;
__Pyx_RefNannySetupContext("get_slice_from_memview", 0);
/* "View.MemoryView":1051
* __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":1052
* 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_ERR(1, 1052, __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":1053
* 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":1051
* __Pyx_memviewslice *mslice):
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* obj = memview
* return &obj.from_slice
*/
}
/* "View.MemoryView":1055
* return &obj.from_slice
* else:
* slice_copy(memview, mslice) # <<<<<<<<<<<<<<
* return mslice
*
*/
/*else*/ {
__pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
/* "View.MemoryView":1056
* else:
* slice_copy(memview, mslice)
* return mslice # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_slice_copy')
*/
__pyx_r = __pyx_v_mslice;
goto __pyx_L0;
}
/* "View.MemoryView":1048
*
* @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, 1, 0);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_obj);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1059
*
* @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;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
__Pyx_RefNannySetupContext("slice_copy", 0);
/* "View.MemoryView":1063
* 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":1064
*
* 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":1065
* 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":1067
* 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":1068
*
* 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":1070
* 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;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_dim = __pyx_t_4;
/* "View.MemoryView":1071
*
* 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":1072
* 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":1073
* 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_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
} else {
__pyx_t_5 = -1L;
}
(__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
}
/* "View.MemoryView":1059
*
* @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":1076
*
* @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;
__Pyx_RefNannySetupContext("memoryview_copy", 0);
/* "View.MemoryView":1079
* "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":1080
* 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_ERR(1, 1080, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":1076
*
* @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":1083
*
* @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;
__Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
/* "View.MemoryView":1090
* 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":1091
*
* 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":1092
* 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":1090
* 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":1094
* 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":1095
* 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":1097
* 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":1099
* 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_ERR(1, 1097, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "View.MemoryView":1083
*
* @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":1105
*
*
* 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":1106
*
* 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":1107
* 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":1106
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0: # <<<<<<<<<<<<<<
* return -arg
* else:
*/
}
/* "View.MemoryView":1109
* return -arg
* else:
* return arg # <<<<<<<<<<<<<<
*
* @cname('__pyx_get_best_slice_order')
*/
/*else*/ {
__pyx_r = __pyx_v_arg;
goto __pyx_L0;
}
/* "View.MemoryView":1105
*
*
* 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":1112
*
* @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;
int __pyx_t_4;
/* "View.MemoryView":1117
* """
* cdef int i
* cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<<
* cdef Py_ssize_t f_stride = 0
*
*/
__pyx_v_c_stride = 0;
/* "View.MemoryView":1118
* 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":1120
* 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 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1121
*
* 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":1122
* 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":1123
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i]
* break # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
goto __pyx_L4_break;
/* "View.MemoryView":1121
*
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* c_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L4_break:;
/* "View.MemoryView":1125
* break
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i]
*/
__pyx_t_1 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_1;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1126
*
* 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":1127
* 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":1128
* 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":1126
*
* for i in range(ndim):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* f_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L7_break:;
/* "View.MemoryView":1130
* 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":1131
*
* 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":1130
* break
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
* return 'C'
* else:
*/
}
/* "View.MemoryView":1133
* return 'C'
* else:
* return 'F' # <<<<<<<<<<<<<<
*
* @cython.cdivision(True)
*/
/*else*/ {
__pyx_r = 'F';
goto __pyx_L0;
}
/* "View.MemoryView":1112
*
* @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":1136
*
* @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;
Py_ssize_t __pyx_t_6;
/* "View.MemoryView":1143
*
* 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":1144
* 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":1145
* 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":1146
* 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":1148
* 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":1149
*
* 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":1150
* 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":1149
*
* 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":1151
* 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):
*/
(void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
/* "View.MemoryView":1149
*
* 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":1153
* 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;
__pyx_t_5 = __pyx_t_4;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1154
* else:
* for i in range(dst_extent):
* memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<<
* src_data += src_stride
* dst_data += dst_stride
*/
(void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
/* "View.MemoryView":1155
* 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":1156
* 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":1148
* 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":1158
* 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;
__pyx_t_5 = __pyx_t_4;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1159
* 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":1163
* 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":1164
* 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":1136
*
* @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":1166
* 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":1169
* __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":1166
* 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":1173
*
* @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;
int __pyx_t_4;
/* "View.MemoryView":1176
* "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":1178
* cdef Py_ssize_t size = src.memview.view.itemsize
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* size *= src.shape[i]
*
*/
__pyx_t_2 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1179
*
* 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":1181
* size *= src.shape[i]
*
* return size # <<<<<<<<<<<<<<
*
* @cname('__pyx_fill_contig_strides_array')
*/
__pyx_r = __pyx_v_size;
goto __pyx_L0;
/* "View.MemoryView":1173
*
* @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":1184
*
* @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;
int __pyx_t_4;
/* "View.MemoryView":1193
* 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":1194
*
* if order == 'F':
* for idx in range(ndim): # <<<<<<<<<<<<<<
* strides[idx] = stride
* stride = stride * shape[idx]
*/
__pyx_t_2 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_idx = __pyx_t_4;
/* "View.MemoryView":1195
* 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":1196
* 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":1193
* cdef int idx
*
* if order == 'F': # <<<<<<<<<<<<<<
* for idx in range(ndim):
* strides[idx] = stride
*/
goto __pyx_L3;
}
/* "View.MemoryView":1198
* 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 > -1; __pyx_t_2-=1) {
__pyx_v_idx = __pyx_t_2;
/* "View.MemoryView":1199
* 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":1200
* 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":1202
* stride = stride * shape[idx]
*
* return stride # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_data_to_temp')
*/
__pyx_r = __pyx_v_stride;
goto __pyx_L0;
/* "View.MemoryView":1184
*
* @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":1205
*
* @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_t_6;
/* "View.MemoryView":1216
* 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":1217
*
* 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":1219
* 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":1220
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
__pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1221
* result = malloc(size)
* if not result:
* _err(MemoryError, NULL) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1221, __pyx_L1_error)
/* "View.MemoryView":1220
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
}
/* "View.MemoryView":1224
*
*
* tmpslice.data = <char *> result # <<<<<<<<<<<<<<
* tmpslice.memview = src.memview
* for i in range(ndim):
*/
__pyx_v_tmpslice->data = ((char *)__pyx_v_result);
/* "View.MemoryView":1225
*
* 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":1226
* 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;
__pyx_t_5 = __pyx_t_3;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1227
* 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":1228
* 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":1230
* tmpslice.suboffsets[i] = -1
*
* fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<<
* ndim, order)
*
*/
(void)(__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":1234
*
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0
*/
__pyx_t_3 = __pyx_v_ndim;
__pyx_t_5 = __pyx_t_3;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1235
*
* 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":1236
* for i in range(ndim):
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0 # <<<<<<<<<<<<<<
*
* if slice_is_contig(src[0], order, ndim):
*/
(__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
/* "View.MemoryView":1235
*
* for i in range(ndim):
* if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
* tmpslice.strides[i] = 0
*
*/
}
}
/* "View.MemoryView":1238
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1239
*
* if slice_is_contig(src[0], order, ndim):
* memcpy(result, src.data, size) # <<<<<<<<<<<<<<
* else:
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*/
(void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
/* "View.MemoryView":1238
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
goto __pyx_L9;
}
/* "View.MemoryView":1241
* 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":1243
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*
* return result # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
/* "View.MemoryView":1205
*
* @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 = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = NULL;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1248
*
* @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;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_extents", 0);
/* "View.MemoryView":1251
* 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_ERR(1, 1251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1251, __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":1250
* 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_ERR(1, 1250, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1250, __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_ERR(1, 1250, __pyx_L1_error)
/* "View.MemoryView":1248
*
* @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
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1254
*
* @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;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_dim", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1255
* @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_ERR(1, 1255, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1255, __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_ERR(1, 1255, __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_UNPACK_METHODS && 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);
}
}
__pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1255, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__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_ERR(1, 1255, __pyx_L1_error)
/* "View.MemoryView":1254
*
* @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_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1258
*
* @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;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1259
* @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 (unlikely(__pyx_t_1)) {
/* "View.MemoryView":1260
* 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_ERR(1, 1260, __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_UNPACK_METHODS && 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);
}
}
__pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1260, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__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_ERR(1, 1260, __pyx_L1_error)
/* "View.MemoryView":1259
* @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":1262
* raise error(msg.decode('ascii'))
* else:
* raise error # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_contents')
*/
/*else*/ {
__Pyx_Raise(__pyx_v_error, 0, 0, 0);
__PYX_ERR(1, 1262, __pyx_L1_error)
}
/* "View.MemoryView":1258
*
* @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_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1265
*
* @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;
int __pyx_t_6;
void *__pyx_t_7;
int __pyx_t_8;
/* "View.MemoryView":1273
* 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":1274
* """
* 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":1276
* 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":1277
* 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":1278
* 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":1281
* 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":1282
*
* 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":1281
* 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":1283
* 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":1284
* 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":1283
* 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":1286
* 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":1288
* 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;
__pyx_t_3 = __pyx_t_5;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1289
*
* 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":1290
* 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":1291
* 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":1292
* 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":1290
* 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":1294
* src.strides[i] = 0
* else:
* _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<<
*
* if src.suboffsets[i] >= 0:
*/
/*else*/ {
__pyx_t_6 = __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_6 == ((int)-1))) __PYX_ERR(1, 1294, __pyx_L1_error)
}
__pyx_L7:;
/* "View.MemoryView":1289
*
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
* if src.shape[i] == 1:
* broadcasting = True
*/
}
/* "View.MemoryView":1296
* _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":1297
*
* if src.suboffsets[i] >= 0:
* _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<<
*
* if slices_overlap(&src, &dst, ndim, itemsize):
*/
__pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1297, __pyx_L1_error)
/* "View.MemoryView":1296
* _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":1299
* _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":1301
* 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":1302
*
* 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":1301
* if slices_overlap(&src, &dst, ndim, itemsize):
*
* if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
* order = get_best_order(&dst, ndim)
*
*/
}
/* "View.MemoryView":1304
* order = get_best_order(&dst, ndim)
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<<
* src = tmp
*
*/
__pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(1, 1304, __pyx_L1_error)
__pyx_v_tmpdata = __pyx_t_7;
/* "View.MemoryView":1305
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
* src = tmp # <<<<<<<<<<<<<<
*
* if not broadcasting:
*/
__pyx_v_src = __pyx_v_tmp;
/* "View.MemoryView":1299
* _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":1307
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1310
*
*
* 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":1311
*
* 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":1310
*
*
* 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":1312
* 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":1313
* 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":1312
* 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":1315
* 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":1317
* 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":1318
*
* 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)
*/
(void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
/* "View.MemoryView":1319
* 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":1320
* 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":1321
* 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":1315
* direct_copy = slice_is_contig(dst, 'F', ndim)
*
* if direct_copy: # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
}
/* "View.MemoryView":1307
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1323
* 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_8 = (__pyx_t_2 != 0);
if (__pyx_t_8) {
/* "View.MemoryView":1326
*
*
* transpose_memslice(&src) # <<<<<<<<<<<<<<
* transpose_memslice(&dst)
*
*/
__pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1326, __pyx_L1_error)
/* "View.MemoryView":1327
*
* 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 == ((int)0))) __PYX_ERR(1, 1327, __pyx_L1_error)
/* "View.MemoryView":1323
* return 0
*
* if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1329
* 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":1330
*
* 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":1331
* 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":1333
* refcount_copying(&dst, dtype_is_object, ndim, True)
*
* free(tmpdata) # <<<<<<<<<<<<<<
* return 0
*
*/
free(__pyx_v_tmpdata);
/* "View.MemoryView":1334
*
* free(tmpdata)
* return 0 # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_broadcast_leading')
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":1265
*
* @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 = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1337
*
* @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;
int __pyx_t_3;
/* "View.MemoryView":1341
* 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":1343
* 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 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1344
*
* 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":1345
* 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":1346
* 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":1348
* 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;
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1349
*
* 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":1350
* 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":1351
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0]
* mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
*
*
*/
(__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
}
/* "View.MemoryView":1337
*
* @cname('__pyx_memoryview_broadcast_leading')
* cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
* int ndim,
* int ndim_other) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1359
*
* @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":1363
*
*
* 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":1364
*
* 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":1363
*
*
* if dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice_with_gil(dst.data, dst.shape,
* dst.strides, ndim, inc)
*/
}
/* "View.MemoryView":1359
*
* @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":1368
*
* @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 = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
/* "View.MemoryView":1371
* 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":1368
*
* @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
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
/* "View.MemoryView":1374
*
* @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;
Py_ssize_t __pyx_t_3;
int __pyx_t_4;
__Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
/* "View.MemoryView":1378
* cdef Py_ssize_t i
*
* for i in range(shape[0]): # <<<<<<<<<<<<<<
* if ndim == 1:
* if inc:
*/
__pyx_t_1 = (__pyx_v_shape[0]);
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1379
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
__pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":1380
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
__pyx_t_4 = (__pyx_v_inc != 0);
if (__pyx_t_4) {
/* "View.MemoryView":1381
* 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":1380
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":1383
* 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":1379
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
goto __pyx_L5;
}
/* "View.MemoryView":1385
* Py_DECREF((<PyObject **> data)[0])
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
* ndim - 1, inc)
*
*/
/*else*/ {
/* "View.MemoryView":1386
* 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":1388
* ndim - 1, inc)
*
* data += strides[0] # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
}
/* "View.MemoryView":1374
*
* @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":1394
*
* @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":1397
* 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":1398
* 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":1400
* _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":1394
*
* @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":1404
*
* @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;
Py_ssize_t __pyx_t_4;
/* "View.MemoryView":1408
* 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":1409
* 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":1411
* 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":1412
*
* if ndim == 1:
* for i in range(extent): # <<<<<<<<<<<<<<
* memcpy(data, item, itemsize)
* data += stride
*/
__pyx_t_2 = __pyx_v_extent;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1413
* if ndim == 1:
* for i in range(extent):
* memcpy(data, item, itemsize) # <<<<<<<<<<<<<<
* data += stride
* else:
*/
(void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
/* "View.MemoryView":1414
* 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":1411
* cdef Py_ssize_t extent = shape[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* for i in range(extent):
* memcpy(data, item, itemsize)
*/
goto __pyx_L3;
}
/* "View.MemoryView":1416
* 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;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1417
* 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":1419
* _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":1404
*
* @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 */
}
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v___pyx_type = 0;
long __pyx_v___pyx_checksum;
PyObject *__pyx_v___pyx_state = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
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);
}
__pyx_v___pyx_type = values[0];
__pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
__pyx_v___pyx_state = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_v___pyx_PickleError = 0;
PyObject *__pyx_v___pyx_result = 0;
PyObject *__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_t_6;
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
/* "(tree fragment)":4
* cdef object __pyx_PickleError
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
*/
__pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
if (__pyx_t_1) {
/* "(tree fragment)":5
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931:
* from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
*/
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_n_s_PickleError);
__Pyx_GIVEREF(__pyx_n_s_PickleError);
PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
__pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_t_2);
__pyx_v___pyx_PickleError = __pyx_t_2;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "(tree fragment)":6
* if __pyx_checksum != 0xb068931:
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) # <<<<<<<<<<<<<<
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None:
*/
__pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_INCREF(__pyx_v___pyx_PickleError);
__pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
}
}
__pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 6, __pyx_L1_error)
/* "(tree fragment)":4
* cdef object __pyx_PickleError
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
*/
}
/* "(tree fragment)":7
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<<
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
*/
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
}
}
__pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v___pyx_result = __pyx_t_3;
__pyx_t_3 = 0;
/* "(tree fragment)":8
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None: # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
*/
__pyx_t_1 = (__pyx_v___pyx_state != Py_None);
__pyx_t_6 = (__pyx_t_1 != 0);
if (__pyx_t_6) {
/* "(tree fragment)":9
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
*/
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
__pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "(tree fragment)":8
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None: # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
*/
}
/* "(tree fragment)":10
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result # <<<<<<<<<<<<<<
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v___pyx_result);
__pyx_r = __pyx_v___pyx_result;
goto __pyx_L0;
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_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.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v___pyx_PickleError);
__Pyx_XDECREF(__pyx_v___pyx_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
Py_ssize_t __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
/* "(tree fragment)":12
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0] # <<<<<<<<<<<<<<
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
* __pyx_result.__dict__.update(__pyx_state[1])
*/
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 12, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_v___pyx_result->name);
__Pyx_DECREF(__pyx_v___pyx_result->name);
__pyx_v___pyx_result->name = __pyx_t_1;
__pyx_t_1 = 0;
/* "(tree fragment)":13
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
* __pyx_result.__dict__.update(__pyx_state[1])
*/
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(1, 13, __pyx_L1_error)
}
__pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
__pyx_t_4 = ((__pyx_t_3 > 1) != 0);
if (__pyx_t_4) {
} else {
__pyx_t_2 = __pyx_t_4;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
__pyx_t_5 = (__pyx_t_4 != 0);
__pyx_t_2 = __pyx_t_5;
__pyx_L4_bool_binop_done:;
if (__pyx_t_2) {
/* "(tree fragment)":14
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
* __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<<
*/
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 14, __pyx_L1_error)
}
__pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_8 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
if (likely(__pyx_t_8)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
__Pyx_INCREF(__pyx_t_8);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_7, function);
}
}
__pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "(tree fragment)":13
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
* __pyx_result.__dict__.update(__pyx_state[1])
*/
}
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
/* 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_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static struct __pyx_vtabstruct_array __pyx_vtable_array;
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->__pyx_vtab = __pyx_vtabptr_array;
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)) goto bad;
return o;
bad:
Py_DECREF(o); o = 0;
return NULL;
}
static void __pyx_tp_dealloc_array(PyObject *o) {
struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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 = __Pyx_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 __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
}
static PyMethodDef __pyx_methods_array[] = {
{"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_array[] = {
{(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
{0, 0, 0, 0, 0}
};
static PySequenceMethods __pyx_tp_as_sequence_array = {
__pyx_array___len__, /*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 = {
__pyx_array___len__, /*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)
"libreco.algorithms._als.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
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#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 CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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[] = {
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_MemviewEnum = {
PyVarObject_HEAD_INIT(0, 0)
"libreco.algorithms._als.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
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#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)) goto bad;
return o;
bad:
Py_DECREF(o); o = 0;
return NULL;
}
static void __pyx_tp_dealloc_memoryview(PyObject *o) {
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(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},
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_memoryview[] = {
{(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
{(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
{(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
{(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
{(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
{(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
{(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
{(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
{(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)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)
"libreco.algorithms._als.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
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#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 CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && 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_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
}
static PyMethodDef __pyx_methods__memoryviewslice[] = {
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
{(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
{0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_memoryviewslice = {
PyVarObject_HEAD_INIT(0, 0)
"libreco.algorithms._als._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
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#endif
};
static PyMethodDef __pyx_methods[] = {
{0, 0, 0, 0}
};
#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec__als(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
{Py_mod_create, (void*)__pyx_pymod_create},
{Py_mod_exec, (void*)__pyx_pymod_exec__als},
{0, NULL}
};
#endif
static struct PyModuleDef __pyx_moduledef = {
PyModuleDef_HEAD_INIT,
"_als",
0, /* m_doc */
#if CYTHON_PEP489_MULTI_PHASE_INIT
0, /* m_size */
#else
-1, /* m_size */
#endif
__pyx_methods /* m_methods */,
#if CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_moduledef_slots, /* m_slots */
#else
NULL, /* m_reload */
#endif
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
#define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define CYTHON_SMALL_CODE __attribute__((cold))
#else
#define CYTHON_SMALL_CODE
#endif
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 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_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0},
{&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 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_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
{&__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_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_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
{&__pyx_kp_u_Try_increasing_the_regularizati, __pyx_k_Try_increasing_the_regularizati, sizeof(__pyx_k_Try_increasing_the_regularizati), 0, 1, 0, 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_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 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_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
{&__pyx_n_s_als_update, __pyx_k_als_update, sizeof(__pyx_k_als_update), 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_cg_steps, __pyx_k_cg_steps, sizeof(__pyx_k_cg_steps), 0, 0, 1, 1},
{&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
{&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 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_kp_u_cython_lapack_posv_failed_err, __pyx_k_cython_lapack_posv_failed_err, sizeof(__pyx_k_cython_lapack_posv_failed_err), 0, 1, 0, 0},
{&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
{&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
{&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 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_eye, __pyx_k_eye, sizeof(__pyx_k_eye), 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_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 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_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_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
{&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
{&__pyx_n_s_interaction, __pyx_k_interaction, sizeof(__pyx_k_interaction), 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_libreco_algorithms__als, __pyx_k_libreco_algorithms__als, sizeof(__pyx_k_libreco_algorithms__als), 0, 0, 1, 1},
{&__pyx_kp_s_libreco_algorithms__als_pyx, __pyx_k_libreco_algorithms__als_pyx, sizeof(__pyx_k_libreco_algorithms__als_pyx), 0, 0, 1, 0},
{&__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_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
{&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
{&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
{&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
{&__pyx_n_s_num_threads, __pyx_k_num_threads, sizeof(__pyx_k_num_threads), 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_kp_u_on_row, __pyx_k_on_row, sizeof(__pyx_k_on_row), 0, 1, 0, 0},
{&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
{&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
{&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
{&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 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_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
{&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
{&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
{&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 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_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
{&__pyx_n_s_ranking, __pyx_k_ranking, sizeof(__pyx_k_ranking), 0, 0, 1, 1},
{&__pyx_n_s_rating, __pyx_k_rating, sizeof(__pyx_k_rating), 0, 0, 1, 1},
{&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
{&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
{&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
{&__pyx_n_s_reg, __pyx_k_reg, sizeof(__pyx_k_reg), 0, 0, 1, 1},
{&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
{&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
{&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
{&__pyx_n_s_single, __pyx_k_single, sizeof(__pyx_k_single), 0, 0, 1, 1},
{&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 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_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
{&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
{&__pyx_n_s_task, __pyx_k_task, sizeof(__pyx_k_task), 0, 0, 1, 1},
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
{&__pyx_n_s_transpose, __pyx_k_transpose, sizeof(__pyx_k_transpose), 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_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
{&__pyx_n_s_use_cg, __pyx_k_use_cg, sizeof(__pyx_k_use_cg), 0, 0, 1, 1},
{&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 79, __pyx_L1_error)
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 108, __pyx_L1_error)
__pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error)
__pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error)
__pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
__pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 400, __pyx_L1_error)
__pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 609, __pyx_L1_error)
__pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 828, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
/* "View.MemoryView":133
*
* if not self.ndim:
* raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
*
* if itemsize <= 0:
*/
__pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 133, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple_);
__Pyx_GIVEREF(__pyx_tuple_);
/* "View.MemoryView":136
*
* if itemsize <= 0:
* raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
*
* if not isinstance(format, bytes):
*/
__pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 136, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__2);
__Pyx_GIVEREF(__pyx_tuple__2);
/* "View.MemoryView":148
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 148, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__3);
__Pyx_GIVEREF(__pyx_tuple__3);
/* "View.MemoryView":176
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 176, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__4);
__Pyx_GIVEREF(__pyx_tuple__4);
/* "View.MemoryView":192
* 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__5 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 192, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__5);
__Pyx_GIVEREF(__pyx_tuple__5);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__6);
__Pyx_GIVEREF(__pyx_tuple__6);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__7);
__Pyx_GIVEREF(__pyx_tuple__7);
/* "View.MemoryView":414
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
*
* have_slices, index = _unellipsify(index, self.view.ndim)
*/
__pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 414, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__8);
__Pyx_GIVEREF(__pyx_tuple__8);
/* "View.MemoryView":491
* 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__9 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 491, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__9);
__Pyx_GIVEREF(__pyx_tuple__9);
/* "View.MemoryView":516
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
*
* if flags & PyBUF_ND:
*/
__pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 516, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__10);
__Pyx_GIVEREF(__pyx_tuple__10);
/* "View.MemoryView":566
* 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__11 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 566, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__11);
__Pyx_GIVEREF(__pyx_tuple__11);
/* "View.MemoryView":573
* def suboffsets(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__12 = PyTuple_New(1); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 573, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__12);
__Pyx_INCREF(__pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_int_neg_1);
PyTuple_SET_ITEM(__pyx_tuple__12, 0, __pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_tuple__12);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__13);
__Pyx_GIVEREF(__pyx_tuple__13);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__14);
__Pyx_GIVEREF(__pyx_tuple__14);
/* "View.MemoryView":678
* if item is Ellipsis:
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
* seen_ellipsis = True
* else:
*/
__pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) __PYX_ERR(1, 678, __pyx_L1_error)
__Pyx_GOTREF(__pyx_slice__15);
__Pyx_GIVEREF(__pyx_slice__15);
/* "View.MemoryView":699
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 699, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__16);
__Pyx_GIVEREF(__pyx_tuple__16);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__17);
__Pyx_GIVEREF(__pyx_tuple__17);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__18);
__Pyx_GIVEREF(__pyx_tuple__18);
/* "libreco/algorithms/_als.pyx":36
*
*
* def als_update(interaction, X, Y, reg, task, use_cg=True, # <<<<<<<<<<<<<<
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
*/
__pyx_tuple__19 = PyTuple_Pack(8, __pyx_n_s_interaction, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_reg, __pyx_n_s_task, __pyx_n_s_use_cg, __pyx_n_s_num_threads, __pyx_n_s_cg_steps); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__19);
__Pyx_GIVEREF(__pyx_tuple__19);
__pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(8, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_libreco_algorithms__als_pyx, __pyx_n_s_als_update, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 36, __pyx_L1_error)
/* "View.MemoryView":286
* 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__21 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 286, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__21);
__Pyx_GIVEREF(__pyx_tuple__21);
/* "View.MemoryView":287
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__22);
__Pyx_GIVEREF(__pyx_tuple__22);
/* "View.MemoryView":288
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 288, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__23);
__Pyx_GIVEREF(__pyx_tuple__23);
/* "View.MemoryView":291
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(1, 291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__24);
__Pyx_GIVEREF(__pyx_tuple__24);
/* "View.MemoryView":292
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 292, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__25);
__Pyx_GIVEREF(__pyx_tuple__25);
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
__pyx_tuple__26 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__26);
__Pyx_GIVEREF(__pyx_tuple__26);
__pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
/* InitThreads.init */
#ifdef WITH_THREAD
PyEval_InitThreads();
#endif
if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
static int __Pyx_modinit_global_init_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
/*--- 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);
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
/*--- Variable export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
/*--- Function export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_type_init_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
/*--- Type init code ---*/
__pyx_vtabptr_array = &__pyx_vtable_array;
__pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_array.tp_print = 0;
#endif
if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
__pyx_array_type = &__pyx_type___pyx_array;
if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_MemviewEnum.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
__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_ERR(1, 330, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_memoryview.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __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_ERR(1, 961, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_memoryviewslice.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(1, 961, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 961, __pyx_L1_error)
__pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static int __Pyx_modinit_type_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
/*--- Type import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
/*--- Variable import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_import_code(void) {
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
__Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
/*--- Function import code ---*/
__pyx_t_1 = PyImport_ImportModule("scipy.linalg.cython_lapack"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportFunction(__pyx_t_1, "sposv", (void (**)(void))&__pyx_f_5scipy_6linalg_13cython_lapack_sposv, "void (char *, int *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, int *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_2 = PyImport_ImportModule("scipy.linalg.cython_blas"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportFunction(__pyx_t_2, "saxpy", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_saxpy, "void (int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportFunction(__pyx_t_2, "sdot", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_sdot, "__pyx_t_5scipy_6linalg_11cython_blas_s (int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportFunction(__pyx_t_2, "sscal", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_sscal, "void (int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportFunction(__pyx_t_2, "ssymv", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_ssymv, "void (char *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *, __pyx_t_5scipy_6linalg_11cython_blas_s *, __pyx_t_5scipy_6linalg_11cython_blas_s *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_RefNannyFinishContext();
return -1;
}
#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif
#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC init_als(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC init_als(void)
#else
__Pyx_PyMODINIT_FUNC PyInit__als(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit__als(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
#if PY_VERSION_HEX >= 0x030700A1
static PY_INT64_T main_interpreter_id = -1;
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
if (main_interpreter_id == -1) {
main_interpreter_id = current_id;
return (unlikely(current_id == -1)) ? -1 : 0;
} else if (unlikely(main_interpreter_id != current_id))
#else
static PyInterpreterState *main_interpreter = NULL;
PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
if (!main_interpreter) {
main_interpreter = current_interpreter;
} else if (unlikely(main_interpreter != current_interpreter))
#endif
{
PyErr_SetString(
PyExc_ImportError,
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
return -1;
}
return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
PyObject *value = PyObject_GetAttrString(spec, from_name);
int result = 0;
if (likely(value)) {
if (allow_none || value != Py_None) {
result = PyDict_SetItemString(moddict, to_name, value);
}
Py_DECREF(value);
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
} else {
result = -1;
}
return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
PyObject *module = NULL, *moddict, *modname;
if (__Pyx_check_single_interpreter())
return NULL;
if (__pyx_m)
return __Pyx_NewRef(__pyx_m);
modname = PyObject_GetAttrString(spec, "name");
if (unlikely(!modname)) goto bad;
module = PyModule_NewObject(modname);
Py_DECREF(modname);
if (unlikely(!module)) goto bad;
moddict = PyModule_GetDict(module);
if (unlikely(!moddict)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
return module;
bad:
Py_XDECREF(module);
return NULL;
}
static CYTHON_SMALL_CODE int __pyx_pymod_exec__als(PyObject *__pyx_pyinit_module)
#endif
#endif
{
PyObject *__pyx_t_1 = NULL;
static PyThread_type_lock __pyx_t_2[8];
__Pyx_RefNannyDeclarations
#if CYTHON_PEP489_MULTI_PHASE_INIT
if (__pyx_m) {
if (__pyx_m == __pyx_pyinit_module) return 0;
PyErr_SetString(PyExc_RuntimeError, "Module '_als' has already been imported. Re-initialisation is not supported.");
return -1;
}
#elif PY_MAJOR_VERSION >= 3
if (__pyx_m) return __Pyx_NewRef(__pyx_m);
#endif
#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("__Pyx_PyMODINIT_FUNC PyInit__als(void)", 0);
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pxy_PyFrame_Initialize_Offsets
__Pxy_PyFrame_Initialize_Offsets();
#endif
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pyx_CyFunction_USED
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_FusedFunction_USED
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Coroutine_USED
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Generator_USED
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_AsyncGen_USED
if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_StopAsyncIteration_USED
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __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 CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_m = __pyx_pyinit_module;
Py_INCREF(__pyx_m);
#else
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4("_als", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
#else
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_d);
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_b);
__pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_cython_runtime);
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
/*--- Initialize various global constants etc. ---*/
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __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_ERR(0, 1, __pyx_L1_error)
#endif
if (__pyx_module_is_main_libreco__algorithms___als) {
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
}
#if PY_MAJOR_VERSION >= 3
{
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
if (!PyDict_GetItemString(modules, "libreco.algorithms._als")) {
if (unlikely(PyDict_SetItemString(modules, "libreco.algorithms._als", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
}
}
#endif
/*--- Builtin init code ---*/
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Constants init code ---*/
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Global type/function init code ---*/
(void)__Pyx_modinit_global_init_code();
(void)__Pyx_modinit_variable_export_code();
(void)__Pyx_modinit_function_export_code();
if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
(void)__Pyx_modinit_type_import_code();
(void)__Pyx_modinit_variable_import_code();
if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
/*--- Execution code ---*/
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
/* "libreco/algorithms/_als.pyx":1
* import numpy as np # <<<<<<<<<<<<<<
* import cython
* from cython.parallel import parallel, prange
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "libreco/algorithms/_als.pyx":36
*
*
* def als_update(interaction, X, Y, reg, task, use_cg=True, # <<<<<<<<<<<<<<
* num_threads=1, cg_steps=3):
* if task == "rating" and use_cg:
*/
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7libreco_10algorithms_4_als_1als_update, NULL, __pyx_n_s_libreco_algorithms__als); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_als_update, __pyx_t_1) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "libreco/algorithms/_als.pyx":1
* import numpy as np # <<<<<<<<<<<<<<
* import cython
* from cython.parallel import parallel, prange
*/
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":209
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
* def __dealloc__(array self):
*/
__pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 209, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 209, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_array_type);
/* "View.MemoryView":286
* 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_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 286, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XGOTREF(generic);
__Pyx_DECREF_SET(generic, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":287
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XGOTREF(strided);
__Pyx_DECREF_SET(strided, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":288
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 288, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XGOTREF(indirect);
__Pyx_DECREF_SET(indirect, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":291
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XGOTREF(contiguous);
__Pyx_DECREF_SET(contiguous, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":292
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 292, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XGOTREF(indirect_contiguous);
__Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":316
*
* DEF THREAD_LOCKS_PREALLOCATED = 8
* cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<<
* cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
* PyThread_allocate_lock(),
*/
__pyx_memoryview_thread_locks_used = 0;
/* "View.MemoryView":317
* DEF THREAD_LOCKS_PREALLOCATED = 8
* cdef int __pyx_memoryview_thread_locks_used = 0
* cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<<
* PyThread_allocate_lock(),
* PyThread_allocate_lock(),
*/
__pyx_t_2[0] = PyThread_allocate_lock();
__pyx_t_2[1] = PyThread_allocate_lock();
__pyx_t_2[2] = PyThread_allocate_lock();
__pyx_t_2[3] = PyThread_allocate_lock();
__pyx_t_2[4] = PyThread_allocate_lock();
__pyx_t_2[5] = PyThread_allocate_lock();
__pyx_t_2[6] = PyThread_allocate_lock();
__pyx_t_2[7] = PyThread_allocate_lock();
memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
/* "View.MemoryView":545
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 545, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 545, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_memoryview_type);
/* "View.MemoryView":991
* return self.from_object
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 991, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 991, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_memoryviewslice_type);
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
/*--- Wrapped vars code ---*/
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
if (__pyx_m) {
if (__pyx_d) {
__Pyx_AddTraceback("init libreco.algorithms._als", __pyx_clineno, __pyx_lineno, __pyx_filename);
}
Py_CLEAR(__pyx_m);
} else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ImportError, "init libreco.algorithms._als");
}
__pyx_L0:;
__Pyx_RefNannyFinishContext();
#if CYTHON_PEP489_MULTI_PHASE_INIT
return (__pyx_m != NULL) ? 0 : -1;
#elif PY_MAJOR_VERSION >= 3
return __pyx_m;
#else
return;
#endif
}
/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
PyObject *m = NULL, *p = NULL;
void *r = NULL;
m = PyImport_ImportModule(modname);
if (!m) goto end;
p = PyObject_GetAttrString(m, "RefNannyAPI");
if (!p) goto end;
r = PyLong_AsVoidPtr(p);
end:
Py_XDECREF(p);
Py_XDECREF(m);
return (__Pyx_RefNannyAPIStruct *)r;
}
#endif
/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
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);
}
#endif
/* GetBuiltinName */
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;
}
/* RaiseArgTupleInvalid */
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);
}
/* RaiseDoubleKeywords */
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
}
/* ParseKeywords */
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;
}
/* BytesEquals */
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;
#if CYTHON_USE_UNICODE_INTERNALS
Py_hash_t hash1, hash2;
hash1 = ((PyBytesObject*)s1)->ob_shash;
hash2 = ((PyBytesObject*)s2)->ob_shash;
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
return (equals == Py_NE);
}
#endif
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
}
/* UnicodeEquals */
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;
}
#if CYTHON_USE_UNICODE_INTERNALS
{
Py_hash_t hash1, hash2;
#if CYTHON_PEP393_ENABLED
hash1 = ((PyASCIIObject*)s1)->hash;
hash2 = ((PyASCIIObject*)s2)->hash;
#else
hash1 = ((PyUnicodeObject*)s1)->hash;
hash2 = ((PyUnicodeObject*)s2)->hash;
#endif
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
goto return_ne;
}
}
#endif
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_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
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
}
/* MemviewSliceInit */
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 (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;
}
#ifndef Py_NO_RETURN
#define Py_NO_RETURN
#endif
static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
va_list vargs;
char msg[200];
#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, fmt);
#else
va_start(vargs);
#endif
vsnprintf(msg, 200, fmt, vargs);
va_end(vargs);
Py_FatalError(msg);
}
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;
}
}
/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
PyObject **dictptr = NULL;
Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
dictptr = _PyObject_GetDictPtr(obj);
#endif
}
return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
return 0;
return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif
/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
} else if (unlikely(PyErr_Occurred())) {
return NULL;
}
#else
result = PyDict_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
#endif
#else
result = PyObject_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
PyErr_Clear();
#endif
return __Pyx_GetBuiltinName(name);
}
/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
int flags = PyCFunction_GET_FLAGS(func);
assert(PyCFunction_Check(func));
assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
assert(nargs >= 0);
assert(nargs == 0 || args != NULL);
/* _PyCFunction_FastCallDict() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the
caller loses its exception */
assert(!PyErr_Occurred());
if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
} else {
return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
}
}
#endif
/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
PyObject *globals) {
PyFrameObject *f;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
PyObject **fastlocals;
Py_ssize_t i;
PyObject *result;
assert(globals != NULL);
/* XXX Perhaps we should create a specialized
PyFrame_New() that doesn't take locals, but does
take builtins without sanity checking them.
*/
assert(tstate != NULL);
f = PyFrame_New(tstate, co, globals, NULL);
if (f == NULL) {
return NULL;
}
fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
for (i = 0; i < na; i++) {
Py_INCREF(*args);
fastlocals[i] = *args++;
}
result = PyEval_EvalFrameEx(f,0);
++tstate->recursion_depth;
Py_DECREF(f);
--tstate->recursion_depth;
return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
PyObject *globals = PyFunction_GET_GLOBALS(func);
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
PyObject *closure;
#if PY_MAJOR_VERSION >= 3
PyObject *kwdefs;
#endif
PyObject *kwtuple, **k;
PyObject **d;
Py_ssize_t nd;
Py_ssize_t nk;
PyObject *result;
assert(kwargs == NULL || PyDict_Check(kwargs));
nk = kwargs ? PyDict_Size(kwargs) : 0;
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
return NULL;
}
if (
#if PY_MAJOR_VERSION >= 3
co->co_kwonlyargcount == 0 &&
#endif
likely(kwargs == NULL || nk == 0) &&
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
if (argdefs == NULL && co->co_argcount == nargs) {
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
goto done;
}
else if (nargs == 0 && argdefs != NULL
&& co->co_argcount == Py_SIZE(argdefs)) {
/* function called with no arguments, but all parameters have
a default value: use default values as arguments .*/
args = &PyTuple_GET_ITEM(argdefs, 0);
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
goto done;
}
}
if (kwargs != NULL) {
Py_ssize_t pos, i;
kwtuple = PyTuple_New(2 * nk);
if (kwtuple == NULL) {
result = NULL;
goto done;
}
k = &PyTuple_GET_ITEM(kwtuple, 0);
pos = i = 0;
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
Py_INCREF(k[i]);
Py_INCREF(k[i+1]);
i += 2;
}
nk = i / 2;
}
else {
kwtuple = NULL;
k = NULL;
}
closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
if (argdefs != NULL) {
d = &PyTuple_GET_ITEM(argdefs, 0);
nd = Py_SIZE(argdefs);
}
else {
d = NULL;
nd = 0;
}
#if PY_MAJOR_VERSION >= 3
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
args, nargs,
k, (int)nk,
d, (int)nd, kwdefs, closure);
#else
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
args, nargs,
k, (int)nk,
d, (int)nd, closure);
#endif
Py_XDECREF(kwtuple);
done:
Py_LeaveRecursiveCall();
return result;
}
#endif
#endif
/* PyObjectCall */
#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
/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
PyObject *args, *result = NULL;
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(function)) {
PyObject *args[2] = {arg1, arg2};
return __Pyx_PyFunction_FastCall(function, args, 2);
}
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(function)) {
PyObject *args[2] = {arg1, arg2};
return __Pyx_PyCFunction_FastCall(function, args, 2);
}
#endif
args = PyTuple_New(2);
if (unlikely(!args)) goto done;
Py_INCREF(arg1);
PyTuple_SET_ITEM(args, 0, arg1);
Py_INCREF(arg2);
PyTuple_SET_ITEM(args, 1, arg2);
Py_INCREF(function);
result = __Pyx_PyObject_Call(function, args, NULL);
Py_DECREF(args);
Py_DECREF(function);
done:
return result;
}
/* PyObjectCallMethO */
#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
/* PyObjectCallOneArg */
#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) {
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(func)) {
return __Pyx_PyFunction_FastCall(func, &arg, 1);
}
#endif
if (likely(PyCFunction_Check(func))) {
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
} else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
}
}
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
/* CIntToDigits */
static const char DIGIT_PAIRS_10[2*10*10+1] = {
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"
"70717273747576777879"
"80818283848586878889"
"90919293949596979899"
};
static const char DIGIT_PAIRS_8[2*8*8+1] = {
"0001020304050607"
"1011121314151617"
"2021222324252627"
"3031323334353637"
"4041424344454647"
"5051525354555657"
"6061626364656667"
"7071727374757677"
};
static const char DIGITS_HEX[2*16+1] = {
"0123456789abcdef"
"0123456789ABCDEF"
};
/* BuildPyUnicode */
static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
int prepend_sign, char padding_char) {
PyObject *uval;
Py_ssize_t uoffset = ulength - clength;
#if CYTHON_USE_UNICODE_INTERNALS
Py_ssize_t i;
#if CYTHON_PEP393_ENABLED
void *udata;
uval = PyUnicode_New(ulength, 127);
if (unlikely(!uval)) return NULL;
udata = PyUnicode_DATA(uval);
#else
Py_UNICODE *udata;
uval = PyUnicode_FromUnicode(NULL, ulength);
if (unlikely(!uval)) return NULL;
udata = PyUnicode_AS_UNICODE(uval);
#endif
if (uoffset > 0) {
i = 0;
if (prepend_sign) {
__Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
i++;
}
for (; i < uoffset; i++) {
__Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
}
}
for (i=0; i < clength; i++) {
__Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
}
#else
{
PyObject *sign = NULL, *padding = NULL;
uval = NULL;
if (uoffset > 0) {
prepend_sign = !!prepend_sign;
if (uoffset > prepend_sign) {
padding = PyUnicode_FromOrdinal(padding_char);
if (likely(padding) && uoffset > prepend_sign + 1) {
PyObject *tmp;
PyObject *repeat = PyInt_FromSize_t(uoffset - prepend_sign);
if (unlikely(!repeat)) goto done_or_error;
tmp = PyNumber_Multiply(padding, repeat);
Py_DECREF(repeat);
Py_DECREF(padding);
padding = tmp;
}
if (unlikely(!padding)) goto done_or_error;
}
if (prepend_sign) {
sign = PyUnicode_FromOrdinal('-');
if (unlikely(!sign)) goto done_or_error;
}
}
uval = PyUnicode_DecodeASCII(chars, clength, NULL);
if (likely(uval) && padding) {
PyObject *tmp = PyNumber_Add(padding, uval);
Py_DECREF(uval);
uval = tmp;
}
if (likely(uval) && sign) {
PyObject *tmp = PyNumber_Add(sign, uval);
Py_DECREF(uval);
uval = tmp;
}
done_or_error:
Py_XDECREF(padding);
Py_XDECREF(sign);
}
#endif
return uval;
}
/* CIntToPyUnicode */
#ifdef _MSC_VER
#ifndef _MSC_STDINT_H_
#if _MSC_VER < 1300
typedef unsigned short uint16_t;
#else
typedef unsigned __int16 uint16_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define GCC_DIAGNOSTIC
#endif
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char) {
char digits[sizeof(int)*3+2];
char *dpos, *end = digits + sizeof(int)*3+2;
const char *hex_digits = DIGITS_HEX;
Py_ssize_t length, ulength;
int prepend_sign, last_one_off;
int remaining;
#ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;
if (format_char == 'X') {
hex_digits += 16;
format_char = 'x';
}
remaining = value;
last_one_off = 0;
dpos = end;
do {
int digit_pos;
switch (format_char) {
case 'o':
digit_pos = abs((int)(remaining % (8*8)));
remaining = (int) (remaining / (8*8));
dpos -= 2;
*(uint16_t*)dpos = ((const uint16_t*)DIGIT_PAIRS_8)[digit_pos];
last_one_off = (digit_pos < 8);
break;
case 'd':
digit_pos = abs((int)(remaining % (10*10)));
remaining = (int) (remaining / (10*10));
dpos -= 2;
*(uint16_t*)dpos = ((const uint16_t*)DIGIT_PAIRS_10)[digit_pos];
last_one_off = (digit_pos < 10);
break;
case 'x':
*(--dpos) = hex_digits[abs((int)(remaining % 16))];
remaining = (int) (remaining / 16);
break;
default:
assert(0);
break;
}
} while (unlikely(remaining != 0));
if (last_one_off) {
assert(*dpos == '0');
dpos++;
}
length = end - dpos;
ulength = length;
prepend_sign = 0;
if (!is_unsigned && value <= neg_one) {
if (padding_char == ' ' || width <= length + 1) {
*(--dpos) = '-';
++length;
} else {
prepend_sign = 1;
}
++ulength;
}
if (width > ulength) {
ulength = width;
}
if (ulength == 1) {
return PyUnicode_FromOrdinal(*dpos);
}
return __Pyx_PyUnicode_BuildFromAscii(ulength, dpos, (int) length, prepend_sign, padding_char);
}
/* JoinPyUnicode */
static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
CYTHON_UNUSED Py_UCS4 max_char) {
#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
PyObject *result_uval;
int result_ukind;
Py_ssize_t i, char_pos;
void *result_udata;
#if CYTHON_PEP393_ENABLED
result_uval = PyUnicode_New(result_ulength, max_char);
if (unlikely(!result_uval)) return NULL;
result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
result_udata = PyUnicode_DATA(result_uval);
#else
result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
if (unlikely(!result_uval)) return NULL;
result_ukind = sizeof(Py_UNICODE);
result_udata = PyUnicode_AS_UNICODE(result_uval);
#endif
char_pos = 0;
for (i=0; i < value_count; i++) {
int ukind;
Py_ssize_t ulength;
void *udata;
PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
if (unlikely(__Pyx_PyUnicode_READY(uval)))
goto bad;
ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
if (unlikely(!ulength))
continue;
if (unlikely(char_pos + ulength < 0))
goto overflow;
ukind = __Pyx_PyUnicode_KIND(uval);
udata = __Pyx_PyUnicode_DATA(uval);
if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
} else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
_PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
#else
Py_ssize_t j;
for (j=0; j < ulength; j++) {
Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
__Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
}
#endif
}
char_pos += ulength;
}
return result_uval;
overflow:
PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
bad:
Py_DECREF(result_uval);
return NULL;
#else
result_ulength++;
value_count++;
return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
#endif
}
/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
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);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
*type = tstate->curexc_type;
*value = tstate->curexc_value;
*tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
}
#endif
/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
CYTHON_UNUSED PyObject *cause) {
__Pyx_PyThreadState_declare
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_PyThreadState_assign
__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 (cause) {
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 = __Pyx_PyThreadState_Current;
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
/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
PyObject *tmp_type, *tmp_value, *tmp_tb;
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_FAST_THREAD_STATE
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_FAST_THREAD_STATE
#if CYTHON_USE_EXC_INFO_STACK
{
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = local_type;
exc_info->exc_value = local_value;
exc_info->exc_traceback = local_tb;
}
#else
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;
#endif
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;
}
/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = *type;
exc_info->exc_value = *value;
exc_info->exc_traceback = *tb;
#else
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;
#endif
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
PyErr_SetExcInfo(*type, *value, *tb);
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
}
#endif
/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
_PyErr_StackItem *exc_info = tstate->exc_info;
while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
exc_info->previous_item != NULL)
{
exc_info = exc_info->previous_item;
}
return exc_info;
}
#endif
/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
*type = exc_info->exc_type;
*value = exc_info->exc_value;
*tb = exc_info->exc_traceback;
#else
*type = tstate->exc_type;
*value = tstate->exc_value;
*tb = tstate->exc_traceback;
#endif
Py_XINCREF(*type);
Py_XINCREF(*value);
Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = type;
exc_info->exc_value = value;
exc_info->exc_traceback = tb;
#else
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;
#endif
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
}
#endif
/* WriteUnraisableException */
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;
__Pyx_PyThreadState_declare
#ifdef WITH_THREAD
PyGILState_STATE state;
if (nogil)
state = PyGILState_Ensure();
#ifdef _MSC_VER
else state = (PyGILState_STATE)-1;
#endif
#endif
__Pyx_PyThreadState_assign
__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
}
/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
else if (exact) {
#if PY_MAJOR_VERSION == 2
if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
#endif
}
else {
if (likely(__Pyx_TypeCheck(obj, type))) return 1;
}
PyErr_Format(PyExc_TypeError,
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
name, type->tp_name, Py_TYPE(obj)->tp_name);
return 0;
}
/* None */
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;
}
/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#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);
}
/* GetItemInt */
static 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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyList_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyTuple_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if ((!boundscheck) || (likely(__Pyx_is_valid_index(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(__Pyx_is_valid_index(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))
return NULL;
PyErr_Clear();
}
}
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));
}
/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
PyObject *runerr;
Py_ssize_t key_value;
PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
if (unlikely(!(m && m->sq_item))) {
PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
return NULL;
}
key_value = __Pyx_PyIndex_AsSsize_t(index);
if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
}
if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
PyErr_Clear();
PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
}
return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
if (likely(m && m->mp_subscript)) {
return m->mp_subscript(obj, key);
}
return __Pyx_PyObject_GetIndex(obj, key);
}
#endif
/* decode_c_string */
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);
}
}
/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
Py_ssize_t i, n;
n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
for (i=0; i<n; i++) {
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
}
#endif
for (i=0; i<n; i++) {
if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
}
return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
PyObject *exc_type = tstate->curexc_type;
if (exc_type == err) return 1;
if (unlikely(!exc_type)) return 0;
if (unlikely(PyTuple_Check(err)))
return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif
/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
return NULL;
__Pyx_PyErr_Clear();
Py_INCREF(d);
return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
PyObject *r = __Pyx_GetAttr(o, n);
return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}
/* RaiseTooManyValuesToUnpack */
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);
}
/* RaiseNeedMoreValuesToUnpack */
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");
}
/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}
/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (likely(__Pyx_TypeCheck(obj, type)))
return 1;
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
Py_TYPE(obj)->tp_name, type->tp_name);
return 0;
}
/* Import */
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_MAJOR_VERSION < 3
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, '.')) {
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, 1);
if (!module) {
if (!PyErr_ExceptionMatches(PyExc_ImportError))
goto bad;
PyErr_Clear();
}
}
level = 0;
}
#endif
if (!module) {
#if PY_MAJOR_VERSION < 3
PyObject *py_level = PyInt_FromLong(level);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
Py_DECREF(py_level);
#else
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, level);
#endif
}
}
bad:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(py_import);
#endif
Py_XDECREF(empty_list);
Py_XDECREF(empty_dict);
return module;
}
/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
while (a) {
a = a->tp_base;
if (a == b)
return 1;
}
return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
PyObject *mro;
if (a == b) return 1;
mro = a->tp_mro;
if (likely(mro)) {
Py_ssize_t i, n;
n = PyTuple_GET_SIZE(mro);
for (i = 0; i < n; i++) {
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
return 1;
}
return 0;
}
return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
PyObject *exception, *value, *tb;
int res;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ErrFetch(&exception, &value, &tb);
res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
if (!res) {
res = PyObject_IsSubclass(err, exc_type2);
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
}
__Pyx_ErrRestore(exception, value, tb);
return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
if (!res) {
res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
}
return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
Py_ssize_t i, n;
assert(PyExceptionClass_Check(exc_type));
n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
for (i=0; i<n; i++) {
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
}
#endif
for (i=0; i<n; i++) {
PyObject *t = PyTuple_GET_ITEM(tuple, i);
#if PY_MAJOR_VERSION < 3
if (likely(exc_type == t)) return 1;
#endif
if (likely(PyExceptionClass_Check(t))) {
if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
} else {
}
}
return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
if (likely(err == exc_type)) return 1;
if (likely(PyExceptionClass_Check(err))) {
if (likely(PyExceptionClass_Check(exc_type))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
} else if (likely(PyTuple_Check(exc_type))) {
return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
} else {
}
}
return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
assert(PyExceptionClass_Check(exc_type1));
assert(PyExceptionClass_Check(exc_type2));
if (likely(err == exc_type1 || err == exc_type2)) return 1;
if (likely(PyExceptionClass_Check(err))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
}
return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif
/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
(void)inplace;
(void)zerodivision_check;
#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
if (likely(PyLong_CheckExact(op1))) {
const long b = intval;
long a, x;
#ifdef HAVE_LONG_LONG
const PY_LONG_LONG llb = intval;
PY_LONG_LONG lla, llx;
#endif
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;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
case 2:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
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;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
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;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
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;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
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;
#ifdef HAVE_LONG_LONG
} 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;
#endif
}
CYTHON_FALLTHROUGH;
default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
}
}
x = a + b;
return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
long_long:
llx = lla + llb;
return PyLong_FromLongLong(llx);
#endif
}
#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
/* None */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}
/* None */
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;
}
/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Format(PyExc_ImportError,
#if PY_MAJOR_VERSION < 3
"cannot import name %.230s", PyString_AS_STRING(name));
#else
"cannot import name %S", name);
#endif
}
return value;
}
/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
PyObject *r;
if (unlikely(!__Pyx_PyBaseString_Check(n))) {
PyErr_SetString(PyExc_TypeError,
"hasattr(): attribute name must be string");
return -1;
}
r = __Pyx_GetAttr(o, n);
if (unlikely(!r)) {
PyErr_Clear();
return 0;
} else {
Py_DECREF(r);
return 1;
}
}
/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
"'%.50s' object has no attribute '%U'",
tp->tp_name, attr_name);
#else
"'%.50s' object has no attribute '%.400s'",
tp->tp_name, PyString_AS_STRING(attr_name));
#endif
return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
PyObject *descr;
PyTypeObject *tp = Py_TYPE(obj);
if (unlikely(!PyString_Check(attr_name))) {
return PyObject_GenericGetAttr(obj, attr_name);
}
assert(!tp->tp_dictoffset);
descr = _PyType_Lookup(tp, attr_name);
if (unlikely(!descr)) {
return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
}
Py_INCREF(descr);
#if PY_MAJOR_VERSION < 3
if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
#endif
{
descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
if (unlikely(f)) {
PyObject *res = f(descr, obj, (PyObject *)tp);
Py_DECREF(descr);
return res;
}
}
return descr;
}
#endif
/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
return PyObject_GenericGetAttr(obj, attr_name);
}
return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif
/* SetVTable */
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;
}
/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
int ret;
PyObject *name_attr;
name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
if (likely(name_attr)) {
ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
} else {
ret = -1;
}
if (unlikely(ret < 0)) {
PyErr_Clear();
ret = 0;
}
Py_XDECREF(name_attr);
return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
int ret = 0;
PyObject *object_reduce = NULL;
PyObject *object_reduce_ex = NULL;
PyObject *reduce = NULL;
PyObject *reduce_ex = NULL;
PyObject *reduce_cython = NULL;
PyObject *setstate = NULL;
PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
if (!setstate) PyErr_Clear();
if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
}
PyType_Modified((PyTypeObject*)type_obj);
}
}
goto GOOD;
BAD:
if (!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
Py_XDECREF(object_reduce);
Py_XDECREF(object_reduce_ex);
#endif
Py_XDECREF(reduce);
Py_XDECREF(reduce_ex);
Py_XDECREF(reduce_cython);
Py_XDECREF(setstate);
Py_XDECREF(setstate_cython);
return ret;
}
/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
PyObject *use_cline;
PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject **cython_runtime_dict;
#endif
if (unlikely(!__pyx_cython_runtime)) {
return c_line;
}
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
if (likely(cython_runtime_dict)) {
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
use_cline, *cython_runtime_dict,
__Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
} else
#endif
{
PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
if (use_cline_obj) {
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
Py_DECREF(use_cline_obj);
} else {
PyErr_Clear();
use_cline = NULL;
}
}
if (!use_cline) {
c_line = 0;
PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
}
else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
c_line = 0;
}
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
return c_line;
}
#endif
/* CodeObjectCache */
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);
}
/* AddTraceback */
#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;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
if (c_line) {
c_line = __Pyx_CLineForTraceback(tstate, c_line);
}
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(
tstate, /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
__pyx_d, /*PyObject *globals,*/
0 /*PyObject *locals*/
);
if (!py_frame) goto bad;
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
PyTraceBack_Here(py_frame);
bad:
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
}
#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 (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
if (__Pyx_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;
}
if ((0)) {}
view->obj = NULL;
Py_DECREF(obj);
}
#endif
/* MemviewSliceIsContig */
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;
}
/* OverlappingSlices */
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);
}
/* Capsule */
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;
}
/* CIntFromPyVerify */
#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;\
}
/* MemviewDtypeToObject */
static CYTHON_INLINE PyObject *__pyx_memview_get_float(const char *itemp) {
return (PyObject *) PyFloat_FromDouble(*(float *) itemp);
}
static CYTHON_INLINE int __pyx_memview_set_float(const char *itemp, PyObject *obj) {
float value = __pyx_PyFloat_AsFloat(obj);
if ((value == (float)-1) && PyErr_Occurred())
return 0;
*(float *) itemp = value;
return 1;
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
const int neg_one = (int) ((int) 0 - (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);
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(int) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int),
little, !is_unsigned);
}
}
/* Declarations */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
return ::std::complex< float >(x, y);
}
#else
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
return x + y*(__pyx_t_float_complex)_Complex_I;
}
#endif
#else
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
__pyx_t_float_complex z;
z.real = x;
z.imag = y;
return z;
}
#endif
/* Arithmetic */
#if CYTHON_CCOMPLEX
#else
static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
return (a.real == b.real) && (a.imag == b.imag);
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real + b.real;
z.imag = a.imag + b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real - b.real;
z.imag = a.imag - b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real * b.real - a.imag * b.imag;
z.imag = a.real * b.imag + a.imag * b.real;
return z;
}
#if 1
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
if (b.imag == 0) {
return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
} else if (fabsf(b.real) >= fabsf(b.imag)) {
if (b.real == 0 && b.imag == 0) {
return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
} else {
float r = b.imag / b.real;
float s = (float)(1.0) / (b.real + b.imag * r);
return __pyx_t_float_complex_from_parts(
(a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
}
} else {
float r = b.real / b.imag;
float s = (float)(1.0) / (b.imag + b.real * r);
return __pyx_t_float_complex_from_parts(
(a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
}
}
#else
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
if (b.imag == 0) {
return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
} else {
float denom = b.real * b.real + b.imag * b.imag;
return __pyx_t_float_complex_from_parts(
(a.real * b.real + a.imag * b.imag) / denom,
(a.imag * b.real - a.real * b.imag) / denom);
}
}
#endif
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
__pyx_t_float_complex z;
z.real = -a.real;
z.imag = -a.imag;
return z;
}
static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
return (a.real == 0) && (a.imag == 0);
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
__pyx_t_float_complex z;
z.real = a.real;
z.imag = -a.imag;
return z;
}
#if 1
static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
#if !defined(HAVE_HYPOT) || defined(_MSC_VER)
return sqrtf(z.real*z.real + z.imag*z.imag);
#else
return hypotf(z.real, z.imag);
#endif
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
float r, lnr, theta, z_r, z_theta;
if (b.imag == 0 && b.real == (int)b.real) {
if (b.real < 0) {
float denom = a.real * a.real + a.imag * a.imag;
a.real = a.real / denom;
a.imag = -a.imag / denom;
b.real = -b.real;
}
switch ((int)b.real) {
case 0:
z.real = 1;
z.imag = 0;
return z;
case 1:
return a;
case 2:
z = __Pyx_c_prod_float(a, a);
return __Pyx_c_prod_float(a, a);
case 3:
z = __Pyx_c_prod_float(a, a);
return __Pyx_c_prod_float(z, a);
case 4:
z = __Pyx_c_prod_float(a, a);
return __Pyx_c_prod_float(z, z);
}
}
if (a.imag == 0) {
if (a.real == 0) {
return a;
} else if (b.imag == 0) {
z.real = powf(a.real, b.real);
z.imag = 0;
return z;
} else if (a.real > 0) {
r = a.real;
theta = 0;
} else {
r = -a.real;
theta = atan2f(0.0, -1.0);
}
} else {
r = __Pyx_c_abs_float(a);
theta = atan2f(a.imag, a.real);
}
lnr = logf(r);
z_r = expf(lnr * b.real - theta * b.imag);
z_theta = theta * b.real + lnr * b.imag;
z.real = z_r * cosf(z_theta);
z.imag = z_r * sinf(z_theta);
return z;
}
#endif
#endif
/* Declarations */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
return ::std::complex< double >(x, y);
}
#else
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
return x + y*(__pyx_t_double_complex)_Complex_I;
}
#endif
#else
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
__pyx_t_double_complex z;
z.real = x;
z.imag = y;
return z;
}
#endif
/* Arithmetic */
#if CYTHON_CCOMPLEX
#else
static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
return (a.real == b.real) && (a.imag == b.imag);
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real + b.real;
z.imag = a.imag + b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real - b.real;
z.imag = a.imag - b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real * b.real - a.imag * b.imag;
z.imag = a.real * b.imag + a.imag * b.real;
return z;
}
#if 1
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
if (b.imag == 0) {
return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
} else if (fabs(b.real) >= fabs(b.imag)) {
if (b.real == 0 && b.imag == 0) {
return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
} else {
double r = b.imag / b.real;
double s = (double)(1.0) / (b.real + b.imag * r);
return __pyx_t_double_complex_from_parts(
(a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
}
} else {
double r = b.real / b.imag;
double s = (double)(1.0) / (b.imag + b.real * r);
return __pyx_t_double_complex_from_parts(
(a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
}
}
#else
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
if (b.imag == 0) {
return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
} else {
double denom = b.real * b.real + b.imag * b.imag;
return __pyx_t_double_complex_from_parts(
(a.real * b.real + a.imag * b.imag) / denom,
(a.imag * b.real - a.real * b.imag) / denom);
}
}
#endif
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
__pyx_t_double_complex z;
z.real = -a.real;
z.imag = -a.imag;
return z;
}
static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
return (a.real == 0) && (a.imag == 0);
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
__pyx_t_double_complex z;
z.real = a.real;
z.imag = -a.imag;
return z;
}
#if 1
static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
#if !defined(HAVE_HYPOT) || defined(_MSC_VER)
return sqrt(z.real*z.real + z.imag*z.imag);
#else
return hypot(z.real, z.imag);
#endif
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
double r, lnr, theta, z_r, z_theta;
if (b.imag == 0 && b.real == (int)b.real) {
if (b.real < 0) {
double denom = a.real * a.real + a.imag * a.imag;
a.real = a.real / denom;
a.imag = -a.imag / denom;
b.real = -b.real;
}
switch ((int)b.real) {
case 0:
z.real = 1;
z.imag = 0;
return z;
case 1:
return a;
case 2:
z = __Pyx_c_prod_double(a, a);
return __Pyx_c_prod_double(a, a);
case 3:
z = __Pyx_c_prod_double(a, a);
return __Pyx_c_prod_double(z, a);
case 4:
z = __Pyx_c_prod_double(a, a);
return __Pyx_c_prod_double(z, z);
}
}
if (a.imag == 0) {
if (a.real == 0) {
return a;
} else if (b.imag == 0) {
z.real = pow(a.real, b.real);
z.imag = 0;
return z;
} else if (a.real > 0) {
r = a.real;
theta = 0;
} else {
r = -a.real;
theta = atan2(0.0, -1.0);
}
} else {
r = __Pyx_c_abs_double(a);
theta = atan2(a.imag, a.real);
}
lnr = log(r);
z_r = exp(lnr * b.real - theta * b.imag);
z_theta = theta * b.real + lnr * b.imag;
z.real = z_r * cos(z_theta);
z.imag = z_r * sin(z_theta);
return z;
}
#endif
#endif
/* MemviewSliceCopyTemplate */
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;
}
/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
const int neg_one = (int) ((int) 0 - (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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} 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) (-(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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#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_IntOrLong(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_IntOrLong(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;
}
/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
const long neg_one = (long) ((long) 0 - (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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} 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) (-(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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#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_IntOrLong(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_IntOrLong(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;
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
const long neg_one = (long) ((long) 0 - (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);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(long) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(long),
little, !is_unsigned);
}
}
/* CIntFromPy */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
const char neg_one = (char) ((char) 0 - (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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} 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) (-(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))
#ifdef HAVE_LONG_LONG
} else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#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_IntOrLong(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_IntOrLong(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;
}
/* IsLittleEndian */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
union {
uint32_t u32;
uint8_t u8[4];
} S;
S.u32 = 0x01020304;
return S.u8[0] == 4;
}
/* BufferFormatCheck */
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 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_Is_Little_Endian()) {
PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
return NULL;
}
ctx->new_packmode = '=';
++ts;
break;
case '>':
case '!':
if (__Pyx_Is_Little_Endian()) {
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;
}
CYTHON_FALLTHROUGH;
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;
}
CYTHON_FALLTHROUGH;
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;
}
}
}
}
/* TypeInfoCompare */
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;
}
/* MemviewSliceValidateAndInit */
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[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;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int__const__(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_int__const__, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float__const__(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_float__const__, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__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) | writable_flag, 2,
&__Pyx_TypeInfo_float, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_float(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_float, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* CheckBinaryVersion */
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;
}
/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
PyObject *d = 0;
PyObject *cobj = 0;
union {
void (*fp)(void);
void *p;
} tmp;
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
if (!d)
goto bad;
cobj = PyDict_GetItemString(d, funcname);
if (!cobj) {
PyErr_Format(PyExc_ImportError,
"%.200s does not export expected C function %.200s",
PyModule_GetName(module), funcname);
goto bad;
}
#if PY_VERSION_HEX >= 0x02070000
if (!PyCapsule_IsValid(cobj, sig)) {
PyErr_Format(PyExc_TypeError,
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
goto bad;
}
tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
{const char *desc, *s1, *s2;
desc = (const char *)PyCObject_GetDesc(cobj);
if (!desc)
goto bad;
s1 = desc; s2 = sig;
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
if (*s1 != *s2) {
PyErr_Format(PyExc_TypeError,
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
PyModule_GetName(module), funcname, sig, desc);
goto bad;
}
tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
*f = tmp.fp;
if (!(*f))
goto bad;
Py_DECREF(d);
return 0;
bad:
Py_XDECREF(d);
return -1;
}
#endif
/* InitStrings */
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;
if (PyObject_Hash(*t->p) == -1)
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 const char* __Pyx_PyObject_AsString(PyObject* o) {
Py_ssize_t ignore;
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
if (likely(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
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __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)) {
return __Pyx_PyUnicode_AsStringAndSize(o, length);
} 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 int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
int retval;
if (unlikely(!x)) return -1;
retval = __Pyx_PyObject_IsTrue(x);
Py_DECREF(x);
return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
if (PyLong_Check(result)) {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"__int__ returned non-int (type %.200s). "
"The ability to return an instance of a strict subclass of int "
"is deprecated, and may be removed in a future version of Python.",
Py_TYPE(result)->tp_name)) {
Py_DECREF(result);
return NULL;
}
return result;
}
#endif
PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)",
type_name, type_name, Py_TYPE(result)->tp_name);
Py_DECREF(result);
return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
PyNumberMethods *m;
#endif
const char *name = NULL;
PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
if (likely(PyLong_Check(x)))
#endif
return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
if (m && m->nb_int) {
name = "int";
res = m->nb_int(x);
}
else if (m && m->nb_long) {
name = "long";
res = m->nb_long(x);
}
#else
if (likely(m && m->nb_int)) {
name = "int";
res = m->nb_int(x);
}
#endif
#else
if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
res = PyNumber_Int(x);
}
#endif
if (likely(res)) {
#if PY_MAJOR_VERSION < 3
if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
if (unlikely(!PyLong_CheckExact(res))) {
#endif
return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
}
}
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(b);
}
#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_PyBool_FromLong(long b) {
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return PyInt_FromSize_t(ival);
}
#endif /* Py_PYTHON_H */
|
#pragma once
#include "../util/screen.hpp"
class SkyDome : public rs::util::PostEffect {
public:
SkyDome(rs::Priority p);
//! 仮想スカイドームの距離計算で使用(X=大気の横幅反比, Y=大気の厚さ)
void setScale(float w, float h);
//! 仮想スカイドームの補正比率
void setDivide(float d);
//! レイリー散乱係数
void setRayleighCoeff(const spn::Vec3& r);
//! ミー散乱係数
void setMieCoeff(float gain, float c);
//! ミー散乱の入射角度に対する係数
void setLightPower(float p);
//! 全体の光量補正値
void setLightDir(const spn::Vec3& dir);
//! 太陽の方向
void setLightColor(const spn::Vec3& c);
void onDraw(rs::IEffect& e) const override;
};
DEF_LUAIMPORT(SkyDome)
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x2187, %r8
cmp $65342, %rbp
movw $0x6162, (%r8)
nop
nop
nop
nop
nop
and %r8, %r8
lea addresses_A_ht+0xfdb, %rsi
lea addresses_UC_ht+0x12c6b, %rdi
nop
nop
nop
nop
add %r13, %r13
mov $119, %rcx
rep movsw
nop
add $57844, %rsi
lea addresses_WC_ht+0xa4db, %rbp
nop
inc %rbx
movb $0x61, (%rbp)
nop
nop
nop
nop
nop
and $47492, %rcx
lea addresses_WT_ht+0x18a9b, %rsi
lea addresses_A_ht+0x1b8ab, %rdi
nop
add %r14, %r14
mov $11, %rcx
rep movsl
sub %rbp, %rbp
lea addresses_A_ht+0x1ab9b, %rcx
nop
nop
nop
nop
nop
cmp %rbp, %rbp
movb $0x61, (%rcx)
nop
nop
nop
nop
inc %rsi
lea addresses_A_ht+0x1b379, %rbx
nop
nop
nop
sub $29900, %r13
mov $0x6162636465666768, %rbp
movq %rbp, %xmm5
vmovups %ymm5, (%rbx)
xor %rsi, %rsi
lea addresses_D_ht+0xaadb, %r8
clflush (%r8)
nop
and $7641, %r13
mov (%r8), %di
nop
nop
xor %rbp, %rbp
lea addresses_WC_ht+0x18c61, %rsi
lea addresses_WC_ht+0x6bd, %rdi
nop
cmp $775, %r8
mov $116, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %rbp
lea addresses_WT_ht+0x10cbd, %r8
nop
nop
add $27577, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
vmovups %ymm6, (%r8)
nop
nop
add %rcx, %rcx
lea addresses_normal_ht+0x76b7, %rbx
nop
sub $50300, %r8
movb $0x61, (%rbx)
nop
nop
nop
nop
and %r14, %r14
lea addresses_WC_ht+0x1c9db, %r13
nop
nop
nop
nop
nop
inc %rsi
vmovups (%r13), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %rcx
nop
nop
nop
nop
xor %rdi, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r9
push %rax
push %rcx
push %rdx
push %rsi
// Store
mov $0x4d7ea0000000a5b, %r15
nop
nop
nop
add $15901, %rax
mov $0x5152535455565758, %rsi
movq %rsi, (%r15)
add %r9, %r9
// Store
lea addresses_US+0x8bdb, %r15
nop
nop
nop
nop
nop
cmp $50687, %rcx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm0
movups %xmm0, (%r15)
nop
sub %rsi, %rsi
// Faulty Load
mov $0x47521a00000000db, %rdx
clflush (%rdx)
nop
nop
nop
nop
cmp $15084, %r12
movb (%rdx), %r15b
lea oracles, %rcx
and $0xff, %r15
shlq $12, %r15
mov (%rcx,%r15,1), %r15
pop %rsi
pop %rdx
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': True, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
#include "visit_context.hpp"
#include <kdb.hpp>
#include <iostream>
class CountryAustriaLayer : public kdb::Layer
{
public:
std::string id() const { return "country"; }
std::string operator()() const { return "Austria"; }
};
class LanguageGermanLayer : public kdb::Layer
{
public:
std::string id() const override
{
return "language";
}
std::string operator()() const override
{
return "german";
}
};
class ProfileLayer : public kdb::Layer
{
public:
ProfileLayer(kdb::visit::Profile const & profile) :
m_profile(profile) {}
std::string id() const { return "profile"; }
std::string operator()() const { return m_profile; }
private:
kdb::visit::Profile const & m_profile;
};
//{end}
/*
//{layer/profileOld}
class ProfileLayer : public kdb::Layer
{
public:
ProfileLayer(kdb::String const & profile) :
m_profile(profile) {}
std::string id() const override
{ return "profile"; }
std::string operator()() const override
{ return m_profile; }
private:
std::string m_profile;
};
//{end}
*/
// application: e.g. git-pull, git-push
//{application}
class MainApplicationLayer : public kdb::Layer
{
public:
std::string id() const override
{ return "application"; }
std::string operator()() const override
{ return "main"; }
};
void visit(kdb::visit::Person & p) {
p.context().with<CountryAustriaLayer>()
.with<LanguageGermanLayer>()([&] {
std::cout << "visit " << ++p.visits << " in "
<< p.context()["country"] << ": "
<< p.greeting << std::endl; });
std::cout << p.greeting << std::endl;
}
int main()
{
using namespace kdb;
KDB kdb;
KeySet ks;
Context c;
// some predefined values (for convenience):
ks.append(Key("user/visit/%/%/%/person/greeting",
KEY_VALUE,
"Tag",
KEY_END));
ks.append(Key("user/visit/german/Austria/%/person/greeting",
KEY_VALUE,
"Servus",
KEY_END));
ks.append(Key("user/visit/german/switzerland/%/person/greeting",
KEY_VALUE,
"Grüezi",
KEY_END));
KeySet ks2;
kdb.get(ks2, "/visit");
// overwrite them if something is available in config files:
ks.append(ks2);
Parameters par(ks,c);
c.activate<MainApplicationLayer>();
c.activate<ProfileLayer>(par.profile);
for(int i=0; i<3; ++i) ::visit(par.visit.person);
return 0;
}
|
org 100h
.model small
Draw MACRO Y, X, Color
mov ah,0ch
mov al, Color
MOV dx, Y
MOV cx, X
int 10h
ENDM
.data
;Will be used for Bar Previous Top Location [- Future Level planning -]
eggX dw 0 ;Will be used for Bar Previous Left Location
eggY dw 50
remX dw 300
remY dw 180
frX dw 10
frY dw 10
;This var will hold the Bar Y-axis
wrtX dw 300
wrtY dw 180
pnt dw 0
.code
MOV ah, 0
mov al, 13h
INT 10h
mov ax,0
int 33h
proc frame
; fr1:
; Draw frY, frX,2
; inc frY
; cmp fry,190
; jle fr1
;
; fr2:
; Draw frY, frX,2
; inc frX
; cmp frX,310
; jle fr2
;
; fr3:
; Draw frY, frX,2
; dec frY
; cmp frY,10
; jge fr3
;
; fr4:
; Draw frY, frX,2
; dec frX
; cmp frX,10
; jge fr4
endp frame
proc catcher
l1:
add wrtX,1
Draw wrtY, wrtX,4
Draw remY, remX,0
inc remX
;cccccccccccccccccccccccc
cmp eggY,50
jg E2
MC:
;.....................
cmp eggY,180
je point
dec eggY
add eggY,1
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggX,2
Draw eggY,eggX,0
sub eggX,2
;.....................
mov eggY,50
mov ax,3
int 33h
shr cx,1
mov eggX,cx
cmp bx,1
jne CM1
E2:
mov ax,wrtX
sub ax,1
cmp eggX,ax
je MC
cmp eggY,200
jge MC
;ccccccccccccccccccccccccc
EGG1:
;####################################################
dec eggY
add eggY,1
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggX,2
Draw eggY,eggX,0
sub eggX,2
;*****************
;
; ;--------------
; add wrtX,1
; inc remX
; ;--------------
add eggY,2
Draw eggY,eggX,4
add eggY,2
Draw eggY,eggX,4
add eggY,2
Draw eggY,eggX,4
add eggX,2
Draw eggY,eggX,4
add eggX,2
Draw eggY,eggX,4
sub eggY,2
Draw eggY,eggX,4
sub eggY,2
Draw eggY,eggX,4
sub eggX,2
Draw eggY,eggX,4
sub eggX,2
;--------------
add wrtX,1
inc remX
;--------------
;####################################
CM1:
cmp wrtX,300
jle l1
mov remX,330
l2:
sub wrtX,1
Draw wrtY, wrtX,4
Draw remY, remX,0
dec remX
;cccccccccccccccccccccccc
cmp eggY,50
jg E3
MC2:
;.....................
cmp eggY,180
je point
dec eggY
add eggY,1
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggX,2
Draw eggY,eggX,0
sub eggX,2
;.....................
mov eggY,50
mov ax,3
int 33h
shr cx,1
mov eggX,cx
cmp bx,1
jne CM2
E3:
mov ax,wrtX
sub ax,1
cmp eggX,ax
je MC2
cmp eggY,200
jge MC2
;ccccccccccccccccccccccccc
EGG2:
;####################################################
dec eggY
add eggY,1
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggX,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
add eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggY,2
Draw eggY,eggX,0
sub eggX,2
Draw eggY,eggX,0
sub eggX,2
;*****************
; ;-------------
; sub wrtX,1
; dec remX
; ;-------------
add eggY,2
Draw eggY,eggX,4
add eggY,2
Draw eggY,eggX,4
add eggY,2
Draw eggY,eggX,4
add eggX,2
Draw eggY,eggX,4
add eggX,2
Draw eggY,eggX,4
sub eggY,2
Draw eggY,eggX,4
sub eggY,2
Draw eggY,eggX,4
sub eggX,2
Draw eggY,eggX,4
sub eggX,2
;-------------
sub wrtX,1
dec remX
;-------------
;####################################
CM2:
cmp wrtX,40
jge l2
mov remX,10
jmp l1
endp catcher
point:
add pnt,10
;jmp catcher
cmp pnt,10
je pri
jmp catcher
pri:
mov ah,0
mov al,04h
int 10h
mov ah,0bh
mov bh,00h
mov bl,3
int 10h
mov ah,02
mov bh,0
mov dh,200
mov dl,50
int 10h
mov ah,9
|
TITLE LLTEXT - text screen mode support
;***
;LLTEXT - text screen mode support
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
; Support for text screen modes (BIOS 0,1,2,3,7).
; Note that this module module contains support
; code for all adapters capable of handling these
; screen modes and also attempts to compensate for
; the subtle differences in their treatment.
;
; This module sets hooks in the mode-independent
; modules to routines here for mode-dependent
; graphics support. See the mode-independent
; modules for more precise descriptions of the
; purposes and interfaces of these routines.
;
; The following table summarizes the information for
; the modes and configurations covered:
;
; C | A B
; O | B T I
; L | I T P T
; O A M | O R A C S
; S R D O | S I C G H / P
; C B A N | B O E A P P L
; R U C R P I | M U L X Y S R A I A
; E R O O T T | O T O R R I B G X N
; E S L W E O | D E R E E Z O E E E
; N T S S R R | E S S S S E X S L S
; -- - -- -- - -- | -- --- ---- --- --- --- ---- --- - -
; 0 0 40 25 C x | 0 16 N/A 320 200 2 8x8 8
; 0 x 40 25 m x | " " " 320 400 " 8x16 "
; 0 0 40 25 E C | " " 16 320 200 " 8x8 "
; 0 x 40 25 E E | " " 64 320 350 " 8x14 "
; 0 x 40 25 V x | " " " 360 400 " 9x16 "
; 0 x 40 43 E E | " " " 320 350 4 8x8 " (4 pgs w/64K)
; 0 x 40 43 V x | " " " 320 350 " 8x8 "
; 0 x 40 50 V x | " " " 320 400 8 8x8 4
; 0 1 40 25 C x | 1 " N/A 320 200 2 8x8 8
; 0 1 40 25 E C | " " 16 320 200 " 8x8 "
; 0 0 80 25 C x | 2 " N/A 640 200 4 8x8 4
; 0 x 80 25 m x | " " " 640 400 " 8x16 8
; 0 0 80 25 E C | " " 16 640 200 " 8x8 " (4 pgs w/64K)
; 0 x 80 25 E E | " " 64 640 350 " 8x14 " (4 pgs w/64K)
; 0 x 80 25 V x | " " " 720 400 " 9x16 "
; 0 x 80 43 E E | " " " 640 350 8 8x8 4 (2 pgs w/64K)
; 0 x 80 43 V x | " " " 640 350 " 8x8 "
; 0 x 80 50 V x | " " " 640 400 " 8x8 "
; 0 1 80 25 C x | 3 " N/A 640 200 4 8x8 "
; 0 1 80 25 E C | " " 16 640 200 " 8x8 8 (4 pgs w/64K)
; 0 x 80 25 M M | 7 " 3 720 350 " 9x14 1
; 0 x 80 25 E M | " " " 720 350 " 9x14 8 (4 pgs w/64K)
; 0 x 80 25 V x | " " " 720 400 " 9x16 "
; 0 x 80 43 E M | " " " 720 350 8 8x8 4 (2 pgs w/64K)
; 0 x 80 43 V x | " " " 720 350 " 8x8 "
; 0 x 80 50 V x | " " " 720 400 " 8x8 "
;
;******************************************************************************
INCLUDE switch.inc ;feature switches
INCLUDE rmacros.inc
USESEG _BSS
USESEG _DATA
USESEG GR_TEXT
USESEG CN_TEXT
INCLUDE seg.inc
INCLUDE ibmunv.inc
INCLUDE llgrp.inc ; Constant definitions
INCLUDE grmac.inc ;ModeData macros
INCLUDE oscalls.inc ;Dos 5 structures
sBegin _DATA
externW b$UsrCsrTyp
externB b$InsCsrStop
sEnd _DATA
sBegin _BSS
;
; ***************************************************************************
; External variables
; ***************************************************************************
;
externB b$BiosMode
externW b$ModeBurst
externW b$CurPages
externB b$ScreenMode
externB b$ScrWidth
externD b$InitPalette
externB b$MaxAttr
externB b$MaxColor
globalW b$PageTable,,8 ;Offset to start of each video page
externB b$OrgBiosMode
externB b$Monitor
externB b$Adapter
externW b$VideoMem
externB b$PageSize
externB b$MaxPage
externB b$ScrHeight
externB b$ForeColor
externW b$FBColors
externB b$CharColor
externW b$CurrPSize
externB b$NullColor
externW b$DSP
externW b$CURSOR
externW b$CSRTYP
;
; ***************************************************************************
; Local variables
; ***************************************************************************
;
externB b$BorderColor ;border color (overscan)
sEnd _BSS
sBegin CN_TEXT
externNP B$USRCSR
sEnd CN_TEXT
assumes CS,GR_TEXT
sBegin GR_TEXT
externNP B$InitModeData
externNP B$GetParm
externNP B$EgaPalReset
externNP B$EgaPalResetB
externNP B$EgaPalPut
externNP B$EgaPalPutB
externNP B$EgaPalTrans
externNP B$EgaPalSet
externNP b$ColorPalette
externNP b$EnhPalette
;
; PAGE SIZES for each screen dimension possibility:
;
; These are calculated here as the BIOS initializes them (for the 25-line
; cases), or as it calculates them (for the 43/50-line cases). The added
; "slop" separates the pages and apparently eases scrolling troubles
; while increasing our troubles.
;
; NOTE: 4 pages of 80x50 is 8100H bytes, 100H over the 8000H max for the
; memory map, but 100H is the 256 byte slop between pages, so its OK.
; BUT, 8 pages of 40x50 is 8500H which is more than the slop will
; allow so we cut the supported pages in half to 4 in the code.
; (40x50 could actually support 7 pages, but 4 is a nicer number??)
;
P40x25 EQU ((40*25*2+255) AND (NOT 255)) SHR 4 ;0800H bytes
P80x25 EQU ((80*25*2+255) AND (NOT 255)) SHR 4 ;1000H bytes
P40x43 EQU (40*43*2+256) SHR 4 ;0E70H bytes
P80x43 EQU (80*43*2+256) SHR 4 ;1BE0H bytes
P40x50 EQU (40*50*2+256) SHR 4 ;10A0H bytes [4]
P80x50 EQU (80*50*2+256) SHR 4 ;2040H bytes [4]
;===========================================================================
mModeData Mode0Data
;
; SCREEN 0, BIOS modes 0 & 1
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 0 ;BIOS mode and burst may be adjusted later
mBurst 0
mScrWidth 40
mScrHeight 25
mHorzRes 320
mVertRes 200
mVideoBase 0B800H
mMaxAttr 15
mMaxColor 63
mPageSize 2 ;page size in K
mCurrPSize P40x25 ;page size in paragraphs (1 plane)
mMaxPage 7
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette b$ColorPalette ;moved to LLXGASUP for sharing
mInitVgaPal b$VgaPalette ;use regular VGA palette
mAlphaDim AlphaDim0
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalReset
mPalPut B$EgaPalPut
mPalTrans B$EgaPalTrans
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;===========================================================================
mModeData Mode2Data
;
; SCREEN 0, BIOS modes 2 & 3
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 2 ;BIOS mode and burst may be adjusted later
mBurst 0
mScrWidth 80
mScrHeight 25
mHorzRes 640
mVertRes 200
mVideoBase 0B800H
mMaxAttr 15
mMaxColor 63
mPageSize 4 ;page size in K
mCurrPSize P80x25 ;page size in paragraphs (1 plane)
mMaxPage 3
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette b$ColorPalette ;moved to LLXGASUP for sharing
mInitVgaPal b$VgaPalette ;use regular VGA palette
mAlphaDim AlphaDim2
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalReset
mPalPut B$EgaPalPut
mPalTrans B$EgaPalTrans
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;===========================================================================
mModeData Mode7Data
;
; SCREEN 0, BIOS mode 7
;
; Mode-dependent data follows to initialize the the "b$ModeData" table
; in LLCGRP.
;
;===========================================================================
mScreenMode 0
mBiosMode 7
mBurst 0
mScrWidth 80
mScrHeight 25
mHorzRes 720
mVertRes 350
mVideoBase 0B000H
mMaxAttr 15
mMaxColor 2
mPageSize 4 ;page size in K
mCurrPSize P80x25 ;page size in paragraphs (1 plane)
mMaxPage 0
mNullColor 7
mForeColor 7
mBackColor 0
mEgaWrMd 0
mInitPalette MonoPalette
mInitVgaPal 0 ;not applicable
mAlphaDim AlphaDim7
mSetMode SetMode
mSetPages SetPages
mPalReset B$EgaPalResetB
mPalPut B$EgaPalPutB
mPalTrans PalTrans7
mPalSet B$EgaPalSet
mSetColor SetColor
mEnd ,TextDataLen
;===========================================================================
;
; MonoPalette - used to initialize the EGA palette for SCREEN 0,
; BIOS mode 7, for a Mono Display.
;
labelB MonoPalette ;EGA palette for Mono Display, mode 7
DB 0 ;black
DB 7 DUP (001000B) ;video
DB 0 ;black
DB 7 DUP (011000B) ;intensified
;***
; B$Screen0
;
;Purpose:
; Establish all relevent mode dependent data values and function
; vectors for BASIC screen mode 0.
; NOTE: No actual change in screen mode occurs until SetMode is called!
;Entry:
; AL = screen mode (0)
; AH = burst (0 or 1)
; CL = alpha columns
;Exit:
; PSW.C = set indicates error
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc B$Screen0,<PUBLIC,NEAR>
cBegin
mov bx,GR_TEXTOFFSET Mode7Data
mov al,7 ;assume mono mode
test b$Monitor,Monochrome ;is this a monochrome monitor?
jnz Scr7 ;go if so
cmp b$Monitor,AnalogMono ; VGA working only in MONO modes?
je Scr7 ; go if so
and al,b$OrgBiosMode;get entry bios mode and mask down to 3 bits
cmp al,7 ;if AL=7 then entry mode was 7 or F (both mono)
je Scr7 ;branch if entry mode was mono. use mode 7
xor al,al ;mode base = 0
mov bx,GR_TEXTOFFSET Mode0Data
cmp cl,40 ;40 columns?
je Got40 ;go if so w/mode base = 0
mov bx,GR_TEXTOFFSET Mode2Data
mov al,2 ;mode base = 2
Got40:
add al,ah ;new BIOS mode = 0/2 if no burst
; 1/3 if burst
Scr7:
mov cx,TextDataLen
push ax
call B$InitModeData ;initialize table data
pop ax
mov b$ModeBurst,ax ;save new mode and burst
test b$Adapter,CGA + MDPA + HGC ;CGA or MDPA or HGC adapters?
jnz SkipPage ;go if so
mov ah,7 ;8 (max=7) pages for EGA/VGA/MCGA w/25 lines
test b$Adapter,EGA ; EGA adapter?
jz MaxPg ; brif not, 8 pages is right
cmp b$VideoMem,64 ; only 64K EGA?
ja MaxPg ; go if more, 8 pages is right
cmp al,1 ;BIOS mode 0 or 1? (40 columns)
jbe MaxPg ;go if so, 8 pages is right
shr ah,1 ;limit to 4 pages (max=3) if 64K EGA & 80x25
MaxPg:
mov b$MaxPage,ah ;save corrected max page value
test b$Monitor,StdColor ;std color monitor?
jz SkipPage ;go if not
mov b$MaxColor,15 ;it can only handle 16 colors
SkipPage:
cmp al,7 ;BIOS mode 7?
jz ScrExit ;if mono, don't setup enhanced palette
test b$Monitor,AnalogColor + AnalogMono + EnhColor
;enhanced or analog monitor?
jz ScrExit ;go if not
;set up enhanced palette for >= enhanced color monitor
mov WORD PTR b$InitPalette,GR_TEXTOFFSET b$EnhPalette
ScrExit:
mov al,b$ForeColor ;set character color for text mode
mov b$CharColor,al
mov b$DSP,770H ;text mode function key attributes
clc ;indicate no error
cEnd
;***
; AlphaDim0
;
;Purpose:
; Validate the proposed text dimensions for 40 column Screen mode 0
; and set up several screen-dependent variables if dimensions are OK.
;Entry:
; BH = number of lines
; BL = number of columns
;Exit:
; If dimensions ok
; PSW.C reset
; AL = -1
; b$MaxPage, b$BiosMode, b$VideoMem, b$CurrPSize,
; and b$ScrHeight set appropriately.
; Else (error)
; PSW.C set
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc AlphaDim0,<NEAR>
cBegin
mov cl,80 ;80 is "other" columns
ADim0_2: ;common entry point from AlphaDim2
xor al,al ;flag request for screen 0
cmp bl,cl ;"other" columns?
je ADim0Exit ;exit if so w/request to reenter screen 0
ADim0_7: ;common entry point from AlphaDim7
cmp bl,b$ScrWidth ;same as current?
stc
jne ADim0Exit ;go if not w/error, only 80 or 40 columns
cmp bh,25 ;25 lines?
je ADim0Ok ;go if so, w/request to reenter screen 0
; to get back to 25 lines
dec al ;flag request satisfied (or error)
test b$Adapter,EGA + VGA ;EGA or VGA?
stc ;set error, just in case
jz ADim0Exit ;go if not w/error, only 25 lines
test b$Monitor,StdColor ;disallow StdColor monitor for 43 lines
stc ;set error, just in case
jnz ADim0Exit ;go if StdColor w/error
cmp bh,43 ;43 lines?
je LinesOk ;43 lines is ok
test b$Adapter,VGA ;VGA?
stc ;set error, just in case
jz ADim0Exit ;exit with error if not VGA
cmp bh,50 ;50 lines?
stc ;set error, just in case
jne ADim0Exit ;exit with error if not 50 lines
mov cx,P40x50 ;larger page size
cmp bl,40 ;40 columns?
je ADim0_50 ;go if so
mov cx,P80x50 ;larger page size
jmp short ADim0_50
LinesOK:
mov cx,P40x43 ;larger page size
cmp bl,40 ;40 columns?
je ADim0_43 ;go if so
mov cx,P80x43 ;larger page size
ADim0_50:
mov b$MaxPage,3 ;only 4 pages in 80x43 or 80x50 or 40x50
ADim0_43:
;64K EGA has half the pages for all text dimensions except
;40x25, which is handled by B$Screen0 and never reaches here
cmp b$VideoMem,64 ;only 64K?
ja PgOk ;go if more, MaxPage is right
shr b$MaxPage,1 ;halve number of pages if 64K mode 7
PgOk:
ADim0Ok:
mov b$ScrHeight,bh ;set alpha rows
clc ;no error
ADim0Exit:
cEnd
;***
; AlphaDim2
;
;Purpose:
; Validate the proposed text dimensions for 80 column Screen mode 0
; and set up several screen-dependent variables if dimensions are OK.
;Entry:
; BH = number of lines
; BL = number of columns
;Exit:
; exits through AlphaDim0
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc AlphaDim2,<NEAR>
cBegin
mov cl,40 ;40 is "other" columns
jmp ADim0_2 ;rest is just like mode 0 case
cEnd <nogen>
;***
; AlphaDim7
;
;Purpose:
; Validate the proposed text dimensions for monochrome Screen mode 0
; and set up several screen-dependent variables if dimensions are OK.
;Entry:
; BH = number of lines
; BL = number of columns
;Exit:
; exits through AlphaDim0
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc AlphaDim7,<NEAR>
cBegin
xor al,al ;setup for request to reenter screen 0
jmp ADim0_7 ;rest is just like mode 0 case
cEnd <nogen>
;***
; B$FixTextPage
;
;Purpose:
; Fix up b$CurrPSize (for 43/50 lines) and initialize b$PageTable.
;
;Entry:
; b$CurrPSize initialized to 25-line default.
; b$ScrHeight must be initialized (call Alphadim).
;
;Exit:
; b$CurrPSize updated.
; b$PageTable initialized.
;
;Uses:
; per conv.
;
;Preserves:
; DI.
;
;******************************************************************************
cProc B$FixTextPage,<PUBLIC,NEAR>,<DI>
cBegin
xor ax,ax ; get a zero
cmp b$ScreenMode,al ; make sure we're in text mode
jnz PSizeExit ; else just return
push es
cmp b$ScrHeight,25 ; 25-line mode?
je PSizeOkay ; brif so--b$CurrPSize already set correctly
mov es,ax
mov ax,es:[CRT_LEN] ; get actual page size from BIOS, in bytes
mov cl,4
shr ax,cl ; convert to paragraphs
mov b$CurrPSize,ax ; and update current page size
PSizeOkay:
mov di,offset DGroup:b$PageTable
mov bx,[b$CurrPSize] ; size of page in paragraphs
mov cl,4
shl bx,cl ; convert to size in bytes
xor ax,ax ; first page always at offset zero
mov cx,8 ; assume 8 pages
push ds
pop es ; es=ds
SetPageTable:
stosw ; set offset for this page
add ax,bx ; compute offset of next page
loop SetPageTable
pop es
PSizeExit:
cEnd
;***
; SetMode
;
;Purpose:
; Set screen mode according to the characteristics established
; by previous call to B$Screenx and b$AlphaDim. Set 8x8 character
; font if new mode is to be 43 or 50 lines.
;Entry:
; b$BiosMode is mode to set
; b$ScrHeight is number of lines
;Exit:
; None
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc SetMode,<NEAR>
cBegin
test b$Adapter,VGA + MCGA ;MCGA or VGA?
jz SkipScanSet ;no, don't set scan lines
mov ax,1202H ;assume we want 400 scan lines
cmp b$ScrHeight,43 ;43 lines mode?
jne SetScans ;no, go set to 400 scan lines
mov ax,1201H ;set 350 scan lines for 43 line mode
SetScans:
mov bl,30H ;subfunction for set scan lines
SCNIO ;set the scan lines
SkipScanSet:
mov al,b$BiosMode ;set BIOS mode
SCNIO vSetMode
cmp b$ScrHeight,43 ;43 lines?
je Set8x8 ;branch if so
cmp b$ScrHeight,50 ;50 lines?
Set8x8:
jne SetMode25 ;go if not
mov ax,1112H ;character generator request
xor bl,bl ; to load 8x8 font
SCNIO ; which gets 43 lines [2]or 50 lines
MOV AX,0707H ; cursor type for 8x8 font
JMP SHORT sm_1
SetMode25:
MOV AX,0707H ; assume 7,7 cursor (all bios modes but 7)
CMP b$BiosMode,AL ; bios mode 7? (AL = 7)
JNE StoreCsr ; no, use normal cursor
MOV AX,0C0CH ; bios mode 7 cursor is 12,12
sm_1:
StoreCsr:
MOV b$UsrCsrTyp,AX ; store cursor type
MOV b$UsrCsrTyp,AX ; store cursor type
MOV b$InsCsrStop,AL ; and make insert cursor match
MOV DX,b$CURSOR ; Get current cursor position
MOV BYTE PTR b$CSRTYP,-1 ; invalidate present cursor type so it
; will get changed
CALL B$USRCSR ; display user cursor
NoStore:
cEnd
;***
; SetPages
;
;Purpose:
; Set the current active and visual pages for text modes.
;Entry:
; AL = active page
; AH = visual page
;Exit:
; None
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc SetPages,<NEAR>
cBegin
mov b$CurPages,ax ;save page numbers
mov al,ah
SCNIO vSelActivePage ;set visual page
cEnd
;***
; PalTrans7
;
;Purpose:
; Translate a user supplied color for monochrome Screen mode 0
; to the corresponding hardware value after verifying that the
; attribute value and the color value are in the legal ranges.
; Color mapping: 0 --> 0
; 1 --> 01000B
; 2 --> 11000B
;Entry:
; DX:AX = user supplied color value
; BL = user supplied attribute value
;Exit:
; PSW.C set if illegal value, reset if Ok
; DX:AX = translated color value
; BL = unchanged
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc PalTrans7,<NEAR>
cBegin
cmp bl,b$MaxAttr ;is legal attribute ?
ja PalTrErr ;error return
or dh,dl ;hi word of color 0?
or dh,ah ;hi byte of lo word of color 0?
jnz PalTrExit ;error if not
cmp al,b$MaxColor ;is legal color ?
ja PalTrErr ;error return
cmp al,1 ;translate color
jb PalTrExit ; 0 -> 0
mov al,01000B ; 1 -> 01000B
je PalTrExit
mov al,11000B ; 2 -> 11000B
PalTrExit:
clc ;no error
ret
PalTrErr:
STC ;indicate error
cEnd
;***
; SetColor
;
;Purpose:
; Process the color statement for text modes (BASIC Screen mode 0).
; Syntax for text mode color statement is as follows:
;
; COLOR [foreground],[background],[border]
;
; where "foreground" is the attribute to be used for the foreground
; (0-15 are normal, 16-31 are 0-15 plus blinking)
; and "background" is the attribute to be used for the background
; and "border" is the color to be used for the overscan border
;
; Any omitted parameter(s) indicate no change for that parameter.
;Entry:
; parameter list
; WORD 1 = flag 0 if param not present
; WORD 2 = parameter if WORD 1 <> 0, else second param flag
; etc.
;Exit:
; PSW.C set if error, reset if Ok.
; b$FBColors is set to foreground/background attributes
; b$CharColor is set to character attribute (fg & bg in one byte)
; b$NullColor is set to null attribute (same as character attribute)
;Uses:
; per conv.
;Exceptions:
;******************************************************************************
cProc SetColor,<NEAR>
cBegin
MOV DX,b$FBColors ;dl=ForeColor dh=BackColor
MOV BH,b$BorderColor
JCXZ SetColErr ;error if no params
jmp short SetCol1
SetColErr:
stc
jmp SetColExit
SetCol1:
cCall B$GetParm ;[AL] = parm if not psw.z
JZ TXTCL1 ;brif no parm given
CMP AL,31 ;is foreground color in range [0-31]?
JA SetColErr ;error if not
XCHG AL,DL ;save new foreground color
TXTCL1:
cCall B$GetParm ;get bkgrnd color if specified
JZ TXTCL2 ;brif no parm given
CMP AL,15 ;range check background color [0-15]
JA SetColErr ;brif out of range
XCHG AL,DH ;save new background color
TXTCL2:
cCall B$GetParm ;get border color if specified
JZ TXTCL3 ;brif no parm given
JCXZ NoError
JMP SHORT SetColErr
NoError:
CMP AL,15 ;range check border color [0-15]
JA SetColErr ;brif out of range
XCHG AL,BH ;save new border color
TXTCL3:
cmp b$BiosMode,7 ;mode 7?
jne SetColOk ;skip if not
test b$Adapter,EGA ;EGA?
jz SetColOk ;skip if not
;this fixes a bug in the EGA card mode 7 ???
;if Fg=0/8/16/24 and Bg=7/15 let it go else force Bg to 0
mov al,dh ;BackColor
not al ;low 3 bits = 0 iff BackColor = 7|15
or al,dl ;low 3 bits = 0 iff ForeColor = 0|8|16|24
and al,7 ;low 3 bits = 0 iff both
jz SetColOk
xor dh,dh ;in all other cases make Bg = 0
SetColOk:
MOV AX,DX ;get fg/bk colors in AX
MOV b$FBColors,AX ;new fore and back
XCHG DH,DL ;swap forground/background colors
AND DH,0FH ;strip off blink
SHL DL,1 ;shift background intensity bit into d4
AND DL,10H ;leave intensity
OR DL,BH ;[DL] = border color + background intensity
AND AH,7 ;strip background intensity from char attribute
MOV CL,4
SHL AH,CL ;move background color bits to d6-d4 for char
;attribute
TEST AL,10H ;is blink enabled?
JZ NOBLNK ;br. if not
OR AH,80H ;add blink
NOBLNK:
OR AH,DH ;add foreground color
MOV CH,AH ;place char attribute in CH
MOV b$NullColor,AH ;char attribute
MOV b$CharColor,AH ;null attribute
TEST b$Monitor,AnalogColor + AnalogMono + EnhColor
;enhanced or analog monitor?
jnz NO_BORDER ;Brif so
MOV b$BorderColor,BH;new border color
MOV BL,DL ;need border color in BL
XOR BH,BH ;zero BH
SCNIO vSetPalette ;set border color
NO_BORDER:
clc ;indicate no error
SetColExit:
cEnd
sEnd GR_TEXT
END
|
; A269457: a(n) = 5*(n + 1)*(n + 4)/2.
; 10,25,45,70,100,135,175,220,270,325,385,450,520,595,675,760,850,945,1045,1150,1260,1375,1495,1620,1750,1885,2025,2170,2320,2475,2635,2800,2970,3145,3325,3510,3700,3895,4095,4300,4510,4725,4945,5170,5400,5635
mov $1,$0
add $1,3
bin $1,2
sub $1,1
mul $1,5
|
MODULE __printf_print_aligned
SECTION code_clib
PUBLIC __printf_print_aligned
EXTERN __printf_doprint
EXTERN l_ge
__printf_print_aligned:
ld l,(ix-6) ;width
ld h,(ix-5)
ld a,h
or l
jr z,width_done
push bc
call l_ge
pop bc
jr nc,adjust_width
ld hl,0
jr width_done
adjust_width:
and a
sbc hl,de
width_done:
bit 0,(ix-4)
call z,print_padding ; Doing rightaligh, pad it out
print_buffer:
ld a,d
or e
jr z,buffer_done
ld a,(bc)
; and a
; jr z,print_buffer_end
call __printf_doprint
inc bc
dec de
jr print_buffer
buffer_done:
; Now the right padding - hl is what we've got to print
print_buffer_end:
res 2,(ix-4) ; We can't do a trailing pad with 0!
print_padding:
ld a,h
or l
ret z
ld a,' '
bit 2,(ix-4)
jr z,pad_is_space
ld a,'0'
pad_is_space:
call __printf_doprint
dec hl
jr print_padding
|
; A138894: Expansion of (1+x)/(1-10*x+9*x^2).
; 1,11,101,911,8201,73811,664301,5978711,53808401,484275611,4358480501,39226324511,353036920601,3177332285411,28595990568701,257363915118311,2316275236064801,20846477124583211,187618294121248901,1688564647091240111,15197081823821161001,136773736414390449011,1230963627729514041101,11078672649565626369911,99708053846090637329201,897372484614815735962811,8076352361533341623665301,72687171253800074612987711,654184541284200671516889401,5887660871557806043652004611,52988947844020254392868041501,476900530596182289535812373511,4292104775365640605822311361601,38628942978290765452400802254411,347660486804616889071607220289701,3128944381241552001644464982607311,28160499431173968014800184843465801,253444494880565712133201663591192211
mov $1,9
pow $1,$0
mul $1,5
div $1,4
mov $0,$1
|
; A268896: Start at a(0)=1. a(n) = a(n-1)+2 if n == 1,2 (mod 3) and a(n)=a(n-1)+a(n-3) if n == 0 (mod 3).
; 1,3,5,6,8,10,16,18,20,36,38,40,76,78,80,156,158,160,316,318,320,636,638,640,1276,1278,1280,2556,2558,2560,5116,5118,5120,10236,10238,10240,20476,20478,20480,40956,40958
mov $2,$0
mul $2,2
mov $1,$2
add $1,1
lpb $0
add $0,1
sub $1,$0
sub $0,4
mul $1,2
lpe
mov $0,$1
|
;
; ANSI Video handling for the ABC80
;
; Scrollup
;
;
; $Id: f_ansi_scrollup.asm,v 1.3 2007/10/31 14:01:47 stefano Exp $
;
XLIB ansi_SCROLLUP
.ansi_SCROLLUP
jp $241 |
.text
.globl partition
# Setup the left address, right address, and pivot stuff
partition:
addi $sp, $sp, -12
sw $a0, 0($sp) #left
sw $a1, 4($sp) #right
sw $ra, 8($sp) #return
addi $a1, $a1, -1
addi $t0, $a0, -1 #left address
addi $t1, $a1, 1 #right address
addi $t2, $a1, -1 #pivot address
lw $t2, 0($t2)
jal partmain
lw $a0, 0($ra)
lw $a1, 4($ra)
lw $ra, 8($sp)
addi $sp, $sp, 12
jr $ra
# while (left < right) repeat partition cycle
partmain:
addi $sp, $sp, -4
sw $ra, 8($sp)
j whileg
j whilel
j ifl
blt $t0, $t1, partmain
lw $ra, 8($sp)
addi $sp, $sp, 4
jr $ra
# while (array[right] > pivot) repeat whileg
whileg:
addi $t1, $t1, -1
lw $t4, 0($t1)
bgt $t4, $t3, whileg
jr $ra
# while (left < right and array[left] <= pivot) repeat whilel
whilel:
addi $t0, $t0, 1
lw $t4, 0($t0)
slt $t5, $t0, $t1 #(left < right), 0 = false
sgt $t6, $t3, $t4 #(array[left] <= pivot), 1 = false
bne $t5, $t6, whilel
jr $ra
# if (left < right) then swap left and right addresses
ifl:
add $a0, $zero, $t0
add $a1, $zero, $t1
j swap
jr $ra |
; A292291: Number of vertices of type B at level n of the hyperbolic Pascal pyramid.
; 0,0,0,3,12,36,99,264,696,1827,4788,12540,32835,85968,225072,589251,1542684,4038804,10573731,27682392,72473448,189737955,496740420,1300483308,3404709507,8913645216,23336226144,61095033219,159948873516,418751587332,1096305888483,2870166078120,7514192345880,19672410959523,51503040532692,134836710638556,353007091382979,924184563510384,2419546599148176,6334455233934147,16583819102654268,43417002074028660,113667187119431715,297584559284266488,779086490733367752,2039674912915836771,5339938248014142564,13980139831126590924,36600481245365630211,95821303904970299712,250863430469545268928,656768987503665507075,1719443532041451252300,4501561608620688249828,11785241293820613497187,30854162272841152241736,80777245524702843228024,211477574301267377442339,553655477379099289098996,1449488857836030489854652,3794811096128992180464963,9934944430550946051540240,26010022195523845974155760,68095122156020591870927043,178275344272537929638625372,466730910661593197044949076,1221917387712241661496221859,3199021252475131787443716504,8375146369713153700834927656,21926417856664329315061066467,57404107200279834244348271748,150285903744175173417983748780,393453604032245686009602974595,1030074908352561884610825175008,2696771121025439967822872550432,7060238454723758018857792476291,18483944243145834088750504878444,48391594274713744247393722159044,126690838580995398653430661598691,331680921468272451712898262637032,868351925823821956485264126312408,2273374856003193417742894116300195,5951772642185758296743418222588180,15581943070554081472487360551464348,40794056569476486120718663431804867,106800226637875376889668629743950256,279606623344149644548287225800045904,732019643394573556755193047656187459
sub $0,2
mov $1,5
lpb $0
sub $0,1
add $2,$1
add $1,$2
lpe
sub $1,5
div $1,5
mul $1,3
mov $0,$1
|
PAGE 58,132
;******************************************************************************
TITLE MonoUMB -- Dummy VDD2 device to fool old VDDs
;******************************************************************************
;
; (C) Copyright MICROSOFT Corp., 1992
;
; Title: MonoUMB -- Dummy VDD2 device to fool old (3.00) VDDs into
; not claiming the MONOChrome adapter region.
; This allows a UMB in the MONOChrome region
; for LIM/UMBulators (like EMM386) that do not
; load the LoadHi VxD on WIN386 versions >= 3.10
; because they specify the UMBs using only the
; Paging Import to the V86MMGR.
;
; Version: 1.00
;
; Date: 07-Jan-1992
;
; Author: ARR
;
;------------------------------------------------------------------------------
;
; Change log:
;
; DATE REV DESCRIPTION
; ----------- --- -----------------------------------------------------------
; 01-07-1992 ARR Original
;
;==============================================================================
;
; DESCRIPTION: See Title ABove
;
;******************************************************************************
.386p
;******************************************************************************
; I N C L U D E S
;******************************************************************************
.XLIST
INCLUDE VMM.Inc
.LIST
Create_VDD2_Service_Table EQU TRUE
INCLUDE .\VDD2.Inc
MonoUMB_Service_Table EQU VDD2_Service_Table
Num_MonoUMB_Services EQU Num_VDD2_Services
;******************************************************************************
; V I R T U A L D E V I C E D E C L A R A T I O N
;******************************************************************************
Declare_Virtual_Device MonoUMB, 1, 0, MonoUMB_Control, VDD2_Device_ID, Undefined_Init_Order
;******************************************************************************
; E Q U A T E S
;******************************************************************************
;******************************************************************************
; S T R U C T U R E S
;******************************************************************************
;******************************************************************************
; F L A G E Q U A T E S
;******************************************************************************
;******************************************************************************
; I N I T I A L I Z A T I O N D A T A
;******************************************************************************
VxD_IDATA_SEG
; define a copyright string
MS_CopyRight db '(C) Copyright MICROSOFT Corp., 1992',0
MonoUMB_Device_Name db 'MonoUMB',0,0
VxD_IDATA_ENDS
;******************************************************************************
; L O C A L D A T A
;******************************************************************************
VxD_DATA_SEG
VxD_DATA_ENDS
;******************************************************************************
; R E A L M O D E I N I T I A L I Z A T I O N
;******************************************************************************
VxD_REAL_INIT_SEG
;******************************************************************************
;
; MonoUMB_Real_Mode_Init
;
; DESCRIPTION:
;
; The VxD will not load if this is a duplicate load.
;
; ENTRY:
; CS, DS = Real mode segment
; AX = VMM version (AH=Major, AL=Minor)
; BX = Flags
;
; EXIT:
; BX = Null pointer (no pages to exclude)
; SI = Null pointer (no instance data)
; EDX = 0
;
; USES:
; AX, BX, DX, SI, Flags
;
;==============================================================================
BeginProc MonoUMB_Real_Mode_Init
; check for duplicate device load.
test bx, Duplicate_From_INT2F OR Duplicate_Device_ID
jnz SHORT MU_RMI_Fail_Load
MU_RMI_Loading_Ok:
mov ax, Device_Load_Ok
jmp SHORT MU_RMI_Exit
MU_RMI_Fail_Load:
; fail this device load without any error message.
mov ax, Abort_Device_Load + No_Fail_Message
MU_RMI_Exit:
xor bx,bx ;no pages to exclude
xor si,si ;no instance data
xor edx,edx ;Ref data 0
ret
EndProc MonoUMB_Real_Mode_Init
VxD_REAL_INIT_ENDS
;******************************************************************************
; D E V I C E C O N T R O L P R O C E D U R E
;******************************************************************************
VxD_CODE_SEG
;******************************************************************************
;
; MonoUMB_Control
;
; DESCRIPTION:
;
; ENTRY:
; EAX = Control call ID
;
; EXIT:
; If carry clear then
; Successful
; else
; Control call failed
;
; USES:
; EAX, EBX, ECX, EDX, ESI, EDI, Flags
;
;==============================================================================
BeginProc MonoUMB_Control,PUBLIC
clc ; Ignore other control calls
ret
EndProc MonoUMB_Control
;----------------------------------------------------------------------------;
; VDD2_Get_Version: ;
; ;
; DESCRIPTION: ;
; MonoUMB VxD acts like a secondary VDD. This prevents the VGA and ;
; EGA VDDs from getting upset about the fact that someone has ;
; grabbed the ownership of the MONO video pages. ;
; ;
; ENTRY: ;
; None ;
; ;
; EXIT: ;
; If UMBs in MONO region, carry clear ;
; EAX != 0 ;
; ESI -> device name string ;
; else, carry set ;
; EAX = ESI = 0 ;
; ;
; USES: ;
; FLAGS,EAX,ESI ;
; ;
;----------------------------------------------------------------------------;
BeginProc VDD2_Get_Version, Service
mov esi,OFFSET32 MonoUMB_Device_Name
mov eax, 200h
clc
ret
EndProc VDD2_Get_Version
VxD_CODE_ENDS
END MonoUMB_Real_Mode_Init
|
; A277592: Numbers k such that k/10^m == 5 mod 10, where 10^m is the greatest power of 10 that divides n.
; 5,15,25,35,45,50,55,65,75,85,95,105,115,125,135,145,150,155,165,175,185,195,205,215,225,235,245,250,255,265,275,285,295,305,315,325,335,345,350,355,365,375,385,395,405,415,425,435,445,450,455,465,475,485
add $0,5
mov $2,$0
mul $0,2
lpb $0
trn $0,$2
sub $2,1
add $0,$2
sub $0,1
add $2,10
lpe
mov $1,5
mul $1,$0
sub $1,35
mov $0,$1
|
; A264851: a(n) = n*(n + 1)*(n + 2)*(4*n - 3)/6.
; 0,1,20,90,260,595,1176,2100,3480,5445,8140,11726,16380,22295,29680,38760,49776,62985,78660,97090,118580,143451,172040,204700,241800,283725,330876,383670,442540,507935,580320,660176,748000,844305,949620,1064490,1189476
mov $3,$0
lpb $0,1
sub $0,1
add $4,$3
add $2,$4
add $1,$2
add $3,12
lpe
|
const_def
const MARTTEXT_HOW_MANY
const MARTTEXT_COSTS_THIS_MUCH
const MARTTEXT_NOT_ENOUGH_MONEY
const MARTTEXT_BAG_FULL
const MARTTEXT_HERE_YOU_GO
const MARTTEXT_SOLD_OUT
OpenMartDialog::
call GetMart
ld a, c
ld [wMartType], a
call LoadMartPointer
ld a, [wMartType]
ld hl, .dialogs
rst JumpTable
ret
.dialogs
dw MartDialog
dw HerbShop
dw BargainShop
dw Pharmacist
dw RooftopSale
dw TMShop
TMShop:
ld a, 1
ld [wMartSellingTM], a
jr ShopDialog
MartDialog:
xor a
ld [wMartSellingTM], a
ShopDialog:
ld a, MARTTYPE_STANDARD
ld [wMartType], a
xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wMartJumptableIndex], a
call StandardMart
ret
HerbShop:
call FarReadMart
call LoadStandardMenuHeader
ld hl, Text_HerbShop_Intro
call MartTextbox
call BuyMenu
ld hl, Text_HerbShop_ComeAgain
call MartTextbox
ret
BargainShop:
ld b, BANK(BargainShopData)
ld de, BargainShopData
call LoadMartPointer
call ReadMart
call LoadStandardMenuHeader
ld hl, Text_BargainShop_Intro
call MartTextbox
call BuyMenu
ld hl, wBargainShopFlags
ld a, [hli]
or [hl]
jr z, .skip_set
ld hl, wDailyFlags1
set DAILYFLAGS1_GOLDENROD_UNDERGROUND_BARGAIN_F, [hl]
.skip_set
ld hl, Text_BargainShop_ComeAgain
call MartTextbox
ret
Pharmacist:
call FarReadMart
call LoadStandardMenuHeader
ld hl, Text_Pharmacist_Intro
call MartTextbox
call BuyMenu
ld hl, Text_Pharmacist_ComeAgain
call MartTextbox
ret
RooftopSale:
ld b, BANK(RooftopSaleMart1)
ld de, RooftopSaleMart1
ld hl, wStatusFlags
bit STATUSFLAGS_HALL_OF_FAME_F, [hl]
jr z, .ok
ld b, BANK(RooftopSaleMart2)
ld de, RooftopSaleMart2
.ok
call LoadMartPointer
call ReadMart
call LoadStandardMenuHeader
ld hl, Text_Mart_HowMayIHelpYou
call MartTextbox
call BuyMenu
ld hl, Text_Mart_ComeAgain
call MartTextbox
ret
INCLUDE "data/items/rooftop_sale.asm"
LoadMartPointer:
ld a, b
ld [wMartPointerBank], a
ld a, e
ld [wMartPointer], a
ld a, d
ld [wMartPointer + 1], a
ld hl, wCurMart
xor a
ld bc, wCurMartEnd - wCurMart
call ByteFill
xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wMartJumptableIndex], a
ld [wBargainShopFlags], a
ld [wFacingDirection], a
ret
GetMart:
ld a, e
cp (Marts.End - Marts) / 2
jr c, .IsAMart
ld b, BANK(DefaultMart)
ld de, DefaultMart
ret
.IsAMart:
ld hl, Marts
add hl, de
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
ld b, BANK(Marts)
ret
; StandardMart.MartFunctions indexes
const_def
const STANDARDMART_HOWMAYIHELPYOU ; 0
const STANDARDMART_TOPMENU ; 1
const STANDARDMART_BUY ; 2
const STANDARDMART_SELL ; 3
const STANDARDMART_QUIT ; 4
const STANDARDMART_ANYTHINGELSE ; 5
STANDARDMART_EXIT EQU -1
StandardMart:
.loop
ld a, [wMartJumptableIndex]
ld hl, .MartFunctions
rst JumpTable
ld [wMartJumptableIndex], a
cp STANDARDMART_EXIT
jr nz, .loop
ret
.MartFunctions:
; entries correspond to STANDARDMART_* constants
dw .HowMayIHelpYou
dw .TopMenu
dw .Buy
dw .Sell
dw .Quit
dw .AnythingElse
.HowMayIHelpYou:
call LoadStandardMenuHeader
ld hl, Text_Mart_HowMayIHelpYou
call PrintText
ld a, STANDARDMART_TOPMENU
ret
.TopMenu:
ld hl, MenuHeader_BuySell
call CopyMenuHeader
call VerticalMenu
jr c, .quit
ld a, [wMenuCursorY]
cp $1
jr z, .buy
cp $2
jr z, .sell
.quit
ld a, STANDARDMART_QUIT
ret
.buy
ld a, STANDARDMART_BUY
ret
.sell
ld a, STANDARDMART_SELL
ret
.Buy:
call ExitMenu
call FarReadMart
call BuyMenu
and a
ld a, STANDARDMART_ANYTHINGELSE
ret
.Sell:
call ExitMenu
call SellMenu
ld a, STANDARDMART_ANYTHINGELSE
ret
.Quit:
call ExitMenu
ld hl, Text_Mart_ComeAgain
call MartTextbox
ld a, STANDARDMART_EXIT
ret
.AnythingElse:
call LoadStandardMenuHeader
ld hl, Text_Mart_AnythingElse
call PrintText
ld a, STANDARDMART_TOPMENU
ret
FarReadMart:
ld hl, wMartPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wCurMart
.CopyMart:
ld a, [wMartPointerBank]
call GetFarByte
ld [de], a
inc hl
inc de
cp -1
jr nz, .CopyMart
ld hl, wMartItem1BCD
ld de, wCurMart + 1
.ReadMartItem:
ld a, [de]
inc de
cp -1
jr z, .done
push de
call GetMartItemPrice
pop de
jr .ReadMartItem
.done
ret
GetMartItemPrice:
; Return the price of item a in BCD at hl and in tiles at wStringBuffer1.
push hl
ld [wCurItem], a
ld a, [wMartSellingTM]
and a
jr z, .regular_mart
farcall GetTMHMPrice
jr .continue
.regular_mart
farcall GetItemPrice
.continue
pop hl
GetMartPrice:
; Return price de in BCD at hl and in tiles at wStringBuffer1.
push hl
ld a, d
ld [wStringBuffer2], a
ld a, e
ld [wStringBuffer2 + 1], a
ld hl, wStringBuffer1
ld de, wStringBuffer2
lb bc, PRINTNUM_LEADINGZEROS | 2, 6 ; 6 digits
call PrintNum
pop hl
ld de, wStringBuffer1
ld c, 6 / 2 ; 6 digits
.loop
call .CharToNybble
swap a
ld b, a
call .CharToNybble
or b
ld [hli], a
dec c
jr nz, .loop
ret
.CharToNybble:
ld a, [de]
inc de
cp " "
jr nz, .not_space
ld a, "0"
.not_space
sub "0"
ret
ReadMart:
; Load the mart pointer. Mart data is local (no need for bank).
ld hl, wMartPointer
ld a, [hli]
ld h, [hl]
ld l, a
push hl
; set hl to the first item
inc hl
ld bc, wMartItem1BCD
ld de, wCurMart + 1
.loop
; copy the item to wCurMart + (ItemIndex)
ld a, [hli]
ld [de], a
inc de
; -1 is the terminator
cp -1
jr z, .done
push de
; copy the price to de
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
; convert the price to 3-byte BCD at [bc]
push hl
ld h, b
ld l, c
call GetMartPrice
ld b, h
ld c, l
pop hl
pop de
jr .loop
.done
pop hl
ld a, [hl]
ld [wCurMart], a
ret
INCLUDE "data/items/bargain_shop.asm"
BuyMenu:
call FadeToMenu
farcall BlankScreen
xor a
ld [wMenuScrollPositionBackup], a
ld a, 1
ld [wMenuCursorBufferBackup], a
.loop
call BuyMenuLoop ; menu loop
jr nc, .loop
call CloseSubmenu
ret
LoadBuyMenuText:
; load text from a nested table
; which table is in wMartType
; which entry is in register a
push af
call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers
ld a, [hli]
ld h, [hl]
ld l, a
pop af
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
ret
MartAskPurchaseQuantity:
call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers
inc hl
inc hl
ld a, [hl]
and a
jp z, StandardMartAskPurchaseQuantity
cp 1
jp z, BargainShopAskPurchaseQuantity
jp RooftopSaleAskPurchaseQuantity
GetMartDialogGroup:
ld a, [wMartType]
ld e, a
ld d, 0
ld hl, .MartTextFunctionPointers
add hl, de
add hl, de
add hl, de
ret
.MartTextFunctionPointers:
dwb .StandardMartPointers, 0
dwb .HerbShopPointers, 0
dwb .BargainShopPointers, 1
dwb .PharmacyPointers, 0
dwb .StandardMartPointers, 2
.StandardMartPointers:
dw Text_Mart_HowMany
dw Text_Mart_CostsThisMuch
dw Text_Mart_InsufficientFunds
dw Text_Mart_BagFull
dw Text_Mart_HereYouGo
dw BuyMenuLoop
.HerbShopPointers:
dw Text_HerbShop_HowMany
dw Text_HerbShop_CostsThisMuch
dw Text_HerbShop_InsufficientFunds
dw Text_HerbShop_BagFull
dw Text_HerbShop_HereYouGo
dw BuyMenuLoop
.BargainShopPointers:
dw BuyMenuLoop
dw Text_BargainShop_CostsThisMuch
dw Text_BargainShop_InsufficientFunds
dw Text_BargainShop_BagFull
dw Text_BargainShop_HereYouGo
dw Text_BargainShop_SoldOut
.PharmacyPointers:
dw Text_Pharmacy_HowMany
dw Text_Pharmacy_CostsThisMuch
dw Text_Pharmacy_InsufficientFunds
dw Text_Pharmacy_BagFull
dw Text_Pharmacy_HereYouGo
dw BuyMenuLoop
BuyMenuLoop:
farcall PlaceMoneyTopRight
call UpdateSprites
ld hl, MenuHeader_Buy
call CopyMenuHeader
ld a, [wMenuCursorBufferBackup]
ld [wMenuCursorBuffer], a
ld a, [wMenuScrollPositionBackup]
ld [wMenuScrollPosition], a
call ScrollingMenu
ld a, [wMenuScrollPosition]
ld [wMenuScrollPositionBackup], a
ld a, [wMenuCursorY]
ld [wMenuCursorBufferBackup], a
call SpeechTextbox
ld a, [wMenuJoypad]
cp B_BUTTON
jr z, .set_carry
cp A_BUTTON
jr z, .useless_pointer
.useless_pointer
call MartAskPurchaseQuantity
jr c, .cancel
call MartConfirmPurchase
jr c, .cancel
ld de, wMoney
ld bc, hMoneyTemp
ld a, 3 ; useless load
call CompareMoney
jr c, .insufficient_funds
ld a, [wMartSellingTM]
and a
jr z, .regular_item
call ReceiveTMHM
jr .join
.regular_item
ld hl, wNumItems
call ReceiveItem
.join
jr nc, .insufficient_bag_space
ld a, [wMartItemID]
ld e, a
ld d, 0
ld b, SET_FLAG
ld hl, wBargainShopFlags
call FlagAction
call PlayTransactionSound
ld de, wMoney
ld bc, hMoneyTemp
call TakeMoney
ld a, MARTTEXT_HERE_YOU_GO
call LoadBuyMenuText
call JoyWaitAorB
.cancel
call SpeechTextbox
and a
ret
.set_carry
scf
ret
.insufficient_bag_space
ld a, MARTTEXT_BAG_FULL
call LoadBuyMenuText
call JoyWaitAorB
and a
ret
.insufficient_funds
ld a, MARTTEXT_NOT_ENOUGH_MONEY
call LoadBuyMenuText
call JoyWaitAorB
and a
ret
StandardMartAskPurchaseQuantity:
ld a, 99
ld [wItemQuantityBuffer], a
ld a, MARTTEXT_HOW_MANY
call LoadBuyMenuText
farcall SelectQuantityToBuy
call ExitMenu
ret
MartItemName:
ld a, [wCurItem]
ld [wNamedObjectIndexBuffer], a
ld a, [wMartSellingTM]
and a
jr z, .regular_mart
call GetTMHMName
ld de, wStringBuffer1
jp CopyName1
.regular_mart
call GetItemName
jp CopyName1
MartConfirmPurchase:
call MartItemName
ld a, MARTTEXT_COSTS_THIS_MUCH
call LoadBuyMenuText
call YesNoBox
ret
BargainShopAskPurchaseQuantity:
ld a, 1
ld [wItemQuantityChangeBuffer], a
ld a, [wMartItemID]
ld e, a
ld d, 0
ld b, CHECK_FLAG
ld hl, wBargainShopFlags
call FlagAction
ld a, c
and a
jr nz, .SoldOut
ld a, [wMartItemID]
ld e, a
ld d, 0
ld hl, wMartPointer
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
add hl, de
add hl, de
add hl, de
inc hl
ld a, [hli]
ldh [hMoneyTemp + 2], a
ld a, [hl]
ldh [hMoneyTemp + 1], a
xor a
ldh [hMoneyTemp], a
and a
ret
.SoldOut:
ld a, MARTTEXT_SOLD_OUT
call LoadBuyMenuText
call JoyWaitAorB
scf
ret
RooftopSaleAskPurchaseQuantity:
ld a, MARTTEXT_HOW_MANY
call LoadBuyMenuText
call .GetSalePrice
ld a, 99
ld [wItemQuantityBuffer], a
farcall RooftopSale_SelectQuantityToBuy
call ExitMenu
ret
.GetSalePrice:
ld a, [wMartItemID]
ld e, a
ld d, 0
ld hl, wMartPointer
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
add hl, de
add hl, de
add hl, de
inc hl
ld e, [hl]
inc hl
ld d, [hl]
ret
Text_Mart_HowMany:
; How many?
text_far UnknownText_0x1c4bfd
text_end
Text_Mart_CostsThisMuch:
; @ (S) will be ¥@ .
text_far UnknownText_0x1c4c08
text_end
MenuHeader_Buy:
db MENU_BACKUP_TILES ; flags
menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData
db 1 ; default option
.MenuData
db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
db 4, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
dbw 0, wCurMart
dba PlaceMartItemName
dba .PrintBCDPrices
dba UpdateItemDescriptionMart
.PrintBCDPrices:
ld a, [wScrollingMenuCursorPosition]
ld c, a
ld b, 0
ld hl, wMartItem1BCD
add hl, bc
add hl, bc
add hl, bc
push de
ld d, h
ld e, l
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
ld c, PRINTNUM_LEADINGZEROS | PRINTNUM_MONEY | 3
call PrintBCDNumber
ret
Text_HerbShop_Intro:
; Hello, dear. I sell inexpensive herbal medicine. They're good, but a trifle bitter. Your #MON may not like them. Hehehehe…
text_far UnknownText_0x1c4c28
text_end
Text_HerbShop_HowMany:
; How many?
text_far UnknownText_0x1c4ca3
text_end
Text_HerbShop_CostsThisMuch:
; @ (S) will be ¥@ .
text_far UnknownText_0x1c4cae
text_end
Text_HerbShop_HereYouGo:
; Thank you, dear. Hehehehe…
text_far UnknownText_0x1c4cce
text_end
Text_HerbShop_BagFull:
; Oh? Your PACK is full, dear.
text_far UnknownText_0x1c4cea
text_end
Text_HerbShop_InsufficientFunds:
; Hehehe… You don't have the money.
text_far UnknownText_0x1c4d08
text_end
Text_HerbShop_ComeAgain:
; Come again, dear. Hehehehe…
text_far UnknownText_0x1c4d2a
text_end
Text_BargainShop_Intro:
; Hiya! Care to see some bargains? I sell rare items that nobody else carries--but only one of each item.
text_far UnknownText_0x1c4d47
text_end
Text_BargainShop_CostsThisMuch:
; costs ¥@ . Want it?
text_far UnknownText_0x1c4db0
text_end
Text_BargainShop_HereYouGo:
; Thanks.
text_far UnknownText_0x1c4dcd
text_end
Text_BargainShop_BagFull:
; Uh-oh, your PACK is chock-full.
text_far UnknownText_0x1c4dd6
text_end
Text_BargainShop_SoldOut:
; You bought that already. I'm all sold out of it.
text_far UnknownText_0x1c4df7
text_end
Text_BargainShop_InsufficientFunds:
; Uh-oh, you're short on funds.
text_far UnknownText_0x1c4e28
text_end
Text_BargainShop_ComeAgain:
; Come by again sometime.
text_far UnknownText_0x1c4e46
text_end
Text_Pharmacist_Intro:
; What's up? Need some medicine?
text_far UnknownText_0x1c4e5f
text_end
Text_Pharmacy_HowMany:
; How many?
text_far UnknownText_0x1c4e7e
text_end
Text_Pharmacy_CostsThisMuch:
; @ (S) will cost ¥@ .
text_far UnknownText_0x1c4e89
text_end
Text_Pharmacy_HereYouGo:
; Thanks much!
text_far UnknownText_0x1c4eab
text_end
Text_Pharmacy_BagFull:
; You don't have any more space.
text_far UnknownText_0x1c4eb9
text_end
Text_Pharmacy_InsufficientFunds:
; Huh? That's not enough money.
text_far UnknownText_0x1c4ed8
text_end
Text_Pharmacist_ComeAgain:
; All right. See you around.
text_far UnknownText_0x1c4ef6
text_end
SellMenu:
ld a, [wMartSellingTM]
push af
xor a
ld [wMartSellingTM], a
call DisableSpriteUpdates
farcall DepositSellInitPackBuffers
.loop
farcall DepositSellPack
ld a, [wPackUsedItem]
and a
jp z, .quit
call .TryToSellItem
jr .loop
.quit
pop af
ld [wMartSellingTM], a
call ReturnToMapWithSpeechTextbox
and a
ret
.Unreferenced_NothingToSell:
ld hl, .NothingToSellText
call MenuTextboxBackup
and a
ret
.NothingToSellText:
; You don't have anything to sell.
text_far UnknownText_0x1c4f12
text_end
.TryToSellItem:
ld a, [wCurPocket]
cp TM_HM_POCKET
jr z, .cant_sell_tm
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
ld hl, .dw
rst JumpTable
ret
.dw
dw .try_sell
dw .cant_buy
dw .cant_buy
dw .cant_buy
dw .try_sell
dw .try_sell
dw .try_sell
.cant_buy
ret
.cant_sell_tm
ld hl, TextMart_CantBuyFromYou
call PrintText
and a
ret
.try_sell
farcall _CheckTossableItem
ld a, [wItemAttributeParamBuffer]
and a
jr z, .okay_to_sell
ld hl, TextMart_CantBuyFromYou
call PrintText
and a
ret
.okay_to_sell
ld hl, Text_Mart_SellHowMany
call PrintText
farcall PlaceMoneyAtTopLeftOfTextbox
farcall SelectQuantityToSell
call ExitMenu
jr c, .declined
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, Text_Mart_ICanPayThisMuch
call PrintTextboxText
call YesNoBox
jr c, .declined
ld de, wMoney
ld bc, hMoneyTemp
call GiveMoney
ld a, [wMartItemID]
ld hl, wNumItems
call TossItem
call MartItemName
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, Text_Mart_SoldForAmount
call PrintTextboxText
call PlayTransactionSound
farcall PlaceMoneyBottomLeft
call JoyWaitAorB
.declined
call ExitMenu
and a
ret
Text_Mart_SellHowMany:
; How many?
text_far UnknownText_0x1c4f33
text_end
Text_Mart_ICanPayThisMuch:
; I can pay you ¥@ . Is that OK?
text_far UnknownText_0x1c4f3e
text_end
.UnusedString15f7d:
db "!ダミー!@"
Text_Mart_HowMayIHelpYou:
; Welcome! How may I help you?
text_far UnknownText_0x1c4f62
text_end
MenuHeader_BuySell:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 7, 8
dw .MenuData
db 1 ; default option
.MenuData
db STATICMENU_CURSOR ; strings
db 3 ; items
db "BUY@"
db "SELL@"
db "QUIT@"
Text_Mart_HereYouGo:
; Here you are. Thank you!
text_far UnknownText_0x1c4f80
text_end
Text_Mart_InsufficientFunds:
; You don't have enough money.
text_far UnknownText_0x1c4f9a
text_end
Text_Mart_BagFull:
; You can't carry any more items.
text_far UnknownText_0x1c4fb7
text_end
TextMart_CantBuyFromYou:
; Sorry, I can't buy that from you.
text_far UnknownText_0x1c4fd7
text_end
Text_Mart_ComeAgain:
; Please come again!
text_far UnknownText_0x1c4ff9
text_end
Text_Mart_AnythingElse:
text_far UnknownText_0x1c500d
text_end
Text_Mart_SoldForAmount:
text_far UnknownText_0x1c502e
text_end
PlayTransactionSound:
call WaitSFX
ld de, SFX_TRANSACTION
call PlaySFX
ret
MartTextbox:
call MenuTextbox
call JoyWaitAorB
call ExitMenu
ret
|
InitBattle:
ld a, [wCurOpponent]
and a
jr z, asm_f6003
InitOpponent:
ld a, [wCurOpponent]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
jr asm_f601d
asm_f6003:
ld a, [wd732]
bit 1, a
jr z, .asm_f600f
ld a, [hJoyHeld]
bit 1, a ; B button pressed?
ret nz
.asm_f600f
ld a, [wNumberOfNoRandomBattleStepsLeft]
and a
ret nz
callab TryDoWildEncounter
ret nz
asm_f601d:
ld a, [wMapPalOffset]
push af
ld hl, wLetterPrintingDelayFlags
ld a, [hl]
push af
res 1, [hl]
call InitBattleVariables ; 3d:6236
ld a,[wTemp]
cp 10
jr z, InitWildBattle
ld a, [wEnemyMonSpecies2]
sub $c8 ;could do some over-ride here of species, or, diff over-ride to make wild pokemuns actually appear over this number?
jp c, InitWildBattle
ld [wTrainerClass], a
call GetTrainerInformation
callab ReadTrainer
callab DoBattleTransitionAndInitBattleVariables
call _LoadTrainerPic ; 3d:615a
xor a
ld [wEnemyMonSpecies2], a
ld [$ffe1], a
dec a
ld [wAICount], a
coord hl, 12, 0
predef CopyUncompressedPicToTilemap
ld a, $ff
ld [wEnemyMonPartyPos], a
ld a, $2
ld [wIsInBattle], a
; Is this a major story battle?
ld a,[wLoneAttackNo]
and a
jp z,InitBattle_Common
callabd_ModifyPikachuHappiness PIKAHAPPY_GYMLEADER ; useless since already in bank3d
jp InitBattle_Common
InitWildBattle:
ld a, $1
ld [wIsInBattle], a
callab LoadEnemyMonData
callab DoBattleTransitionAndInitBattleVariables
ld a, [wCurOpponent]
cp MAROWAK
jr z, .isGhost
callab IsGhostBattle
jr nz, .isNoGhost
.isGhost
ld hl, wMonHSpriteDim
ld a, $66
ld [hli], a ; write sprite dimensions
ld bc, GhostPic
ld a, c
ld [hli], a ; write front sprite pointer
ld [hl], b
ld hl, wEnemyMonNick ; set name to "GHOST"
ld a, "G"
ld [hli], a
ld a, "H"
ld [hli], a
ld a, "O"
ld [hli], a
ld a, "S"
ld [hli], a
ld a, "T"
ld [hli], a
ld [hl], "@"
ld a, [wcf91]
push af
ld a, MON_GHOST
ld [wcf91], a
ld de, vFrontPic
call LoadMonFrontSprite ; load ghost sprite
pop af
ld [wcf91], a
jr .spriteLoaded
.isNoGhost
ld de, vFrontPic
call LoadMonFrontSprite ; load mon sprite
.spriteLoaded
xor a
ld [wTrainerClass], a
ld [$ffe1], a
coord hl, 12, 0
predef CopyUncompressedPicToTilemap
; common code that executes after init battle code specific to trainer or wild battles
InitBattle_Common:
ld b, $0
call RunPaletteCommand
callab SlidePlayerAndEnemySilhouettesOnScreen
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld hl, .emptyString
call PrintText
call SaveScreenTilesToBuffer1
call ClearScreen
ld a, $98
ld [$ffbd], a
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
ld a, $9c
ld [$ffbd], a
call LoadScreenTilesFromBuffer1
coord hl, 9, 7
ld bc, $50a
call ClearScreenArea
coord hl, 1, 0
ld bc, $40a
call ClearScreenArea
call ClearSprites
ld a, [wIsInBattle]
dec a ; is it a wild battle?
ld hl, DrawEnemyHUDAndHPBar
ld b,BANK(DrawEnemyHUDAndHPBar)
call z, Bankswitch ; draw enemy HUD and HP bar if it's a wild battle
callab StartBattle
callab EndOfBattle
pop af
ld [wLetterPrintingDelayFlags], a
pop af
ld [wMapPalOffset], a
ld a, [wSavedTilesetType]
ld [hTilesetType], a
scf
ret
.emptyString
db "@"
_LoadTrainerPic:
; wd033-wd034 contain pointer to pic
ld a, [wTrainerPicPointer] ; wd033
ld e, a
ld a, [wTrainerPicPointer + 1] ; wd034
ld d, a ; de contains pointer to trainer pic
ld a, [wLinkState]
and a
ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's)
jr z, .loadSprite
ld a, Bank(RedPicFront)
.loadSprite
call UncompressSpriteFromDE
ld de, vFrontPic
ld a, $77
ld c, a
jp LoadUncompressedSpriteData
LoadMonBackPic:
; Assumes the monster's attributes have
; been loaded with GetMonHeader.
ld a, [wBattleMonSpecies2]
ld [wcf91], a
coord hl, 1, 5
ld bc,$708
call ClearScreenArea
ld a,[wTemp4]
cp BLASTOISE
jr z, .MegaLoad3
cp CHARIZARD
jr z, .MegaLoad
cp VENUSAUR
jr z, .MegaLoad2
ld hl, wMonHBackSprite - wMonHeader
call UncompressMonSprite
jp .Load
.MegaLoad
ld a, BANK(MegaCharizardPicBack)
ld de,MegaCharizardPicBack
call UncompressSpriteFromDE
jp .Load
.MegaLoad2
ld a, BANK(MegaVenusaurPicBack)
ld de,MegaVenusaurPicBack
call UncompressSpriteFromDE
jp .Load
.MegaLoad3
ld a, BANK(MegaBlastoisePicBack)
ld de,MegaBlastoisePicBack
call UncompressSpriteFromDE
.Load
callba LoadBackSpriteUnzoomed
ld hl, vSprites
ld de, vBackPic
ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied
ld a, [H_LOADEDROMBANK]
ld b, a
jp CopyVideoData
AnimateSendingOutMon:
ld a, [wPredefRegisters]
ld h, a
ld a, [wPredefRegisters + 1]
ld l, a
ld a, [$ffe1]
ld [H_DOWNARROWBLINKCNT1], a
ld b, $4c
ld a, [wIsInBattle]
and a
jr z, .asm_f61ef
add b
ld [hl], a
call Delay3
ld bc, -41
add hl, bc
ld a, $1
ld [wNumMovesMinusOne], a
ld bc, $303
predef CopyDownscaledMonTiles
ld c, $4
call DelayFrames
ld bc, -41
add hl, bc
xor a
ld [wNumMovesMinusOne], a
ld bc, $505
predef CopyDownscaledMonTiles
ld c, $5
call DelayFrames
ld bc, -41
jr .asm_f61f2
.asm_f61ef
ld bc, -123
.asm_f61f2
add hl, bc
ld a, [H_DOWNARROWBLINKCNT1]
add $31
jr CopyUncompressedPicToHL
CopyUncompressedPicToTilemap:
ld a, [wPredefRegisters]
ld h, a
ld a, [wPredefRegisters + 1]
ld l, a
ld a, [$ffe1]
CopyUncompressedPicToHL:
ld bc, $707
ld de, $14
push af
ld a, [wSpriteFlipped]
and a
jr nz, .asm_f6220
pop af
.asm_f6211
push bc
push hl
.asm_f6213
ld [hl], a
add hl, de
inc a
dec c
jr nz, .asm_f6213
pop hl
inc hl
pop bc
dec b
jr nz, .asm_f6211
ret
.asm_f6220
push bc
ld b, $0
dec c
add hl, bc
pop bc
pop af
.asm_f6227
push bc
push hl
.asm_f6229
ld [hl], a
add hl, de
inc a
dec c
jr nz, .asm_f6229
pop hl
dec hl
pop bc
dec b
jr nz, .asm_f6227
ret
INCLUDE "engine/battle/init_battle_variables.asm"
INCLUDE "engine/battle/moveEffects/focus_energy_effect.asm"
INCLUDE "engine/battle/moveEffects/heal_effect.asm"
INCLUDE "engine/battle/moveEffects/transform_effect.asm"
INCLUDE "engine/battle/moveEffects/reflect_light_screen_effect.asm"
INCLUDE "engine/battle/moveEffects/mist_effect.asm"
INCLUDE "engine/battle/moveEffects/one_hit_ko_effect.asm"
INCLUDE "engine/battle/moveEffects/pay_day_effect.asm"
INCLUDE "engine/battle/moveEffects/paralyze_effect.asm"
|
/*Consider the following program and fill in the blanks in LINE-1 with appropriate function
header so that it will take one argument as call by reference and in LINE-2 for the return statement.*/
#include <iostream>
using namespace std;
int Double(int a) { // LINE-1
return a*2; // LINE-2
}
int main() {
int x, y;
cin >> x >> y;
cout << Double(x + y);
return 0;
}
|
.include "defaults_mod.asm"
table_file_jp equ "exe4-utf8.tbl"
table_file_en equ "bn4-utf8.tbl"
game_code_len equ 3
game_code equ 0x4234574A // B4WJ
game_code_2 equ 0x42345745 // B4WE
game_code_3 equ 0x42345750 // B4WP
card_type equ 1
card_id equ 18
card_no equ "018"
card_sub equ "Mod Card 018"
card_sub_x equ 64
card_desc_len equ 3
card_desc_1 equ "Address 0D"
card_desc_2 equ "MegaFolder2"
card_desc_3 equ "Buggy"
card_name_jp_full equ "メガフォルダ2"
card_name_jp_game equ "メガフォルダ2"
card_name_en_full equ "MegaFolder2"
card_name_en_game equ "MegaFolder2"
card_address equ "0D"
card_address_id equ 3
card_bug equ 1
card_wrote_en equ "MegaFolder2"
card_wrote_jp equ "メガフォルダ2" |
define sysRandom $fe ; an address
define a_dozen $0c ; a constant
LDA sysRandom ; equivalent to "LDA $fe"
LDX #a_dozen ; equivalent to "LDX #$0c"
|
/*
ID: apiv2002
PROG: money
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
long long dp[27][10002];
int vals[26];
int n, v;
int main()
{
freopen("money.in", "r", stdin);
freopen("money.out", "w", stdout);
cin >> v >> n;
for (int i = 1; i <= v; i++) { cin >> vals[i]; }
for (int i = 0; i <= v; i++) { dp[i][0] = 1; }
for (int i = 1; i <= v; i++)
{
for (int j = 1; j <= n; j++)
{
for (int k = 0; (k * vals[i]) <= j; k++)
{
dp[i][j] += dp[i - 1][j - (k * vals[i])];
}
}
}
cout << dp[v][n] << endl;
return 0;
} |
INCLUDE "config_private.inc"
SECTION code_driver
SECTION code_driver_terminal_output
PUBLIC rc_01_output_siob_oterm_msg_bell
PUBLIC rc_01_output_siob_oterm_msg_bell_0
EXTERN rc_01_output_siob_oterm_msg_putc_send
rc_01_output_siob_oterm_msg_bell:
; can use: af, bc, de, hl
bit 0,(ix+7)
ret z ; if bell disabled
rc_01_output_siob_oterm_msg_bell_0:
ld c,CHAR_BELL
jp rc_01_output_siob_oterm_msg_putc_send
|
// This is core/vnl/io/tests/test_matrix_fixed_io.cxx
#include <vcl_iostream.h>
#include <vnl/vnl_matrix_fixed.h>
#include <vnl/io/vnl_io_matrix_fixed.h>
#include <testlib/testlib_test.h>
#include <vpl/vpl.h>
void test_matrix_fixed_double_2_2_io()
{
vcl_cout << "***************************************\n"
<< "Testing vnl_matrix_fixed<double,2,2> io\n"
<< "***************************************\n";
//// test constructors, accessors
double datablock[4] = {
1.1, 1.2,
2.1, 2.2
};
vnl_matrix_fixed<double,2,2> m_out(datablock), m_in0,m_in1;
// Give some initial content
m_in1 = m_out * 2.0;
vsl_b_ofstream bfs_out("vnl_matrix_fixed_io.bvl.tmp",
vcl_ios_out | vcl_ios_binary);
TEST ("vnl_matrix_fixed_io.bvl.tmp for writing", (!bfs_out), false);
vsl_b_write(bfs_out, m_out);
vsl_b_write(bfs_out, m_out);
bfs_out.close();
vsl_b_ifstream bfs_in("vnl_matrix_fixed_io.bvl.tmp",
vcl_ios_in | vcl_ios_binary);
TEST ("vnl_matrix_fixed_io.bvl.tmp for reading", (!bfs_in), false);
vsl_b_read(bfs_in, m_in0);
vsl_b_read(bfs_in, m_in1);
bfs_in.close();
vpl_unlink ("vnl_matrix_fixed_io.bvl.tmp");
// m_in0 is initially empty
TEST ("m_out == m_in0", m_out, m_in0);
// m_in1 has content
TEST ("m_out == m_in1", m_out, m_in1);
vsl_print_summary(vcl_cout, m_out);
vcl_cout << vcl_endl;
}
void test_matrix_fixed_io()
{
test_matrix_fixed_double_2_2_io();
}
TESTMAIN(test_matrix_fixed_io);
|
; A142933: Primes congruent to 17 mod 64.
; Submitted by Jon Maiga
; 17,337,401,593,977,1297,1361,1489,1553,1873,2129,2833,2897,3089,3217,3793,4049,4177,4241,4561,4817,5009,5393,5521,6353,6481,6673,6737,7057,7121,8017,8081,8209,8273,8849,9041,10193,10321,10513,12049,12113,12241,12433,12497,12689,13009,13457,13649,13841,14033,14737,14929,15121,15313,15377,15569,15761,15889,16273,16529,16657,17041,17489,17681,18257,19793,20113,20177,20369,20753,21521,21649,21713,21841,22481,22993,23057,23633,23761,24337,24593,24977,25169,25873,26321,26449,26513,26641,26833,27281
mov $2,$0
add $2,6
pow $2,2
lpb $2
mov $3,$4
add $3,16
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,64
lpe
mov $0,$4
add $0,17
|
%include "x86-helpers.asm"
nasm_util_assert_boilerplate
thunk_boilerplate
; a variant of define_bench that puts a "touch" function immediately following
; the
%macro make_touch 0
%ifndef current_bench
%error "current_bench must be defined for this to work"
%endif
GLOBAL current_bench %+ _touch:function
current_bench %+ _touch:
ret
%endmacro
;; This function executes a tight loop, where we expect that each iteration takes
;; once cycle (plus some penalty on loop exit due to the mispredict). We time this
;; function to calculate the effective CPU frequency. We could also consider a series
;; of dependent add calls, which we expect to each take 1 cycle as well. It isn't
;; really clear which assumption is the most likely to be true in the future, but
;; most delay loops seem to be of the "tight loop" variety, so let's choose that.
;; In the past, both of these approaches would have returned wrong values, e.g.,
;; twice the true frequency for the "add" approach on the double-pumped ALU on the P4
;; or half or less than the true frequency on CPUs that can't issue one taken branch
;; per cycle.
GLOBAL add_calibration_x86:function
ALIGN 32
add_calibration_x86:
times 2 sub rdi, 1
jge add_calibration_x86
ret
define_bench dummy_bench_oneshot1
ret
define_bench dummy_bench_oneshot2
ret
make_touch
define_bench dep_add_noloop_128
xor eax, eax
times 128 add rax, rax
ret
define_bench dep_add_rax_rax
xor eax, eax
.top:
times 128 add rax, rax
dec rdi
jnz .top
ret
define_bench dep_imul128_rax
xor eax, eax
.top:
times 128 imul rax
dec rdi
jnz .top
ret
; because the 64x64=128 imul uses an implicit destination & first source
; we need to clear out eax each iteration to make it independent, although
; of course that may bias the measurement on some architectures
define_bench indep_imul128_rax
.top:
%rep 128
xor eax, eax
imul rax
%endrep
dec rdi
jnz .top
ret
define_bench dep_imul64_rax
xor eax, eax
.top:
times 128 imul rax, rax
dec rdi
jnz .top
ret
define_bench indep_imul64_rax
.top:
%rep 128
xor eax, eax
imul rax, rax
%endrep
dec rdi
jnz .top
ret
define_bench dep_pushpop
xor eax, eax
xor ecx, ecx
.top:
%rep 128
push rax
pop rax
%endrep
dec rdi
jnz .top
ret
define_bench indep_pushpop
xor eax, eax
xor ecx, ecx
.top:
%rep 128
push rax
pop rcx
%endrep
dec rdi
jnz .top
ret
define_bench div_64_64
xor eax,eax
xor edx,edx
mov ecx, 1
.top:
times 128 div rcx
dec rdi
jnz .top
ret
define_bench idiv_64_64
xor eax,eax
xor edx,edx
mov ecx, 1
.top:
times 128 idiv rcx
dec rdi
jnz .top
ret
define_bench nop1_128
.top:
times 128 nop
dec rdi
jnz .top
ret
define_bench nop2_128
.top:
times 128 nop2
dec rdi
jnz .top
ret
define_bench xor_eax_128
.top:
times 128 xor eax, eax
dec rdi
jnz .top
ret
%if 1
%macro define_alu_load 1
define_bench alu_load_6_%1
push_callee_saved
.top:
%rep 64
add eax, 1
add ebx, 1
add ecx, 1
add edx, 1
add esi, 1
add ebp, 1
%assign rnum 8
%rep %1
mov r %+ rnum, [rsp + (rnum - 8) * 4]
%assign rnum (rnum + 1)
%endrep
%undef rnum
%endrep
dec rdi
jnz .top
pop_callee_saved
ret
%endmacro
define_alu_load 0
define_alu_load 1
define_alu_load 2
define_alu_load 3
define_alu_load 4
define_alu_load 5
define_alu_load 6
%endif
empty_fn:
ret
define_bench dense_calls
.top:
%rep 16
call empty_fn
;nop
%endrep
dec rdi
jnz .top
ret
%macro sparse_calls 1
define_bench sparse %+ %1 %+ _calls
xor eax, eax
.top:
%rep 16
call empty_fn
times %1 add eax, 1
%endrep
dec rdi
jnz .top
ret
%endmacro
sparse_calls 0
sparse_calls 1
sparse_calls 2
sparse_calls 3
sparse_calls 4
sparse_calls 5
sparse_calls 6
sparse_calls 7
%macro chained_calls 1
define_bench chained %+ %1 %+ _calls
xor eax, eax
.top:
%rep 4
call call_chain_3
times %1 add eax, 1
%endrep
dec rdi
jnz .top
ret
%endmacro
chained_calls 0
chained_calls 1
chained_calls 2
chained_calls 3
pushpop:
push rax
pop rax
ret
define_bench pushpop_calls
xor eax, eax
.top:
%rep 16
call pushpop
%endrep
dec rdi
jnz .top
ret
%macro addrsp 1
addrsp%1:
add QWORD [rax - %1], 0
add QWORD [rax - %1], 0
ret
%endmacro
%macro addrsp_calls 1
addrsp %1
define_bench addrsp%1_calls
lea rax, [rsp - 8]
.top:
%rep 16
call addrsp%1
%endrep
dec rdi
jnz .top
ret
%endmacro
addrsp_calls 0
addrsp_calls 8
define_bench indep_add
.top:
%rep 50
add eax, ebp
add ecx, ebp
add edx, ebp
add esi, ebp
add r8d, ebp
add r9d, ebp
add r10d, ebp
add r11d, ebp
%endrep
dec rdi
jnz .top
ret
; a basic bench that repeats a single op the given number
; of times, defaults to 128
; %1 the benchmark name
; %2 the full operation
; %3 the default of repeates (128 if not specified)
%macro define_single_op 2-3 128
define_bench %1
xor eax, eax
.top:
times %3 %2
dec rdi
jnz .top
ret
%endmacro
define_single_op rdtsc_bench,rdtsc
define_single_op rdtscp_bench,rdtscp
; pointer chasing loads from a single stack location on the stack
; %1 name suffix
; %2 load expression (don't include [])
; %3 offset if any to apply to pointer and load expression
%macro make_spc 3
define_bench sameloc_pointer_chase%1
or rcx, -1
inc rcx ; rcx is zero but this is just a fancy way of doing it to defeat zero-idiom recognition
lea rax, [rsp - 8 - %3]
push rax
.top:
times 128 mov rax, [%2 + %3]
dec rdi
jnz .top
pop rax
ret
%endmacro
make_spc ,rax,0
make_spc _complex,rax + rcx * 8,4096
; https://stackoverflow.com/q/52351397
define_bench sameloc_pointer_chase_diffpage
push rbp
mov rbp, rsp
sub rsp, 4096
and rsp, -4096 ; align rsp to page boundary
lea rax, [rsp - 8]
mov [rax + 16], rax
.top:
times 128 mov rax, [rax + 16]
dec rdi
jnz .top
mov rsp, rbp
pop rbp
ret
; https://stackoverflow.com/q/52351397
define_bench sameloc_pointer_chase_alt
push rbp
mov rbp, rsp
sub rsp, 4096
and rsp, -4096 ; align rsp to page boundary
lea rax, [rsp - 8]
mov [rax], rax
mov [rax + 16], rax
.top:
%rep 64
mov rax, [rax]
mov rax, [rax + 16]
%endrep
dec rdi
jnz .top
mov rsp, rbp
pop rbp
ret
; put an ALU op in the pointer chase path
define_bench sameloc_pointer_chase_alu
lea rax, [rsp - 8]
push rax
.top:
%rep 128
mov rax, [rax]
add rax, 0
%endrep
dec rdi
jnz .top
pop rax
ret
; put an ALU op in the pointer chase path
define_bench sameloc_pointer_chase_alu2
push rbp
mov rbp, rsp
and rsp, -4096 ; page align rsp to avoid inadvertent page crossing
sub rsp, 2048 + 4096
and rcx, 0 ; avoid zero idiom detection
lea rax, [rsp - 8]
push rax
mov [rax + 2048], rax
.top:
%rep 128
mov rax, [rax + 2048]
mov rax, [rax]
add rax, 0
%endrep
dec rdi
jnz .top
mov rsp, rbp
pop rbp
ret
; put an ALU op in the pointer chase path
define_bench sameloc_pointer_chase_alu3
push rbp
mov rbp, rsp
and rsp, -4096 ; page align rsp to avoid inadvertent page crossing
sub rsp, 2048 + 4096
and rcx, 0 ; avoid zero idiom detection
lea rax, [rsp - 8]
push rax
mov [rax + 2048], rax
.top:
%rep 128
mov rax, [rax + 2048]
add rax, 0
mov rax, [rax]
%endrep
dec rdi
jnz .top
mov rsp, rbp
pop rbp
ret
; do 8 parallel pointer chases to see if fast path (4-cycle) loads
; have a throughput restriction (e.g., only 1 per cycle)
define_bench sameloc_pointer_chase_8way
push rbp
mov rbp, rsp
and rsp, -4096 ; page align rsp to avoid inadvertent page crossing
push r12
push r13
push r14
push r15
%assign regn 8
%rep 8
%define reg r %+ regn
lea reg, [rsp - 8]
push reg
%assign regn (regn + 1)
%endrep
.top:
%rep 16
%assign regn 8
%rep 8
%define reg r %+ regn
mov reg, [reg]
%assign regn (regn + 1)
%endrep
%endrep
dec rdi
jnz .top
add rsp, 8 * 8
pop r15
pop r14
pop r13
pop r12
mov rsp, rbp
pop rbp
ret
; so we can treat r6 to r15 as a contiguous range
%define r6 rsi
%define r7 rdi
; do 10 parallel pointer chases to see if slow path (5-cycle) loads
; have a throughput restriction (e.g., only 1 per cycle)
define_bench sameloc_pointer_chase_8way5
push rbp
mov rbp, rsp
sub rsp, 8192
and rsp, -4096 ; page align rsp to avoid inadvertent page crossing
push r12
push r13
push r14
push r15
mov rcx, rdi ; because we need rdi and rsi as r6 and r7 with altreg
%define offset 4096
%assign regn 6
%rep 10
%define reg r %+ regn
lea reg, [rsp - 8 - offset]
push reg
%assign regn (regn + 1)
%endrep
.top:
%rep 16
%assign regn 6
%rep 10
%define reg r %+ regn
mov reg, [reg + offset]
%assign regn (regn + 1)
%endrep
%endrep
dec rcx
jnz .top
add rsp, 10 * 8
pop r15
pop r14
pop r13
pop r12
mov rsp, rbp
pop rbp
ret
; do 10 parallel pointer chases, unrolled 10 times, where 9 out of the 10
; accesses on each change are 5-cycle and one is 4-cycle, to see if mixing
; 4 and 5-cycle operations slows things down
define_bench sameloc_pointer_chase_8way45
push rbp
mov rbp, rsp
sub rsp, 8192
and rsp, -8192 ; page align rsp to avoid inadvertent page crossing
push r12
push r13
push r14
push r15
mov rcx, rdi
%define offset 4096
%define regcnt 10
%assign regn (16 - regcnt)
%rep regcnt
%define reg r %+ regn
lea reg, [rsp - 8]
push reg
mov [reg + offset], reg
%assign regn (regn + 1)
%endrep
.top:
%assign itr 0
%rep 10
%assign regn (16 - regcnt)
%rep regcnt
%define reg r %+ regn
%if (itr == (regn - (16 - regcnt)))
mov reg, [reg]
%else
mov reg, [reg + offset]
%endif
%assign regn (regn + 1)
%endrep
%assign itr (itr + 1)
%endrep
dec rcx
jnz .top
add rsp, regcnt * 8
pop r15
pop r14
pop r13
pop r12
mov rsp, rbp
pop rbp
ret
; a series of stores to the same location
define_bench store_same_loc
xor eax, eax
.top:
times 128 mov [rsp - 8], eax
dec rdi
jnz .top
ret
; a series of 16-bit stores to the same location, passed as the second parameter
define_bench store16_any
xor eax, eax
.top:
times 128 mov [rsi], ax
dec rdi
jnz .top
ret
; a series of 32-bit stores to the same location, passed as the second parameter
define_bench store32_any
xor eax, eax
.top:
times 128 mov [rsi], eax
dec rdi
jnz .top
ret
; a series of 64-bit stores to the same location, passed as the second parameter
define_bench store64_any
xor eax, eax
.top:
times 128 mov [rsi], rax
dec rdi
jnz .top
ret
; a series of AVX (REX-encoded) 128-bit stores to the same location, passed as the second parameter
define_bench store128_any
vpxor xmm0, xmm0, xmm0
.top:
times 128 vmovdqu [rsi], xmm0
dec rdi
jnz .top
ret
; a series of AVX (REX-encoded) 256-bit stores to the same location, passed as the second parameter
define_bench store256_any
vpxor xmm0, xmm0, xmm0
.top:
times 128 vmovdqu [rsi], ymm0
dec rdi
jnz .top
ret
; a series of AVX512 512-bit stores to the same location, passed as the second parameter
define_bench store512_any
vpxorq zmm16, zmm16, zmm16
.top:
times 128 vmovdqu64 [rsi], zmm16
dec rdi
jnz .top
ret
; a series of independent 16-bit loads from the same location, with location passed as the second parameter
; note that the loads are not zero-extended, so they only write the lower 16 bits of eax, and so on some
; implementations each load is actually dependent on the previous load (to merge in the upper bits of eax)
define_bench load16_any
xor eax, eax
.top:
times 128 mov ax, [rsi]
dec rdi
jnz .top
ret
; a series of independent 32-bit loads from the same location, with location passed as the second parameter
define_bench load32_any
.top:
times 128 mov eax, [rsi]
dec rdi
jnz .top
ret
; a series of independent 64-bit loads from the same location, with location passed as the second parameter
define_bench load64_any
.top:
times 128 mov rax, [rsi]
dec rdi
jnz .top
ret
; a series of independent 128-bit loads from the same location, with location passed as the second parameter
define_bench load128_any
.top:
times 128 vmovdqu xmm0, [rsi]
dec rdi
jnz .top
ret
; a series of independent 256-bit loads from the same location, with location passed as the second parameter
define_bench load256_any
.top:
%rep 64
vmovdqu ymm0, [rsi]
vmovdqu ymm1, [rsi]
%endrep
dec rdi
jnz .top
ret
; a series of independent 256-bit loads from the same location, with location passed as the second parameter
define_bench load512_any
.top:
%rep 64
vmovdqu64 zmm16, [rsi]
vmovdqu64 zmm16, [rsi]
%endrep
dec rdi
jnz .top
ret
; a series of stores to increasing locations without overlap, 1024 total touched
define_bench store64_disjoint
xor eax, eax
sub rsp, 1024
.top:
%assign offset 0
%rep 128
mov [rsp + offset], rax
%assign offset offset+8
%endrep
dec rdi
jnz .top
add rsp, 1024
ret
; Weird case where 32-bit add with memory source runs faster than 64-bit version
; Search for "Totally bizarre" in https://www.agner.org/optimize/blog/read.php?i=423
define_bench misc_add_loop32
push rbp
mov rbp, rsp
push rbx
mov rcx, rdi
sub rsp, 256
and rsp, -64
lea rax, [rsp + 64]
lea rdi, [rsp + 128]
jmp .top
ALIGN 32
.top:
add edx, [rsp]
mov [rax], edi
blsi ebx, [rdi]
dec ecx
jnz .top
; cleanup
mov rbx, [rbp - 8]
mov rsp, rbp
pop rbp
ret
define_bench misc_add_loop64
push rbp
mov rbp, rsp
push rbx
mov rcx, rdi
sub rsp, 256
and rsp, -64
lea rax, [rsp + 64]
lea rdi, [rsp + 128]
; oddly, the slowdown goes away when you do a 256-bit AVX op, like
; the ymm vpxor below, but not for xmm (at least with vzeroupper)
;vpxor ymm0, ymm0, ymm0
;vzeroupper
;vpxor xmm0, xmm0, xmm0
jmp .top
ALIGN 32
.top:
add rdx, [rsp]
mov [rax], rdi
blsi rbx, [rdi]
dec ecx
jnz .top
; cleanup
mov rbx, [rbp - 8]
mov rsp, rbp
pop rbp
ret
define_bench misc_port7
mov rax, rsp
mov rsi, [rsp]
xor edx, edx
.top:
mov ecx, [rax]
mov ecx, [rax]
mov [rax + rdx * 8], rsi
dec rdi
jnz .top
ret
define_bench misc_fusion_add
xor eax, eax
.top:
times 128 add ecx, [rsp]
dec rdi
jnz .top
ret
; does add-jo macro-fuse? (no, on Skylake and earlier)
define_bench misc_macro_fusion_addjo
xor eax, eax
.top:
%rep 128
add eax, 1
jo .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
; is adc, 0 treated specially compared to other immediates?
%macro adc_lat_bench 1
define_bench adc_%1_lat
xor eax, eax
xor ecx, ecx
.top:
times 128 adc rax, %1
dec rdi
jnz .top
ret
ud2
%endmacro
adc_lat_bench 0
adc_lat_bench 1
adc_lat_bench rcx
; is adc, 0 treated specially compared to other immediates?
%macro adc_tput_bench 1
define_bench adc_%1_tput
xor eax, eax
xor ecx, ecx
.top:
%rep 128
xor eax, eax
adc rax, %1
%endrep
dec rdi
jnz .top
ret
ud2
%endmacro
adc_tput_bench 0
adc_tput_bench 1
adc_tput_bench rcx
define_bench misc_flag_merge_1
xor eax, eax
.top:
%rep 128
add rcx, 5
inc rax
jna .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_2
xor eax, eax
.top:
%rep 128
add rcx, 5
inc rax
jc .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_3
xor eax, eax
.top:
%rep 128
inc rax
add rcx, 5
jo .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_4
xor eax, eax
.top:
%rep 128
add rcx, 5
dec rax
nop
jg .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_5
xor eax, eax
.top:
%rep 128
add rcx, 5
inc rax
nop
jna .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_6
xor eax, eax
.top:
%rep 128
add rcx, 5
inc rax
cmovbe rdx, r8
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_7
xor eax, eax
.top:
%rep 128
add rcx, 5
inc rax
cmovc rdx, r8
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_8
xor eax, eax
.top:
%rep 128
inc rax
add rcx, 5
cmovbe rdx, r8
%endrep
dec rdi
jnz .top
ret
.never:
ud2
define_bench misc_flag_merge_9
xor eax, eax
mov ecx, 1
mov edx, 1
.top:
%rep 128
and rcx, rdx
nop
jbe .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
; https://twitter.com/david_schor/status/1106687885825241089
define_bench david_schor1
push rbx
mov rdx, rdi
.l:
inc rax
inc rbx
inc rcx
nop
nop
dec rdx
jnz .l
pop rbx
ret
; args:
; %1 the number of cmp, je pairs in the main loop
%macro define_macro_fusion 1
define_bench double_macro_fusion%1
mov eax, 1
.top:
%rep %1
cmp eax, 0
je .never
%endrep
dec rdi
jnz .top
ret
.never:
ud2
%endmacro
; can two macro fused branches per cycle be sustained?
define_macro_fusion 256
define_macro_fusion 4000
define_bench dendibakh_fused
mov rax, rdi
shl rax, 2
sub rsp, rax
.fused_loop:
inc DWORD [rsp + rdi * 4 - 4]
dec rdi
jnz .fused_loop
add rsp, rax
ret
define_bench dendibakh_fused_simple
mov rax, rdi
shl rax, 2
lea rcx, [rsp - 4]
sub rsp, rax
.fused_loop:
inc DWORD [rcx]
sub rcx, 4
dec rdi
jnz .fused_loop
add rsp, rax
ret
define_bench dendibakh_fused_add_simple
mov rax, rdi
shl rax, 2
lea rcx, [rsp - 4]
sub rsp, rax
.fused_loop:
add DWORD [rcx], 1
sub rcx, 4
dec rdi
jnz .fused_loop
add rsp, rax
ret
define_bench dendibakh_fused_add
mov rax, rdi
shl rax, 2
sub rsp, rax
.fused_loop:
add DWORD [rsp + rdi * 4 - 4], 1
dec rdi
jnz .fused_loop
add rsp, rax
ret
define_bench dendibakh_unfused
mov rax, rdi
shl rax, 2
sub rsp, rax
.unfused_loop:
mov edx, DWORD [rsp + rdi * 4 - 4]
inc edx
mov DWORD [rsp + rdi * 4 - 4], edx
dec rdi
jnz .unfused_loop
add rsp, rax
ret
define_bench vz_samereg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq zmm0, zmm0, zmm0
dec rdi
jnz .top
ret
define_bench vz_diffreg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq zmm0, zmm1, zmm0
dec rdi
jnz .top
ret
define_bench vz_diffreg16
xor ecx, ecx
vpxorq zmm16, zmm16, zmm16
vzeroall
.top:
times 100 vpaddq zmm0, zmm16, zmm0
dec rdi
jnz .top
ret
define_bench vz_diffreg16xor
xor ecx, ecx
vzeroall
vpxorq xmm16, xmm16, xmm16
.top:
times 100 vpaddq zmm0, zmm16, zmm0
dec rdi
jnz .top
ret
define_bench vz256_samereg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq ymm0, ymm0, ymm0
dec rdi
jnz .top
ret
define_bench vz256_diffreg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq ymm0, ymm1, ymm0
dec rdi
jnz .top
ret
define_bench vz128_samereg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq xmm0, xmm0, xmm0
dec rdi
jnz .top
ret
define_bench vz128_diffreg
xor ecx, ecx
vzeroall
.top:
times 100 vpaddq xmm0, xmm1, xmm0
dec rdi
jnz .top
ret
define_bench vzsse_samereg
xor ecx, ecx
vzeroall
.top:
times 100 paddq xmm0, xmm0
dec rdi
jnz .top
ret
define_bench vzsse_diffreg
xor ecx, ecx
vzeroall
.top:
times 100 paddq xmm0, xmm1
dec rdi
jnz .top
ret
%define fused_unroll_order 4
%define fused_unroll (1 << fused_unroll_order)
define_bench fusion_better_fused
push_callee_saved
xor eax, eax
xor edx, edx
xor r8d, r8d
shr rdi, fused_unroll_order
mov rcx, rsi
jmp .top
ALIGN 64
.top:
%assign offset 0
%rep fused_unroll
add r8d, DWORD [rcx ]
add r9d, DWORD [rcx ]
add r10d, DWORD [rcx ]
add r11d, DWORD [rcx ]
test r12d, 1
test r13d, 1
test r14d, 1
test r15d, 1
; xor r14d, r10d
; xor r15d, r11d
%assign offset (offset + 16)
%endrep
add rcx, (fused_unroll * 16)
dec rdi
jnz .top
xor eax, edx
pop_callee_saved
ret
define_bench fusion_better_unfused
xor eax, eax
mov rcx, rsi
jmp .top
ALIGN 64
.top:
add eax, DWORD [rcx]
add edx, DWORD [rcx + 4]
add rcx, 8
dec rdi
jnz .top
xor eax, edx
ret
%macro bmi_bench 1
define_bench bmi_%1
xor eax, eax
xor ecx, ecx
.top:
times 128 %1 eax, ecx
dec rdi
jnz .top
ret
%endmacro
bmi_bench tzcnt
bmi_bench lzcnt
bmi_bench popcnt
%define STRIDE 832 ; 13 * 64
; %1 - bench size in KiB
; %2 - load instruction
; %3 - bench name
%macro load_loop_bench_tmpl 3
; parallel loads with large stride (across pages, defeating prefetcher)
define_bench %3%1
%define SIZE (%1 * 1024)
xor ecx, ecx
mov rdx, rsi
.top:
%define UF 8
%assign s 0
%rep UF
%2 [rdx + STRIDE * s]
%assign s s+1
%endrep
; check if final read of the next unrolled iteration will exceed the requested size
; and if so, wrap back to the start. Due to the runolling this means that the last
; few loads might be skipped, making the effective footprint somewhat smaler than
; requested by something like UF * 0.5 * STRIDE on average (mostly relevant for buffer
; sizes just above a cache size boundary)
lea edx, [ecx + STRIDE * (UF*2-1) - SIZE]
add ecx, STRIDE * UF
test edx, edx
cmovns ecx, edx
lea rdx, [rsi + rcx]
dec rdi
jnz .top
ret
%endmacro
%macro all_parallel_benches 2
load_loop_bench_tmpl 16,{%1},%2
load_loop_bench_tmpl 32,{%1},%2
load_loop_bench_tmpl 64,{%1},%2
load_loop_bench_tmpl 128,{%1},%2
load_loop_bench_tmpl 256,{%1},%2
load_loop_bench_tmpl 512,{%1},%2
load_loop_bench_tmpl 2048,{%1},%2
%endmacro
all_parallel_benches {movzx eax, BYTE},load_loop
all_parallel_benches prefetcht0,prefetcht0_bench
all_parallel_benches prefetcht1,prefetcht1_bench
all_parallel_benches prefetcht2,prefetcht2_bench
all_parallel_benches prefetchnta,prefetchnta_bench
%define UF 8
; all loads happen in parallel, so maximum MLP can be achieved
%macro parallel_mem_bench 3
define_bench parallel_mem_bench_%2
mov rax, [rsi + region.size]
mov rsi, [rsi + region.start]
neg rax
lea r9, [STRIDE * (2*UF-1) + eax]
xor ecx, ecx ; index
mov rdx, rsi ; offset into region
.top:
%assign s 0
%rep UF
%1 [rdx + STRIDE * s] %3
%assign s s+1
%endrep
; check if final read of the next unrolled iteration will exceed the requested size
; and if so, wrap back to the start. Due to the runolling this means that the last
; few loads might be skipped, making the effective footprint somewhat smaler than
; requested by something like UF * 0.5 * STRIDE on average (mostly relevant for buffer
; sizes just above a cache size boundary)
lea edx, [rcx + r9]
add ecx, STRIDE * UF
test edx, edx
cmovns ecx, edx
lea rdx, [rsi + rcx]
dec rdi
jnz .top
ret
%endmacro
parallel_mem_bench {movzx eax, BYTE},load,{}
parallel_mem_bench prefetcht0,prefetcht0,{}
parallel_mem_bench prefetcht1,prefetcht1,{}
parallel_mem_bench prefetcht2,prefetcht2,{}
parallel_mem_bench prefetchnta,prefetchnta,{}
parallel_mem_bench mov DWORD,store,{, 42}
; classic pointer chasing benchmark
define_bench serial_load_bench
mov rsi, [rsi + region.start]
.top:
mov rsi, [rsi]
dec rdi
jnz .top
ret
%ifndef UNROLLB
%define UNROLLB 10
%endif
; %1 size of store in bytes
; %2 full instruction to use
; %3 prefix for benchmark name
%macro define_bandwidth 3
%assign BITSIZE (%1*8)
define_bench %3_bandwidth_ %+ BITSIZE
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
xor eax, eax
vpxor ymm0, ymm0, ymm0
.top:
mov rax, rdx
mov rcx, rsi
.inner:
%assign offset 0
%rep (64 / %1)
%2
%assign offset (offset + %1)
%endrep
%undef offset ; needed to prevent offset from being expanded wrongly in the macro invocations below
add rcx, 64
sub rax, 64
jge .inner
dec rdi
jnz .top
ret
%endmacro
define_bandwidth 4,{mov [rcx + offset], eax},store
define_bandwidth 8,{mov [rcx + offset], rax},store
define_bandwidth 16,{vmovdqa [rcx + offset],xmm0},store
define_bandwidth 32,{vmovdqa [rcx + offset],ymm0},store
define_bandwidth 64,{vmovdqa64[rcx + offset],zmm0},store
define_bandwidth 4,{mov r8d, [rcx + offset]},load
define_bandwidth 8,{mov r8 , [rcx + offset]},load
define_bandwidth 16,{vmovdqa xmm0, [rcx + offset]},load
define_bandwidth 32,{vmovdqa ymm0, [rcx + offset]},load
define_bandwidth 64,{vmovdqa64 zmm0, [rcx + offset]},load
define_bandwidth 64,{movzx r8d, BYTE [rcx + offset]},loadtouch
; version that doesn't interleave the loads in a "clever way"
define_bench bandwidth_test256
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
.top:
mov rax, rdx
mov rcx, rsi
vpxor ymm0, ymm0, ymm0
vpxor ymm1, ymm1, ymm1
.inner:
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
vpaddb ymm1, ymm1, [rcx + offset + 32]
%assign offset (offset + 64)
%endrep
add rcx, UNROLLB * 64
sub rax, UNROLLB * 64
jge .inner
dec rdi
jnz .top
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define_bench bandwidth_test256i_unroll
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
.top:
mov rax, rdx
mov rcx, rsi
lfence
vpxor ymm0, ymm0, ymm0
vpxor ymm1, ymm1, ymm1
vpxor ymm2, ymm2, ymm2
vpxor ymm3, ymm3, ymm3
.inner:
%assign offset 0
%rep UNROLLB/2
vpaddb ymm0, ymm0, [rcx + offset]
vpaddb ymm1, ymm1, [rcx + offset + 64]
%assign offset (offset + 128)
%endrep
.tail1:
%if (UNROLLB % 2 == 1)
vpaddb ymm0, ymm0, [rcx + offset]
%endif
.second:
%assign offset 32
%rep UNROLLB/2
vpaddb ymm2, ymm2, [rcx + offset]
vpaddb ymm3, ymm3, [rcx + offset + 64]
%assign offset (offset + 128)
%endrep
.tail2:
%if (UNROLLB % 2 == 1)
vpaddb ymm2, ymm2, [rcx + offset]
%endif
add rcx, UNROLLB * 64
sub rax, UNROLLB * 64
jge .inner
dec rdi
jnz .top
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define_bench bandwidth_test256i_orig
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
.top:
mov rax, rdx
mov rcx, rsi
lfence
vpxor ymm0, ymm0, ymm0
vpxor ymm1, ymm1, ymm1
.inner:
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
%assign offset (offset + 64)
%endrep
%assign offset 32
%rep UNROLLB
vpaddb ymm1, ymm1, [rcx + offset]
%assign offset (offset + 64)
%endrep
add rcx, UNROLLB * 64
sub rax, UNROLLB * 64
jge .inner
dec rdi
jnz .top
ret
%ifndef UNROLLX
;%warning UNROLLX defined to default of 1
%define UNROLLX 1
%else
;%warning 'UNROLLX' defined externally to UNROLLX
%endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define_bench bandwidth_test256i_single
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
.top:
mov rax, rdx
sub rax, UNROLLB * 64 ; reduce main loop iterations since the intro/outro parts handle this
mov rcx, rsi
lfence
vpxor ymm0, ymm0, ymm0
vpxor ymm1, ymm1, ymm1
vpxor ymm2, ymm1, ymm1
; lead-in loop which reads the first half of the first UNROLLB cache lines
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
%assign offset (offset + 64)
%endrep
.inner:
%assign offset 0
%rep UNROLLX
vpaddb ymm0, ymm0, [rcx + offset + UNROLLB * 64]
vpaddb ymm1, ymm1, [rcx + offset + 32]
%assign offset (offset + 64)
%endrep
add rcx, UNROLLX * 64
sub rax, UNROLLX * 64
jge .inner
; lead out loop to read the remaining lines
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
%assign offset (offset + 64)
%endrep
dec rdi
jnz .top
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define_bench bandwidth_test256i_double
mov rdx, [rsi + region.size]
mov rsi, [rsi + region.start]
.top:
mov rax, rdx
sub rax, UNROLLB * 64 ; reduce main loop iterations since the intro/outro parts handle this
mov rcx, rsi
lfence
vpxor ymm0, ymm0, ymm0
vpxor ymm1, ymm1, ymm1
vpxor ymm2, ymm1, ymm1
; lead-in loop which reads the first half of the first UNROLLB cache lines
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
%assign offset (offset + 64)
%endrep
.inner:
%assign offset 0
%rep UNROLLX
vpaddb ymm0, ymm0, [rcx + offset + UNROLLB * 64]
vpaddb ymm0, ymm0, [rcx + offset + UNROLLB * 64 + 64]
vpaddb ymm1, ymm1, [rcx + offset + 32]
vpaddb ymm1, ymm1, [rcx + offset + 96]
%assign offset (offset + 128)
%endrep
add rcx, 2 * UNROLLX * 64
sub rax, 2 * UNROLLX * 64
jge .inner
; lead out loop to read the remaining lines
%assign offset 0
%rep UNROLLB
vpaddb ymm0, ymm0, [rcx + offset]
%assign offset (offset + 64)
%endrep
dec rdi
jnz .top
ret
;
define_bench serial_load_bench2
xor eax, eax
add eax, 0
mov rsi, [rsi + region.start]
.top:
mov rcx, [rsi + rax]
;add rcx, rax
;add rcx, rax
;xor rsi, rcx ; dummy dependency of rsi on rcx
;xor rsi, rcx
mov rsi, [rcx]
;mov rsi, rcx
dec rdi
jnz .top
ret
; one load only, as a baseline
define_bench serial_double_load_oneload
mov rsi, [rsi + region.start]
.top:
mov rcx, [rsi]
mov rsi, rcx
dec rdi
jnz .top
ret
; testing latency of 2nd hit on the same L2 line
; dummy load FIRST
define_bench serial_double_load1
mov rsi, [rsi + region.start]
.top:
mov rax, [rsi]
mov rcx, [rsi + 56]
mov rsi, rcx
dec rdi
jnz .top
ret
; same as above, but separate the first and second load by a cycle
; inserting a dummy ALU op between the two moves
define_bench serial_double_load_alu
mov rsi, [rsi + region.start]
.top:
mov rax, [rsi]
add rsi, 0
mov rcx, [rsi + 56]
mov rsi, rcx
dec rdi
jnz .top
ret
; dummy load first, but lea rather than mov (no elim) to transfer rcx to rsi
; meaning that it's an ALU op that feeds both loads
define_bench serial_double_load_lea
mov rsi, [rsi + region.start]
.top:
mov rax, [rsi]
mov rcx, [rsi + 56]
lea rsi, [rcx]
dec rdi
jnz .top
ret
; dummy second, but add dummy to something
define_bench serial_double_load_addd
xor eax, eax
xor edx, edx
mov rsi, [rsi + region.start]
.top:
mov rcx, [rsi]
add rax, [rsi]
mov rsi, rcx
dec rdi
jnz .top
ret
; same as above, but use indexed addressing mode to see if that
; stops the issue
define_bench serial_double_load_indexed1
and edx, 0 ; must not be zeroing idiom
mov rsi, [rsi + region.start]
.top:
mov rax, [rsi]
mov rcx, [rsi + rdx + 56]
mov rsi, rcx
dec rdi
jnz .top
ret
; as above, but both loads indexed
define_bench serial_double_load_indexed2
;xor edx, edx
and edx, 0
mov rsi, [rsi + region.start]
.top:
mov rax, [rsi + rdx]
mov rcx, [rsi + rdx + 56]
mov rsi, rcx
dec rdi
jnz .top
ret
; as above, but key load first
define_bench serial_double_load_indexed3
;xor edx, edx
and edx, 0
mov rsi, [rsi + region.start]
.top:
mov rcx, [rsi + rdx + 56]
mov rax, [rsi + rdx]
mov rsi, rcx
dec rdi
jnz .top
ret
; testing latency of 2nd hit on the same L2 line
; dummy load SECOND
define_bench serial_double_load2
mov rsi, [rsi + region.start]
.top:
mov rcx, [rsi + 56]
mov rax, [rsi]
mov rsi, rcx
dec rdi
jnz .top
ret
; testing latency of demand hit on the same L2 line after PF
; dummy load SECOND
; %1 test name suffix
; %2 offset for prefetch
; %3 pf hint
%macro make_serial_double_loadpf 3
define_bench serial_double_load%1
mov rsi, [rsi + region.start]
.top:
prefetch%3 [rsi + %2]
mov rcx, [rsi + 56]
mov rsi, rcx
dec rdi
jnz .top
ret
%endmacro
make_serial_double_loadpf pf_diff, 0, t0
make_serial_double_loadpf pf_same, 56, t0
make_serial_double_loadpf pft1_diff, 0, t1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; GATHER GATHER GATHER GATHER GATHER GATHER ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
%macro define_gather_bench 1
%define vec0 %1 %+ 0
%define vec1 %1 %+ 1
%define vec2 %1 %+ 2
%define vec3 %1 %+ 3
%define vec4 %1 %+ 4
define_bench gatherdd_%1
mov r10, rsp
vzeroall
sub rsp, 1024
and rsp, -64
mov rdx, rsp
xor eax, eax
vpxor vec0, vec0, vec0
vmovdqa vec1, [CONST_DWORD_0_7]
vmovdqa vec3, vec1
vpcmpeqd vec4, vec4, vec4
.top:
%rep 16
vmovdqa vec2, vec4
vpxor vec3, vec3, vec3
vpgatherdd vec3, [rsp + vec1], vec2
%endrep
dec rdi
jnz .top
lfence
mov rsp, r10
ret
%endmacro
define_gather_bench xmm
define_gather_bench ymm
;;;;;;;;; gather latency ;;;;;;;;;;
%macro define_gather_lat_bench 1
%define vec0 %1 %+ 0
%define vec1 %1 %+ 1
%define vec2 %1 %+ 2
%define vec3 %1 %+ 3
%define vec4 %1 %+ 4
%define vec5 %1 %+ 5
define_bench gatherdd_lat_%1
mov r10, rsp
vzeroall
sub rsp, 1024
and rsp, -64
mov rdx, rsp
xor eax, eax
vpxor vec0, vec0, vec0
vpcmpeqd vec4, vec4, vec4
vpxor vec5, vec5, vec5
vmovdqa vec1, [CONST_DWORD_0_7]
vmovdqa [rsp], vec1
.top:
%rep 16
vmovdqa vec2, vec4
vpgatherdd vec0, [rsp + vec1 * 4], vec2
vpand vec0, vec0, vec5
vpor vec1, vec1, vec0 ; make vec1 (indexes) depend on vec0 (result)
%endrep
dec rdi
jnz .top
mov rsp, r10
ret
%endmacro
define_gather_lat_bench xmm
define_gather_lat_bench ymm
; retpoline stuff
; the generic retpoline thunk, parameterized on the loop instruction
%macro retpoline_thunk 1
retpoline_thunk_%1:
call .target
.loop:
%1
jmp .loop
.target:
lea rsp, [rsp + 8]
ret
%endmacro
%macro retpo_call 2
jmp %%call
%%jmpthunk:
push %1
jmp retpoline_thunk_%2
%%call:
call %%jmpthunk
%endmacro
retpoline_thunk pause
retpoline_thunk lfence
ALIGN 16
empty_func:
ret
%macro body 0
call empty_func
%endmacro
%assign depth 128
%rep depth
call_chain_ %+ depth :
%assign depth depth-1
call call_chain_ %+ depth
ret
%endrep
call_chain_0:
ret
%define dense_nop_padding nop5
%macro retpoline_dense_call 1
define_bench retpoline_dense_call_%1
push r15
lea r15, [empty_func]
.top:
%rep 32
retpo_call r15,%1
dense_nop_padding
%endrep
dec rdi
jnz .top
pop r15
ret
%endmacro
retpoline_dense_call lfence
retpoline_dense_call pause
%define IMUL_COUNT 20
define_bench retpoline_sparse_call_base
push r15
lea r15, [empty_func]
.top:
%rep 8
times IMUL_COUNT imul eax, eax, 1
%endrep
dec rdi
jnz .top
pop r15
ret
%macro retpoline_sparse_indep_call 1
define_bench retpoline_sparse_indep_call_%1
push r15
lea r15, [empty_func]
.top:
%rep 8
retpo_call r15,%1
times IMUL_COUNT imul rax, rax, 1
%endrep
dec rdi
jnz .top
pop r15
ret
%endmacro
%macro retpoline_sparse_dep_call 1
define_bench retpoline_sparse_dep_call_%1
push r15
lea r15, [empty_func]
.top:
%rep 8
retpo_call r15,%1
times IMUL_COUNT imul r15, r15, 1
%endrep
dec rdi
jnz .top
pop r15
ret
%endmacro
retpoline_sparse_indep_call lfence
retpoline_sparse_indep_call pause
retpoline_sparse_dep_call lfence
retpoline_sparse_dep_call pause
define_bench indirect_dense_call_pred
push r15
lea r15, [empty_func]
.top:
%rep 32
call r15
dense_nop_padding
%endrep
dec rdi
jnz .top
pop r15
ret
define_bench indirect_dense_call_unpred
push r14
push r15
xor r14, r14
.top:
add r14, 11
and r14, 127
lea r15, [empty_func0 + r14 * 8]
%rep 32
call r15
%endrep
dec rdi
jnz .top
pop r15
pop r14
ret
; empty functions spaced out every 8 bytes
%assign i 0
%rep 128
empty_func %+ i :
ret
nop7
%assign i i+1
%endrep
%macro dsb_body 0
times 2 nop8
.outer:
mov rax, 128
.top:
nop9
dec rax
jne .top
dec rdi
jnz .outer
ret
ud2
%endmacro
GLOBAL dsb_alignment_cross64,dsb_alignment_nocross64
ALIGN 64
times 4 nop8
; the loop ends up crossing a 64-byte boundary
dsb_alignment_cross64:
dsb_body
ALIGN 64
dsb_alignment_nocross64:
dsb_body
%define ADC_INNER_ITERS 250
; %1 name suffix
; %2 reg to use as src/dest
%macro define_adc_bench 2
define_bench adc_chain%1
push rbp
mov rbp, rsp
mov r9, rdi
sub rsp, ADC_INNER_ITERS * 3 * 32
vzeroupper
;vpor ymm0, ymm0, ymm0
.top:
mov rcx, ADC_INNER_ITERS
lea rsi, [rsp]
lea rdx, [rsp + ADC_INNER_ITERS * 32]
lea rdi, [rsp + ADC_INNER_ITERS * 32 * 2]
;vpor ymm0, ymm0, ymm0
;vzeroupper
;vpor xmm0, xmm0, xmm0
ALIGN 64
.Loop:
%assign offset 0
%rep 4
mov %2, [rsi + offset]
mov %2, [rsi + offset]
mov [rdi + offset], %2
%assign offset (offset + 0)
%endrep
sub rcx, 1
jne .Loop
dec r9
jnz .top
mov rsp, rbp
pop rbp
ret
%endmacro
define_adc_bench 32, eax
define_adc_bench 64, rax
struc quadargs
small: resq 1
ssize: resq 1
large: resq 1
endstruc
%macro define_quadratic 1
define_bench quadratic%1
times %1 nop
mov rdx, rsi
mov esi, 1000
mov ecx, 1 ; the array is all 0s so this never matches
.outer:
xor eax, eax
.inner:
cmp dword [rdx+rax*4], ecx
jz .match
inc eax
cmp eax, 1000
jne .inner
dec rdi
jnz .outer
ret
.match:
ud2 ; not possible because we input distinct arrays
%endmacro
%assign i 0
%rep 64
define_quadratic i
%assign i i+1
%endrep
; define the weird store bench
; %1 suffix
; %2 zeroing instruction
%macro define_weird_store 2
define_bench weird_store_%1
push rbp
mov rbp, rsp
sub rsp, 8196
mov rsi, rsp
mov eax, edi
.oloop:
mov ecx, 1000
%2
align 16
.iloop:
mov [rsi], edi
mov [rsp], edi
sub rsp, 4
dec ecx
jnz .iloop
lea rsp, [rbp - 8196]
dec eax
jnz .oloop
mov rsp, rbp
pop rbp
ret
%endmacro
define_weird_store mov,{mov edi, 0}
define_weird_store xor,{xor edi, edi}
; https://news.ycombinator.com/item?id=15935283
; https://eli.thegreenplace.net/2013/12/03/intel-i7-loop-performance-anomaly
define_bench loop_weirdness_fast
.top:
add QWORD [rsp - 8], 1
times 10 mov eax, 1
dec rdi
jne .top
rep ret
define_bench tight_loop1
.top:
dec rdi
jne .top
rep ret
define_bench tight_loop2
.top:
xor eax, eax
jz .l1
nop
.l1:
dec rdi
jne .top
rep ret
define_bench tight_loop3
.top:
xor eax, eax
jnz .l1
nop
.l1:
dec rdi
jne .top
rep ret
%macro fwd_lat_with_delay 1
define_bench fwd_lat_delay_%1
lea rdx, [rsp - 8]
.top:
mov rcx, [rdx]
mov [rdx], rcx
times %1 add rdx, 0
dec rdi
jne .top
rep ret
%endmacro
fwd_lat_with_delay 0
fwd_lat_with_delay 1
fwd_lat_with_delay 2
fwd_lat_with_delay 3
fwd_lat_with_delay 4
fwd_lat_with_delay 5
define_bench train_noalias
;mov r8, rbx
;xor eax, eax
;cpuid
;mov rbx, r8
lea rdx, [rsi + 64]
mov rdi, 520000
xor ecx, ecx
.top:
%rep 100
imul rdx, 1
mov DWORD [rdx], ecx
mov eax, DWORD [rsi]
nop3
%endrep
dec rdi
jnz .top
ret
ud2
define_bench oneshot_try2_4
mov rdx, rsi
%rep 4
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench oneshot_try2_10
mov rdx, rsi
%rep 10
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench oneshot_try2_1000
mov rdx, rsi
%rep 1000
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench oneshot_try2_20
mov rdx, rsi
%rep 20
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench oneshot_try2
mov rdx, rsi
%rep 100
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench oneshot_try1
%rep 100
mov DWORD [rsi], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
define_bench aliasing_loads
mov rdx, rsi
;xor ecx, ecx
times 0 nop
lfence
%rep 5
imul rdx, 1
mov DWORD [rdx], 0
mov eax, DWORD [rsi]
%endrep
ret
ud2
%ifnnum NOPCOUNT
%define NOPCOUNT 0
%endif
%macro nops 0
jmp near %%skipnop
times NOPCOUNT nop
%%skipnop:
%endmacro
; separate training and timed regions
define_bench aliasing_loads_raw
mov r8, rdx ; rdx:rax are clobbered by rdpmc macros
readpmc4_start
mov ecx, 10
.outer:
lea r11, [rsi + 64]
mov r10, 2000
; training loop
.train_top:
%rep 1
times 3 imul r11, 1
mov DWORD [r11], 0
mov eax, DWORD [rsi]
nop
%endrep
;times 10 imul r11, 1
dec r10
jnz .train_top
lea r9, [rsi + 8]
; this lfence is critical because we want to finish all the instructions related to
; training before we start the next section, since otherwise our attempt to delay
; the store may not work (e.g., because the training section will probably end
; with a backlog of imul that will execute and retire 1 every 3 cycles, so we will
; just take the instructions in the next cycle one every 3 cycles, so OoO can't do
; its magic
lfence
mov rdi, 1
jmp .top
ALIGN 256
.top:
nops
%rep 2
times 5 imul r9, 1
; payload load(s)
mov DWORD [r9], 0
add eax, DWORD [rsi + 8]
%endrep
dec rdi
jnz .top
lfence
dec ecx
jnz .outer
readpmc4_end
store_pfcnow4 r8
ret
ud2
%ifndef REPCOUNT
%define REPCOUNT 10
%endif
; mixed aliasing and non-aliasing loads
define_bench mixed_loads_raw
mov r8, rdx ; rdx:rax are clobbered by rdpmc macros
readpmc4_start
xor eax, eax
mov ecx, 1
.outer:
lea r11, [rsi+ 64]
mov rdi, 1000
.top:
%assign r 1
%rep REPCOUNT
; rax is always zero in this loop
times 2 lea r11, strict [byte r11 + rax*2 + 0] ; delay the store address
mov DWORD [r11 + rax], eax ; the store to [rsi + 64]
mov r9d, DWORD [rsi + 64] ; aliasing load
nop9
nop6
mov eax, DWORD [rsi] ; non-aliasing load
imul eax, 1 ; make the eax dep chain longer
%if r == (REPCOUNT/2)
; half way through the unroll, we add 19 bytes of nop so that the the aliasing loads
; in the second half of the loop collide with the non-aliasing loads in the second
; half and vice versa. Without this, we'll never get any slowdown, because even though
; we get collisions, the prediction is always exactly correct since aliasing loads collide
; with aliasing loads after "wrap around" (and non-aliasing with aliasing)
nop9
nop9
nop1
%endif
%assign r r+1
%endrep
dec rdi
jnz .top
lfence
dec ecx
jnz .outer
readpmc4_end
store_pfcnow4 r8
ret
ud2
%define ONESHOT_REPEAT_OUTER 1
%define ONESHOT_REPEAT_INNER 1
; like the fwd_lat_with_delay above, but without a loop, used in oneshot mode to
; examine transient behavior with code code
%macro fwd_lat_delay_oneshot 1
define_bench fwd_lat_delay_oneshot_%1
push rbx
xor eax, eax
cpuid
xor eax, eax
xor ecx, ecx
lea rdx, [rsi + 8]
; put the CPU into hoist-OK mode (watchdog off)
mov rdi, 1600
.topgood:
times 10 imul rsi, 1
mov [rax + rsi], rcx
times 2 mov rax, [rdx]
times 5 imul rsi, 1
mov [rax + rsi], rcx
nop
times 2 mov rax, [rdx]
times 5 imul rsi, 1
mov [rax + rsi], rcx
nop
nop
times 2 mov rax, [rdx]
times 5 imul rsi, 1
mov [rax + rsi], rcx
nop
nop
nop
times 2 mov rax, [rdx]
times 5 imul rsi, 1
mov [rax + rsi], rcx
times 2 mov rax, [rdx]
dec rdi
jnz .topgood
; put the CPU into hoist-not-OK mode
%rep 10
times 5 imul rax, 1
mov [rsi + rax], rcx
mov rdi, [rsi]
mov rdi, [rsi]
mov rdi, [rsi]
mov rdi, [rsi]
mov rdi, [rsi]
mov rdi, [rsi]
%endrep
pop rbx
ret
mov rdi, 500
.top:
; chain of instructions that is much slower when loads aren't hoisted above stores with unknwon
; addresses
mov [rsi + rax], rcx
mov rax, [rdx]
dec rdi
jnz .top
ret
.other:
mov rdi, 1000
.top1:
mov [rax], DWORD 1
mov rsi, [rdx]
dec rdi
jnz .top1
%rep ONESHOT_REPEAT_OUTER
%rep ONESHOT_REPEAT_INNER
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
mov rdi, 1
.top2:
imul rax, 1
imul rax, 1
imul rax, 1
imul rax, 1
mov [rax], DWORD 0
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [byte rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [byte rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [byte rdx]
mov rsi, [rdx]
mov rsi, [rdx]
mov rsi, [rdx]
dec rdi
jnz .top2
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
imul rdx, 1
imul rdx, 1
imul rdx, 1
mov [rdx], rsi
add rcx, [rax + 8]
;times %1 add rcx, 0
%endrep
%rep ONESHOT_REPEAT_INNER * 0
mov [rdx], rcx
mov rcx, [rax - 8]
;times %1 add rdx, 0
%endrep
%endrep
ret
ud2
%endmacro
fwd_lat_delay_oneshot 0
fwd_lat_delay_oneshot 1
fwd_lat_delay_oneshot 2
fwd_lat_delay_oneshot 3
fwd_lat_delay_oneshot 4
fwd_lat_delay_oneshot 5
%macro fwd_tput_conc 1
define_bench fwd_tput_conc_%1
sub rsp, 256
lea rdx, [rsp - 8]
.top:
%assign offset 0
%rep %1
mov rcx, [rdx + offset]
mov [rdx + offset], rcx
%assign offset offset+8
%endrep
dec rdi
jne .top
add rsp, 256
rep ret
%endmacro
fwd_tput_conc 1
fwd_tput_conc 2
fwd_tput_conc 3
fwd_tput_conc 4
fwd_tput_conc 5
fwd_tput_conc 6
fwd_tput_conc 7
fwd_tput_conc 8
fwd_tput_conc 9
fwd_tput_conc 10
%macro bypass_mov_latency 1
define_bench bypass_%1_latency
sub rsp, 120
xor eax, eax
vpxor xmm1, xmm1, xmm1
vpsubb xmm1, xmm1, [rsp + rax] ; to exactly cancel out the vpaddb below
.top:
%1 xmm0, [rsp + rax] ; 6 cycles
vpaddb xmm0, xmm0, xmm1 ; 1 cycle
vmovq rax, xmm0 ; 2 cycles
dec rdi
jnz .top
add rsp, 120
ret
%endmacro
bypass_mov_latency vmovdqa
bypass_mov_latency vmovdqu
bypass_mov_latency vmovups
bypass_mov_latency vmovupd
define_bench bypass_movq_latency
vpxor xmm0, xmm0
.top:
vmovq rax, xmm0 ; 1 cycle
vmovq xmm0, rax ; 1 cycle
dec rdi
jnz .top
ret
define_bench bypass_movd_latency
vpxor xmm0, xmm0, xmm0
.top:
vmovd eax, xmm0 ; 1 cycle
vmovd xmm0, eax ; 1 cycle
dec rdi
jnz .top
ret
%macro vector_load_load_lat 2
define_bench vector_load_load_lat_%1_%2
push rbp
vzeroupper
mov rbp, rsp
sub rsp, 128
and rsp, -64
xor eax, eax
vpxor xmm0, xmm0, xmm0
vmovdqu [rsp], ymm0
vmovdqu [rsp + 32], ymm0
vmovdqu [rsp + 64], ymm0
vmovdqu [rsp + 96], ymm0
.top:
%1 xmm0, [rsp + rax + %2] ; 6 cycles
vmovq rax, xmm0 ; 2 cycles
dec rdi
jnz .top
mov rsp, rbp
pop rbp
ret
%endmacro
vector_load_load_lat movdqu, 0
vector_load_load_lat vmovdqu, 0
vector_load_load_lat lddqu, 0
vector_load_load_lat vlddqu, 0
vector_load_load_lat movdqu, 63
vector_load_load_lat vmovdqu, 63
vector_load_load_lat lddqu, 63
vector_load_load_lat vlddqu, 63
define_bench raw_rdpmc0_overhead
assert_eq rdi, 0
assert_eq rsi, 0
mov r8, rdx
readpmc0_start
readpmc0_end
store_pfcnow0 r8
ret
define_bench raw_rdpmc4_overhead
assert_eq rdi, 0
assert_eq rsi, 0
mov r8, rdx
readpmc4_start
readpmc4_end
store_pfcnow4 r8
ret
; store loop with raw rdpmc calls
define_bench store_raw_libpfc
; loop count should be 1 since we don't have a loop here
assert_eq rdi, 1
sub rsp, 128
mov r8, rdx
readpmc4_start
.top:
%assign offset 0
%rep 100
mov [rsp], BYTE 42
;sfence
%assign offset offset+1
%endrep
readpmc4_end
store_pfcnow4 r8
add rsp, 128
ret
define_bench syscall_asm
.top:
mov eax, esi
syscall
dec rdi
jnz .top
ret
define_bench syscall_asm_lfence_before
.top:
mov eax, esi
lfence
syscall
dec rdi
jnz .top
ret
define_bench syscall_asm_lfence_after
.top:
mov eax, esi
syscall
lfence
dec rdi
jnz .top
ret
define_bench lfence_only
.top:
times 8 lfence
dec rdi
jnz .top
ret
ud2
%define STRIDE 12736 ; 13 * 64
%define SIZE (1 << 25)
%define MASK (SIZE - 1)
; parallel loads with large stride (across pages, defeating prefetcher)
%macro parallel_miss_macro 1
xor edx, edx
.top:
mov eax, DWORD [rsi + rdx]
%1
add rdx, STRIDE
and rdx, MASK
dec rdi
jnz .top
ret
%endmacro
define_bench parallel_misses
parallel_miss_macro nop
define_bench lfenced_misses
parallel_miss_macro lfence
define_bench mfenced_misses
parallel_miss_macro mfence
define_bench sfenced_misses
parallel_miss_macro sfence
%macro syscall_123456 0
mov eax, 123456
syscall
%endmacro
define_bench syscall_misses
parallel_miss_macro syscall_123456
%macro syscall_123456_lfence 0
lfence
syscall_123456
%endmacro
define_bench syscall_misses_lfence
parallel_miss_macro syscall_123456_lfence
ud2
; constants
align 32
CONST_DWORD_0_7:
dd 0,64,128,192,256,320,384,448
|
; WARNING: do not edit!
; Generated from openssl/crypto/sha/asm/sha512-x86_64.pl
;
; Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved.
;
; Licensed under the OpenSSL license (the "License"). You may not use
; this file except in compliance with the License. You can obtain a copy
; in the file LICENSE in the source distribution or at
; https://www.openssl.org/source/license.html
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
EXTERN OPENSSL_ia32cap_P
global sha512_block_data_order
ALIGN 16
sha512_block_data_order:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_sha512_block_data_order:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rax,rsp
push rbx
push rbp
push r12
push r13
push r14
push r15
shl rdx,4
sub rsp,16*8+4*8
lea rdx,[rdx*8+rsi]
and rsp,-64
mov QWORD[((128+0))+rsp],rdi
mov QWORD[((128+8))+rsp],rsi
mov QWORD[((128+16))+rsp],rdx
mov QWORD[152+rsp],rax
$L$prologue:
mov rax,QWORD[rdi]
mov rbx,QWORD[8+rdi]
mov rcx,QWORD[16+rdi]
mov rdx,QWORD[24+rdi]
mov r8,QWORD[32+rdi]
mov r9,QWORD[40+rdi]
mov r10,QWORD[48+rdi]
mov r11,QWORD[56+rdi]
jmp NEAR $L$loop
ALIGN 16
$L$loop:
mov rdi,rbx
lea rbp,[K512]
xor rdi,rcx
mov r12,QWORD[rsi]
mov r13,r8
mov r14,rax
bswap r12
ror r13,23
mov r15,r9
xor r13,r8
ror r14,5
xor r15,r10
mov QWORD[rsp],r12
xor r14,rax
and r15,r8
ror r13,4
add r12,r11
xor r15,r10
ror r14,6
xor r13,r8
add r12,r15
mov r15,rax
add r12,QWORD[rbp]
xor r14,rax
xor r15,rbx
ror r13,14
mov r11,rbx
and rdi,r15
ror r14,28
add r12,r13
xor r11,rdi
add rdx,r12
add r11,r12
lea rbp,[8+rbp]
add r11,r14
mov r12,QWORD[8+rsi]
mov r13,rdx
mov r14,r11
bswap r12
ror r13,23
mov rdi,r8
xor r13,rdx
ror r14,5
xor rdi,r9
mov QWORD[8+rsp],r12
xor r14,r11
and rdi,rdx
ror r13,4
add r12,r10
xor rdi,r9
ror r14,6
xor r13,rdx
add r12,rdi
mov rdi,r11
add r12,QWORD[rbp]
xor r14,r11
xor rdi,rax
ror r13,14
mov r10,rax
and r15,rdi
ror r14,28
add r12,r13
xor r10,r15
add rcx,r12
add r10,r12
lea rbp,[24+rbp]
add r10,r14
mov r12,QWORD[16+rsi]
mov r13,rcx
mov r14,r10
bswap r12
ror r13,23
mov r15,rdx
xor r13,rcx
ror r14,5
xor r15,r8
mov QWORD[16+rsp],r12
xor r14,r10
and r15,rcx
ror r13,4
add r12,r9
xor r15,r8
ror r14,6
xor r13,rcx
add r12,r15
mov r15,r10
add r12,QWORD[rbp]
xor r14,r10
xor r15,r11
ror r13,14
mov r9,r11
and rdi,r15
ror r14,28
add r12,r13
xor r9,rdi
add rbx,r12
add r9,r12
lea rbp,[8+rbp]
add r9,r14
mov r12,QWORD[24+rsi]
mov r13,rbx
mov r14,r9
bswap r12
ror r13,23
mov rdi,rcx
xor r13,rbx
ror r14,5
xor rdi,rdx
mov QWORD[24+rsp],r12
xor r14,r9
and rdi,rbx
ror r13,4
add r12,r8
xor rdi,rdx
ror r14,6
xor r13,rbx
add r12,rdi
mov rdi,r9
add r12,QWORD[rbp]
xor r14,r9
xor rdi,r10
ror r13,14
mov r8,r10
and r15,rdi
ror r14,28
add r12,r13
xor r8,r15
add rax,r12
add r8,r12
lea rbp,[24+rbp]
add r8,r14
mov r12,QWORD[32+rsi]
mov r13,rax
mov r14,r8
bswap r12
ror r13,23
mov r15,rbx
xor r13,rax
ror r14,5
xor r15,rcx
mov QWORD[32+rsp],r12
xor r14,r8
and r15,rax
ror r13,4
add r12,rdx
xor r15,rcx
ror r14,6
xor r13,rax
add r12,r15
mov r15,r8
add r12,QWORD[rbp]
xor r14,r8
xor r15,r9
ror r13,14
mov rdx,r9
and rdi,r15
ror r14,28
add r12,r13
xor rdx,rdi
add r11,r12
add rdx,r12
lea rbp,[8+rbp]
add rdx,r14
mov r12,QWORD[40+rsi]
mov r13,r11
mov r14,rdx
bswap r12
ror r13,23
mov rdi,rax
xor r13,r11
ror r14,5
xor rdi,rbx
mov QWORD[40+rsp],r12
xor r14,rdx
and rdi,r11
ror r13,4
add r12,rcx
xor rdi,rbx
ror r14,6
xor r13,r11
add r12,rdi
mov rdi,rdx
add r12,QWORD[rbp]
xor r14,rdx
xor rdi,r8
ror r13,14
mov rcx,r8
and r15,rdi
ror r14,28
add r12,r13
xor rcx,r15
add r10,r12
add rcx,r12
lea rbp,[24+rbp]
add rcx,r14
mov r12,QWORD[48+rsi]
mov r13,r10
mov r14,rcx
bswap r12
ror r13,23
mov r15,r11
xor r13,r10
ror r14,5
xor r15,rax
mov QWORD[48+rsp],r12
xor r14,rcx
and r15,r10
ror r13,4
add r12,rbx
xor r15,rax
ror r14,6
xor r13,r10
add r12,r15
mov r15,rcx
add r12,QWORD[rbp]
xor r14,rcx
xor r15,rdx
ror r13,14
mov rbx,rdx
and rdi,r15
ror r14,28
add r12,r13
xor rbx,rdi
add r9,r12
add rbx,r12
lea rbp,[8+rbp]
add rbx,r14
mov r12,QWORD[56+rsi]
mov r13,r9
mov r14,rbx
bswap r12
ror r13,23
mov rdi,r10
xor r13,r9
ror r14,5
xor rdi,r11
mov QWORD[56+rsp],r12
xor r14,rbx
and rdi,r9
ror r13,4
add r12,rax
xor rdi,r11
ror r14,6
xor r13,r9
add r12,rdi
mov rdi,rbx
add r12,QWORD[rbp]
xor r14,rbx
xor rdi,rcx
ror r13,14
mov rax,rcx
and r15,rdi
ror r14,28
add r12,r13
xor rax,r15
add r8,r12
add rax,r12
lea rbp,[24+rbp]
add rax,r14
mov r12,QWORD[64+rsi]
mov r13,r8
mov r14,rax
bswap r12
ror r13,23
mov r15,r9
xor r13,r8
ror r14,5
xor r15,r10
mov QWORD[64+rsp],r12
xor r14,rax
and r15,r8
ror r13,4
add r12,r11
xor r15,r10
ror r14,6
xor r13,r8
add r12,r15
mov r15,rax
add r12,QWORD[rbp]
xor r14,rax
xor r15,rbx
ror r13,14
mov r11,rbx
and rdi,r15
ror r14,28
add r12,r13
xor r11,rdi
add rdx,r12
add r11,r12
lea rbp,[8+rbp]
add r11,r14
mov r12,QWORD[72+rsi]
mov r13,rdx
mov r14,r11
bswap r12
ror r13,23
mov rdi,r8
xor r13,rdx
ror r14,5
xor rdi,r9
mov QWORD[72+rsp],r12
xor r14,r11
and rdi,rdx
ror r13,4
add r12,r10
xor rdi,r9
ror r14,6
xor r13,rdx
add r12,rdi
mov rdi,r11
add r12,QWORD[rbp]
xor r14,r11
xor rdi,rax
ror r13,14
mov r10,rax
and r15,rdi
ror r14,28
add r12,r13
xor r10,r15
add rcx,r12
add r10,r12
lea rbp,[24+rbp]
add r10,r14
mov r12,QWORD[80+rsi]
mov r13,rcx
mov r14,r10
bswap r12
ror r13,23
mov r15,rdx
xor r13,rcx
ror r14,5
xor r15,r8
mov QWORD[80+rsp],r12
xor r14,r10
and r15,rcx
ror r13,4
add r12,r9
xor r15,r8
ror r14,6
xor r13,rcx
add r12,r15
mov r15,r10
add r12,QWORD[rbp]
xor r14,r10
xor r15,r11
ror r13,14
mov r9,r11
and rdi,r15
ror r14,28
add r12,r13
xor r9,rdi
add rbx,r12
add r9,r12
lea rbp,[8+rbp]
add r9,r14
mov r12,QWORD[88+rsi]
mov r13,rbx
mov r14,r9
bswap r12
ror r13,23
mov rdi,rcx
xor r13,rbx
ror r14,5
xor rdi,rdx
mov QWORD[88+rsp],r12
xor r14,r9
and rdi,rbx
ror r13,4
add r12,r8
xor rdi,rdx
ror r14,6
xor r13,rbx
add r12,rdi
mov rdi,r9
add r12,QWORD[rbp]
xor r14,r9
xor rdi,r10
ror r13,14
mov r8,r10
and r15,rdi
ror r14,28
add r12,r13
xor r8,r15
add rax,r12
add r8,r12
lea rbp,[24+rbp]
add r8,r14
mov r12,QWORD[96+rsi]
mov r13,rax
mov r14,r8
bswap r12
ror r13,23
mov r15,rbx
xor r13,rax
ror r14,5
xor r15,rcx
mov QWORD[96+rsp],r12
xor r14,r8
and r15,rax
ror r13,4
add r12,rdx
xor r15,rcx
ror r14,6
xor r13,rax
add r12,r15
mov r15,r8
add r12,QWORD[rbp]
xor r14,r8
xor r15,r9
ror r13,14
mov rdx,r9
and rdi,r15
ror r14,28
add r12,r13
xor rdx,rdi
add r11,r12
add rdx,r12
lea rbp,[8+rbp]
add rdx,r14
mov r12,QWORD[104+rsi]
mov r13,r11
mov r14,rdx
bswap r12
ror r13,23
mov rdi,rax
xor r13,r11
ror r14,5
xor rdi,rbx
mov QWORD[104+rsp],r12
xor r14,rdx
and rdi,r11
ror r13,4
add r12,rcx
xor rdi,rbx
ror r14,6
xor r13,r11
add r12,rdi
mov rdi,rdx
add r12,QWORD[rbp]
xor r14,rdx
xor rdi,r8
ror r13,14
mov rcx,r8
and r15,rdi
ror r14,28
add r12,r13
xor rcx,r15
add r10,r12
add rcx,r12
lea rbp,[24+rbp]
add rcx,r14
mov r12,QWORD[112+rsi]
mov r13,r10
mov r14,rcx
bswap r12
ror r13,23
mov r15,r11
xor r13,r10
ror r14,5
xor r15,rax
mov QWORD[112+rsp],r12
xor r14,rcx
and r15,r10
ror r13,4
add r12,rbx
xor r15,rax
ror r14,6
xor r13,r10
add r12,r15
mov r15,rcx
add r12,QWORD[rbp]
xor r14,rcx
xor r15,rdx
ror r13,14
mov rbx,rdx
and rdi,r15
ror r14,28
add r12,r13
xor rbx,rdi
add r9,r12
add rbx,r12
lea rbp,[8+rbp]
add rbx,r14
mov r12,QWORD[120+rsi]
mov r13,r9
mov r14,rbx
bswap r12
ror r13,23
mov rdi,r10
xor r13,r9
ror r14,5
xor rdi,r11
mov QWORD[120+rsp],r12
xor r14,rbx
and rdi,r9
ror r13,4
add r12,rax
xor rdi,r11
ror r14,6
xor r13,r9
add r12,rdi
mov rdi,rbx
add r12,QWORD[rbp]
xor r14,rbx
xor rdi,rcx
ror r13,14
mov rax,rcx
and r15,rdi
ror r14,28
add r12,r13
xor rax,r15
add r8,r12
add rax,r12
lea rbp,[24+rbp]
jmp NEAR $L$rounds_16_xx
ALIGN 16
$L$rounds_16_xx:
mov r13,QWORD[8+rsp]
mov r15,QWORD[112+rsp]
mov r12,r13
ror r13,7
add rax,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[72+rsp]
add r12,QWORD[rsp]
mov r13,r8
add r12,r15
mov r14,rax
ror r13,23
mov r15,r9
xor r13,r8
ror r14,5
xor r15,r10
mov QWORD[rsp],r12
xor r14,rax
and r15,r8
ror r13,4
add r12,r11
xor r15,r10
ror r14,6
xor r13,r8
add r12,r15
mov r15,rax
add r12,QWORD[rbp]
xor r14,rax
xor r15,rbx
ror r13,14
mov r11,rbx
and rdi,r15
ror r14,28
add r12,r13
xor r11,rdi
add rdx,r12
add r11,r12
lea rbp,[8+rbp]
mov r13,QWORD[16+rsp]
mov rdi,QWORD[120+rsp]
mov r12,r13
ror r13,7
add r11,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[80+rsp]
add r12,QWORD[8+rsp]
mov r13,rdx
add r12,rdi
mov r14,r11
ror r13,23
mov rdi,r8
xor r13,rdx
ror r14,5
xor rdi,r9
mov QWORD[8+rsp],r12
xor r14,r11
and rdi,rdx
ror r13,4
add r12,r10
xor rdi,r9
ror r14,6
xor r13,rdx
add r12,rdi
mov rdi,r11
add r12,QWORD[rbp]
xor r14,r11
xor rdi,rax
ror r13,14
mov r10,rax
and r15,rdi
ror r14,28
add r12,r13
xor r10,r15
add rcx,r12
add r10,r12
lea rbp,[24+rbp]
mov r13,QWORD[24+rsp]
mov r15,QWORD[rsp]
mov r12,r13
ror r13,7
add r10,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[88+rsp]
add r12,QWORD[16+rsp]
mov r13,rcx
add r12,r15
mov r14,r10
ror r13,23
mov r15,rdx
xor r13,rcx
ror r14,5
xor r15,r8
mov QWORD[16+rsp],r12
xor r14,r10
and r15,rcx
ror r13,4
add r12,r9
xor r15,r8
ror r14,6
xor r13,rcx
add r12,r15
mov r15,r10
add r12,QWORD[rbp]
xor r14,r10
xor r15,r11
ror r13,14
mov r9,r11
and rdi,r15
ror r14,28
add r12,r13
xor r9,rdi
add rbx,r12
add r9,r12
lea rbp,[8+rbp]
mov r13,QWORD[32+rsp]
mov rdi,QWORD[8+rsp]
mov r12,r13
ror r13,7
add r9,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[96+rsp]
add r12,QWORD[24+rsp]
mov r13,rbx
add r12,rdi
mov r14,r9
ror r13,23
mov rdi,rcx
xor r13,rbx
ror r14,5
xor rdi,rdx
mov QWORD[24+rsp],r12
xor r14,r9
and rdi,rbx
ror r13,4
add r12,r8
xor rdi,rdx
ror r14,6
xor r13,rbx
add r12,rdi
mov rdi,r9
add r12,QWORD[rbp]
xor r14,r9
xor rdi,r10
ror r13,14
mov r8,r10
and r15,rdi
ror r14,28
add r12,r13
xor r8,r15
add rax,r12
add r8,r12
lea rbp,[24+rbp]
mov r13,QWORD[40+rsp]
mov r15,QWORD[16+rsp]
mov r12,r13
ror r13,7
add r8,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[104+rsp]
add r12,QWORD[32+rsp]
mov r13,rax
add r12,r15
mov r14,r8
ror r13,23
mov r15,rbx
xor r13,rax
ror r14,5
xor r15,rcx
mov QWORD[32+rsp],r12
xor r14,r8
and r15,rax
ror r13,4
add r12,rdx
xor r15,rcx
ror r14,6
xor r13,rax
add r12,r15
mov r15,r8
add r12,QWORD[rbp]
xor r14,r8
xor r15,r9
ror r13,14
mov rdx,r9
and rdi,r15
ror r14,28
add r12,r13
xor rdx,rdi
add r11,r12
add rdx,r12
lea rbp,[8+rbp]
mov r13,QWORD[48+rsp]
mov rdi,QWORD[24+rsp]
mov r12,r13
ror r13,7
add rdx,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[112+rsp]
add r12,QWORD[40+rsp]
mov r13,r11
add r12,rdi
mov r14,rdx
ror r13,23
mov rdi,rax
xor r13,r11
ror r14,5
xor rdi,rbx
mov QWORD[40+rsp],r12
xor r14,rdx
and rdi,r11
ror r13,4
add r12,rcx
xor rdi,rbx
ror r14,6
xor r13,r11
add r12,rdi
mov rdi,rdx
add r12,QWORD[rbp]
xor r14,rdx
xor rdi,r8
ror r13,14
mov rcx,r8
and r15,rdi
ror r14,28
add r12,r13
xor rcx,r15
add r10,r12
add rcx,r12
lea rbp,[24+rbp]
mov r13,QWORD[56+rsp]
mov r15,QWORD[32+rsp]
mov r12,r13
ror r13,7
add rcx,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[120+rsp]
add r12,QWORD[48+rsp]
mov r13,r10
add r12,r15
mov r14,rcx
ror r13,23
mov r15,r11
xor r13,r10
ror r14,5
xor r15,rax
mov QWORD[48+rsp],r12
xor r14,rcx
and r15,r10
ror r13,4
add r12,rbx
xor r15,rax
ror r14,6
xor r13,r10
add r12,r15
mov r15,rcx
add r12,QWORD[rbp]
xor r14,rcx
xor r15,rdx
ror r13,14
mov rbx,rdx
and rdi,r15
ror r14,28
add r12,r13
xor rbx,rdi
add r9,r12
add rbx,r12
lea rbp,[8+rbp]
mov r13,QWORD[64+rsp]
mov rdi,QWORD[40+rsp]
mov r12,r13
ror r13,7
add rbx,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[rsp]
add r12,QWORD[56+rsp]
mov r13,r9
add r12,rdi
mov r14,rbx
ror r13,23
mov rdi,r10
xor r13,r9
ror r14,5
xor rdi,r11
mov QWORD[56+rsp],r12
xor r14,rbx
and rdi,r9
ror r13,4
add r12,rax
xor rdi,r11
ror r14,6
xor r13,r9
add r12,rdi
mov rdi,rbx
add r12,QWORD[rbp]
xor r14,rbx
xor rdi,rcx
ror r13,14
mov rax,rcx
and r15,rdi
ror r14,28
add r12,r13
xor rax,r15
add r8,r12
add rax,r12
lea rbp,[24+rbp]
mov r13,QWORD[72+rsp]
mov r15,QWORD[48+rsp]
mov r12,r13
ror r13,7
add rax,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[8+rsp]
add r12,QWORD[64+rsp]
mov r13,r8
add r12,r15
mov r14,rax
ror r13,23
mov r15,r9
xor r13,r8
ror r14,5
xor r15,r10
mov QWORD[64+rsp],r12
xor r14,rax
and r15,r8
ror r13,4
add r12,r11
xor r15,r10
ror r14,6
xor r13,r8
add r12,r15
mov r15,rax
add r12,QWORD[rbp]
xor r14,rax
xor r15,rbx
ror r13,14
mov r11,rbx
and rdi,r15
ror r14,28
add r12,r13
xor r11,rdi
add rdx,r12
add r11,r12
lea rbp,[8+rbp]
mov r13,QWORD[80+rsp]
mov rdi,QWORD[56+rsp]
mov r12,r13
ror r13,7
add r11,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[16+rsp]
add r12,QWORD[72+rsp]
mov r13,rdx
add r12,rdi
mov r14,r11
ror r13,23
mov rdi,r8
xor r13,rdx
ror r14,5
xor rdi,r9
mov QWORD[72+rsp],r12
xor r14,r11
and rdi,rdx
ror r13,4
add r12,r10
xor rdi,r9
ror r14,6
xor r13,rdx
add r12,rdi
mov rdi,r11
add r12,QWORD[rbp]
xor r14,r11
xor rdi,rax
ror r13,14
mov r10,rax
and r15,rdi
ror r14,28
add r12,r13
xor r10,r15
add rcx,r12
add r10,r12
lea rbp,[24+rbp]
mov r13,QWORD[88+rsp]
mov r15,QWORD[64+rsp]
mov r12,r13
ror r13,7
add r10,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[24+rsp]
add r12,QWORD[80+rsp]
mov r13,rcx
add r12,r15
mov r14,r10
ror r13,23
mov r15,rdx
xor r13,rcx
ror r14,5
xor r15,r8
mov QWORD[80+rsp],r12
xor r14,r10
and r15,rcx
ror r13,4
add r12,r9
xor r15,r8
ror r14,6
xor r13,rcx
add r12,r15
mov r15,r10
add r12,QWORD[rbp]
xor r14,r10
xor r15,r11
ror r13,14
mov r9,r11
and rdi,r15
ror r14,28
add r12,r13
xor r9,rdi
add rbx,r12
add r9,r12
lea rbp,[8+rbp]
mov r13,QWORD[96+rsp]
mov rdi,QWORD[72+rsp]
mov r12,r13
ror r13,7
add r9,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[32+rsp]
add r12,QWORD[88+rsp]
mov r13,rbx
add r12,rdi
mov r14,r9
ror r13,23
mov rdi,rcx
xor r13,rbx
ror r14,5
xor rdi,rdx
mov QWORD[88+rsp],r12
xor r14,r9
and rdi,rbx
ror r13,4
add r12,r8
xor rdi,rdx
ror r14,6
xor r13,rbx
add r12,rdi
mov rdi,r9
add r12,QWORD[rbp]
xor r14,r9
xor rdi,r10
ror r13,14
mov r8,r10
and r15,rdi
ror r14,28
add r12,r13
xor r8,r15
add rax,r12
add r8,r12
lea rbp,[24+rbp]
mov r13,QWORD[104+rsp]
mov r15,QWORD[80+rsp]
mov r12,r13
ror r13,7
add r8,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[40+rsp]
add r12,QWORD[96+rsp]
mov r13,rax
add r12,r15
mov r14,r8
ror r13,23
mov r15,rbx
xor r13,rax
ror r14,5
xor r15,rcx
mov QWORD[96+rsp],r12
xor r14,r8
and r15,rax
ror r13,4
add r12,rdx
xor r15,rcx
ror r14,6
xor r13,rax
add r12,r15
mov r15,r8
add r12,QWORD[rbp]
xor r14,r8
xor r15,r9
ror r13,14
mov rdx,r9
and rdi,r15
ror r14,28
add r12,r13
xor rdx,rdi
add r11,r12
add rdx,r12
lea rbp,[8+rbp]
mov r13,QWORD[112+rsp]
mov rdi,QWORD[88+rsp]
mov r12,r13
ror r13,7
add rdx,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[48+rsp]
add r12,QWORD[104+rsp]
mov r13,r11
add r12,rdi
mov r14,rdx
ror r13,23
mov rdi,rax
xor r13,r11
ror r14,5
xor rdi,rbx
mov QWORD[104+rsp],r12
xor r14,rdx
and rdi,r11
ror r13,4
add r12,rcx
xor rdi,rbx
ror r14,6
xor r13,r11
add r12,rdi
mov rdi,rdx
add r12,QWORD[rbp]
xor r14,rdx
xor rdi,r8
ror r13,14
mov rcx,r8
and r15,rdi
ror r14,28
add r12,r13
xor rcx,r15
add r10,r12
add rcx,r12
lea rbp,[24+rbp]
mov r13,QWORD[120+rsp]
mov r15,QWORD[96+rsp]
mov r12,r13
ror r13,7
add rcx,r14
mov r14,r15
ror r15,42
xor r13,r12
shr r12,7
ror r13,1
xor r15,r14
shr r14,6
ror r15,19
xor r12,r13
xor r15,r14
add r12,QWORD[56+rsp]
add r12,QWORD[112+rsp]
mov r13,r10
add r12,r15
mov r14,rcx
ror r13,23
mov r15,r11
xor r13,r10
ror r14,5
xor r15,rax
mov QWORD[112+rsp],r12
xor r14,rcx
and r15,r10
ror r13,4
add r12,rbx
xor r15,rax
ror r14,6
xor r13,r10
add r12,r15
mov r15,rcx
add r12,QWORD[rbp]
xor r14,rcx
xor r15,rdx
ror r13,14
mov rbx,rdx
and rdi,r15
ror r14,28
add r12,r13
xor rbx,rdi
add r9,r12
add rbx,r12
lea rbp,[8+rbp]
mov r13,QWORD[rsp]
mov rdi,QWORD[104+rsp]
mov r12,r13
ror r13,7
add rbx,r14
mov r14,rdi
ror rdi,42
xor r13,r12
shr r12,7
ror r13,1
xor rdi,r14
shr r14,6
ror rdi,19
xor r12,r13
xor rdi,r14
add r12,QWORD[64+rsp]
add r12,QWORD[120+rsp]
mov r13,r9
add r12,rdi
mov r14,rbx
ror r13,23
mov rdi,r10
xor r13,r9
ror r14,5
xor rdi,r11
mov QWORD[120+rsp],r12
xor r14,rbx
and rdi,r9
ror r13,4
add r12,rax
xor rdi,r11
ror r14,6
xor r13,r9
add r12,rdi
mov rdi,rbx
add r12,QWORD[rbp]
xor r14,rbx
xor rdi,rcx
ror r13,14
mov rax,rcx
and r15,rdi
ror r14,28
add r12,r13
xor rax,r15
add r8,r12
add rax,r12
lea rbp,[24+rbp]
cmp BYTE[7+rbp],0
jnz NEAR $L$rounds_16_xx
mov rdi,QWORD[((128+0))+rsp]
add rax,r14
lea rsi,[128+rsi]
add rax,QWORD[rdi]
add rbx,QWORD[8+rdi]
add rcx,QWORD[16+rdi]
add rdx,QWORD[24+rdi]
add r8,QWORD[32+rdi]
add r9,QWORD[40+rdi]
add r10,QWORD[48+rdi]
add r11,QWORD[56+rdi]
cmp rsi,QWORD[((128+16))+rsp]
mov QWORD[rdi],rax
mov QWORD[8+rdi],rbx
mov QWORD[16+rdi],rcx
mov QWORD[24+rdi],rdx
mov QWORD[32+rdi],r8
mov QWORD[40+rdi],r9
mov QWORD[48+rdi],r10
mov QWORD[56+rdi],r11
jb NEAR $L$loop
mov rsi,QWORD[152+rsp]
mov r15,QWORD[((-48))+rsi]
mov r14,QWORD[((-40))+rsi]
mov r13,QWORD[((-32))+rsi]
mov r12,QWORD[((-24))+rsi]
mov rbp,QWORD[((-16))+rsi]
mov rbx,QWORD[((-8))+rsi]
lea rsp,[rsi]
$L$epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_sha512_block_data_order:
ALIGN 64
K512:
DQ 0x428a2f98d728ae22,0x7137449123ef65cd
DQ 0x428a2f98d728ae22,0x7137449123ef65cd
DQ 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc
DQ 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc
DQ 0x3956c25bf348b538,0x59f111f1b605d019
DQ 0x3956c25bf348b538,0x59f111f1b605d019
DQ 0x923f82a4af194f9b,0xab1c5ed5da6d8118
DQ 0x923f82a4af194f9b,0xab1c5ed5da6d8118
DQ 0xd807aa98a3030242,0x12835b0145706fbe
DQ 0xd807aa98a3030242,0x12835b0145706fbe
DQ 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2
DQ 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2
DQ 0x72be5d74f27b896f,0x80deb1fe3b1696b1
DQ 0x72be5d74f27b896f,0x80deb1fe3b1696b1
DQ 0x9bdc06a725c71235,0xc19bf174cf692694
DQ 0x9bdc06a725c71235,0xc19bf174cf692694
DQ 0xe49b69c19ef14ad2,0xefbe4786384f25e3
DQ 0xe49b69c19ef14ad2,0xefbe4786384f25e3
DQ 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65
DQ 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65
DQ 0x2de92c6f592b0275,0x4a7484aa6ea6e483
DQ 0x2de92c6f592b0275,0x4a7484aa6ea6e483
DQ 0x5cb0a9dcbd41fbd4,0x76f988da831153b5
DQ 0x5cb0a9dcbd41fbd4,0x76f988da831153b5
DQ 0x983e5152ee66dfab,0xa831c66d2db43210
DQ 0x983e5152ee66dfab,0xa831c66d2db43210
DQ 0xb00327c898fb213f,0xbf597fc7beef0ee4
DQ 0xb00327c898fb213f,0xbf597fc7beef0ee4
DQ 0xc6e00bf33da88fc2,0xd5a79147930aa725
DQ 0xc6e00bf33da88fc2,0xd5a79147930aa725
DQ 0x06ca6351e003826f,0x142929670a0e6e70
DQ 0x06ca6351e003826f,0x142929670a0e6e70
DQ 0x27b70a8546d22ffc,0x2e1b21385c26c926
DQ 0x27b70a8546d22ffc,0x2e1b21385c26c926
DQ 0x4d2c6dfc5ac42aed,0x53380d139d95b3df
DQ 0x4d2c6dfc5ac42aed,0x53380d139d95b3df
DQ 0x650a73548baf63de,0x766a0abb3c77b2a8
DQ 0x650a73548baf63de,0x766a0abb3c77b2a8
DQ 0x81c2c92e47edaee6,0x92722c851482353b
DQ 0x81c2c92e47edaee6,0x92722c851482353b
DQ 0xa2bfe8a14cf10364,0xa81a664bbc423001
DQ 0xa2bfe8a14cf10364,0xa81a664bbc423001
DQ 0xc24b8b70d0f89791,0xc76c51a30654be30
DQ 0xc24b8b70d0f89791,0xc76c51a30654be30
DQ 0xd192e819d6ef5218,0xd69906245565a910
DQ 0xd192e819d6ef5218,0xd69906245565a910
DQ 0xf40e35855771202a,0x106aa07032bbd1b8
DQ 0xf40e35855771202a,0x106aa07032bbd1b8
DQ 0x19a4c116b8d2d0c8,0x1e376c085141ab53
DQ 0x19a4c116b8d2d0c8,0x1e376c085141ab53
DQ 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8
DQ 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8
DQ 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb
DQ 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb
DQ 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3
DQ 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3
DQ 0x748f82ee5defb2fc,0x78a5636f43172f60
DQ 0x748f82ee5defb2fc,0x78a5636f43172f60
DQ 0x84c87814a1f0ab72,0x8cc702081a6439ec
DQ 0x84c87814a1f0ab72,0x8cc702081a6439ec
DQ 0x90befffa23631e28,0xa4506cebde82bde9
DQ 0x90befffa23631e28,0xa4506cebde82bde9
DQ 0xbef9a3f7b2c67915,0xc67178f2e372532b
DQ 0xbef9a3f7b2c67915,0xc67178f2e372532b
DQ 0xca273eceea26619c,0xd186b8c721c0c207
DQ 0xca273eceea26619c,0xd186b8c721c0c207
DQ 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178
DQ 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178
DQ 0x06f067aa72176fba,0x0a637dc5a2c898a6
DQ 0x06f067aa72176fba,0x0a637dc5a2c898a6
DQ 0x113f9804bef90dae,0x1b710b35131c471b
DQ 0x113f9804bef90dae,0x1b710b35131c471b
DQ 0x28db77f523047d84,0x32caab7b40c72493
DQ 0x28db77f523047d84,0x32caab7b40c72493
DQ 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c
DQ 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c
DQ 0x4cc5d4becb3e42b6,0x597f299cfc657e2a
DQ 0x4cc5d4becb3e42b6,0x597f299cfc657e2a
DQ 0x5fcb6fab3ad6faec,0x6c44198c4a475817
DQ 0x5fcb6fab3ad6faec,0x6c44198c4a475817
DQ 0x0001020304050607,0x08090a0b0c0d0e0f
DQ 0x0001020304050607,0x08090a0b0c0d0e0f
DB 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97
DB 110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54
DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121
DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46
DB 111,114,103,62,0
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
mov rsi,QWORD[8+r9]
mov r11,QWORD[56+r9]
mov r10d,DWORD[r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jb NEAR $L$in_prologue
mov rax,QWORD[152+r8]
mov r10d,DWORD[4+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jae NEAR $L$in_prologue
mov rsi,rax
mov rax,QWORD[((128+24))+rax]
mov rbx,QWORD[((-8))+rax]
mov rbp,QWORD[((-16))+rax]
mov r12,QWORD[((-24))+rax]
mov r13,QWORD[((-32))+rax]
mov r14,QWORD[((-40))+rax]
mov r15,QWORD[((-48))+rax]
mov QWORD[144+r8],rbx
mov QWORD[160+r8],rbp
mov QWORD[216+r8],r12
mov QWORD[224+r8],r13
mov QWORD[232+r8],r14
mov QWORD[240+r8],r15
lea r10,[$L$epilogue]
cmp rbx,r10
jb NEAR $L$in_prologue
lea rsi,[((128+32))+rsi]
lea rdi,[512+r8]
mov ecx,12
DD 0xa548f3fc
$L$in_prologue:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_sha512_block_data_order wrt ..imagebase
DD $L$SEH_end_sha512_block_data_order wrt ..imagebase
DD $L$SEH_info_sha512_block_data_order wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_sha512_block_data_order:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$prologue wrt ..imagebase,$L$epilogue wrt ..imagebase
|
;*!
;* \copy
;* Copyright (c) 2009-2013, Cisco Systems
;* All rights reserved.
;*
;* Redistribution and use in source and binary forms, with or without
;* modification, are permitted provided that the following conditions
;* are met:
;*
;* * Redistributions of source code must retain the above copyright
;* notice, this list of conditions and the following disclaimer.
;*
;* * Redistributions in binary form must reproduce the above copyright
;* notice, this list of conditions and the following disclaimer in
;* the documentation and/or other materials provided with the
;* distribution.
;*
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
;* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
;* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
;* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
;* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
;* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
;* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
;* POSSIBILITY OF SUCH DAMAGE.
;*
;*
;* memzero.asm
;*
;* Abstract
;*
;*
;* History
;* 9/16/2009 Created
;*
;*
;*************************************************************************/
%include "asm_inc.asm"
;***********************************************************************
; Code
;***********************************************************************
SECTION .text
;***********************************************************************
;void WelsPrefetchZero_mmx(int8_t const*_A);
;***********************************************************************
WELS_EXTERN WelsPrefetchZero_mmx
%assign push_num 0
LOAD_1_PARA
prefetchnta [r0]
ret
;***********************************************************************
; void WelsSetMemZeroAligned64_sse2(void *dst, int32_t size)
;***********************************************************************
WELS_EXTERN WelsSetMemZeroAligned64_sse2
%assign push_num 0
LOAD_2_PARA
SIGN_EXTENSION r1, r1d
neg r1
pxor xmm0, xmm0
.memzeroa64_sse2_loops:
movdqa [r0], xmm0
movdqa [r0+16], xmm0
movdqa [r0+32], xmm0
movdqa [r0+48], xmm0
add r0, 0x40
add r1, 0x40
jnz near .memzeroa64_sse2_loops
ret
;***********************************************************************
; void WelsSetMemZeroSize64_mmx(void *dst, int32_t size)
;***********************************************************************
WELS_EXTERN WelsSetMemZeroSize64_mmx
%assign push_num 0
LOAD_2_PARA
SIGN_EXTENSION r1, r1d
neg r1
pxor mm0, mm0
.memzero64_mmx_loops:
movq [r0], mm0
movq [r0+8], mm0
movq [r0+16], mm0
movq [r0+24], mm0
movq [r0+32], mm0
movq [r0+40], mm0
movq [r0+48], mm0
movq [r0+56], mm0
add r0, 0x40
add r1, 0x40
jnz near .memzero64_mmx_loops
WELSEMMS
ret
;***********************************************************************
; void WelsSetMemZeroSize8_mmx(void *dst, int32_t size)
;***********************************************************************
WELS_EXTERN WelsSetMemZeroSize8_mmx
%assign push_num 0
LOAD_2_PARA
SIGN_EXTENSION r1, r1d
neg r1
pxor mm0, mm0
.memzero8_mmx_loops:
movq [r0], mm0
add r0, 0x08
add r1, 0x08
jnz near .memzero8_mmx_loops
WELSEMMS
ret
|
;*******************************************************************************************
; SIDH: an efficient supersingular isogeny cryptography library
;
; Abstract: utility functions in x64 assembly for P751 on Windows
;*******************************************************************************************
.const
; Under Windows we need to use RCX and RDX as registers for the first two parameters as that is
; the usual calling convention (cf. https://docs.microsoft.com/en-us/cpp/build/parameter-passing).
reg_p1 equ rcx
reg_p2 equ rdx
; Digits of 3^238 - 1
three238m1_0 equ 0EDCD718A828384F8h
three238m1_1 equ 0733B35BFD4427A14h
three238m1_2 equ 0F88229CF94D7CF38h
three238m1_3 equ 063C56C990C7C2AD6h
three238m1_4 equ 0B858A87E8F4222C7h
three238m1_5 equ 0254C9C6B525EAF5h
.code
;***********************************************************************
; Check less than 3^238
; Operation:
; Set result [reg_p2] to 0 if the input [reg_p1] scalar is <= 3^238.
;***********************************************************************
checklt238_asm proc
push r12
push r13
push r14
push r15
; Zero rax for later use.
xor rax, rax
; Set [R10,...,R15] = 3^238
mov r10, three238m1_0
mov r11, three238m1_1
mov r12, three238m1_2
mov r13, three238m1_3
mov r14, three238m1_4
mov r15, three238m1_5
; Set [R10,...,R15] = 3^238 - scalar
sub r10, [reg_p1]
sbb r11, [reg_p1+8]
sbb r12, [reg_p1+16]
sbb r13, [reg_p1+24]
sbb r14, [reg_p1+32]
sbb r15, [reg_p1+40]
; Save borrow flag indicating 3^238 - scalar < 0 as a mask in AX
sbb rax, 0
mov [reg_p2], rax
pop r15
pop r14
pop r13
pop r12
ret
checklt238_asm endp
;***********************************************************************
; Multiply by 3.
; Operation:
; Set scalar [reg_p1] = 3*scalar [reg_p1].
;***********************************************************************
mulby3_asm proc
push r12
push r13
push r14
push r15
; Set [R10,...,R15] = scalar
mov r10, [reg_p1]
mov r11, [reg_p1+8]
mov r12, [reg_p1+16]
mov r13, [reg_p1+24]
mov r14, [reg_p1+32]
mov r15, [reg_p1+40]
; Add scalar twice to compute 3*scalar
add [reg_p1], r10
adc [reg_p1+8], r11
adc [reg_p1+16], r12
adc [reg_p1+24], r13
adc [reg_p1+32], r14
adc [reg_p1+40], r15
add [reg_p1], r10
adc [reg_p1+8], r11
adc [reg_p1+16], r12
adc [reg_p1+24], r13
adc [reg_p1+32], r14
adc [reg_p1+40], r15
pop r15
pop r14
pop r13
pop r12
ret
mulby3_asm endp
end
|
; A051724: Numerator of n/12.
; 0,1,1,1,1,5,1,7,2,3,5,11,1,13,7,5,4,17,3,19,5,7,11,23,2,25,13,9,7,29,5,31,8,11,17,35,3,37,19,13,10,41,7,43,11,15,23,47,4,49,25,17,13,53,9,55,14,19,29,59,5,61,31,21,16,65,11,67,17,23,35,71,6,73,37,25,19,77,13,79,20,27,41,83,7,85,43,29,22,89,15,91,23,31,47,95,8,97,49,33,25,101,17,103,26,35,53,107,9,109,55,37,28,113,19,115,29,39,59,119,10,121,61,41,31,125,21,127,32,43,65,131,11,133,67,45,34,137,23,139,35,47,71,143,12,145,73,49,37,149,25,151,38,51,77,155,13,157,79,53,40,161,27,163,41,55,83,167,14,169,85,57,43,173,29,175,44,59,89,179,15,181,91,61,46,185,31,187,47,63,95,191,16,193,97,65,49,197,33,199,50,67,101,203,17,205,103,69,52,209,35,211,53,71,107,215,18,217,109,73,55,221,37,223,56,75,113,227,19,229,115,77,58,233,39,235,59,79,119,239,20,241,121,81,61,245,41,247,62,83
mov $1,$0
gcd $0,12
div $1,$0
|
// Copyright 2009-2021 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2021, NTESS
// All rights reserved.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.
#include "sst_config.h"
#include "sst/core/heartbeat.h"
#include "sst/core/component.h"
#include "sst/core/simulation_impl.h"
#include "sst/core/timeConverter.h"
#include "sst/core/warnmacros.h"
#ifdef SST_CONFIG_HAVE_MPI
DISABLE_WARN_MISSING_OVERRIDE
#include <mpi.h>
REENABLE_WARNING
#endif
namespace SST {
SimulatorHeartbeat::SimulatorHeartbeat( Config* UNUSED(cfg), int this_rank, Simulation_impl* sim, TimeConverter* period) :
Action(),
rank(this_rank),
m_period( period )
{
sim->insertActivity( period->getFactor(), this );
if( (0 == this_rank) ) {
lastTime = sst_get_cpu_time();
}
// if( (0 == this_rank) ) {
// sim->insertActivity( period->getFactor(), this );
// lastTime = sst_get_cpu_time();
// }
}
SimulatorHeartbeat::~SimulatorHeartbeat() {
}
void SimulatorHeartbeat::execute( void )
{
Simulation_impl *sim = Simulation_impl::getSimulation();
const double now = sst_get_cpu_time();
Output& sim_output = sim->getSimulationOutput();
if ( 0 == rank ) {
sim->getSimulationOutput().output("# Simulation Heartbeat: Simulated Time %s (Real CPU time since last period %.5f seconds)\n",
sim->getElapsedSimTime().toStringBestSI().c_str(), (now - lastTime) );
lastTime = now;
}
SimTime_t next = sim->getCurrentSimCycle() + m_period->getFactor();
sim->insertActivity( next, this );
// Print some resource usage
uint64_t local_max_tv_depth = Simulation_impl::getSimulation()->getTimeVortexMaxDepth();
uint64_t global_max_tv_depth = 0;
uint64_t global_max_sync_data_size = 0, global_sync_data_size = 0;
uint64_t mempool_size = 0;
uint64_t active_activities = 0;
#ifdef USE_MEMPOOL
Activity::getMemPoolUsage(mempool_size, active_activities);
#endif
uint64_t max_mempool_size, global_mempool_size, global_active_activities;
#ifdef SST_CONFIG_HAVE_MPI
uint64_t local_sync_data_size = Simulation_impl::getSimulation()->getSyncQueueDataSize();
MPI_Allreduce(&local_max_tv_depth, &global_max_tv_depth, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD );
MPI_Allreduce(&local_sync_data_size, &global_max_sync_data_size, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD );
MPI_Allreduce(&local_sync_data_size, &global_sync_data_size, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD );
MPI_Allreduce(&mempool_size, &max_mempool_size, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD );
MPI_Allreduce(&mempool_size, &global_mempool_size, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD );
MPI_Allreduce(&active_activities, &global_active_activities, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD );
#else
global_max_tv_depth = local_max_tv_depth;
global_max_sync_data_size = 0;
global_max_sync_data_size = 0;
max_mempool_size = mempool_size;
global_mempool_size = mempool_size;
global_active_activities = active_activities;
#endif
if ( rank == 0 ) {
char ua_buffer[256];
sprintf(ua_buffer, "%" PRIu64 "B", global_max_sync_data_size);
UnitAlgebra global_max_sync_data_size_ua(ua_buffer);
sprintf(ua_buffer, "%" PRIu64 "B", global_sync_data_size);
UnitAlgebra global_sync_data_size_ua(ua_buffer);
sprintf(ua_buffer, "%" PRIu64 "B", max_mempool_size);
UnitAlgebra max_mempool_size_ua(ua_buffer);
sprintf(ua_buffer, "%" PRIu64 "B", global_mempool_size);
UnitAlgebra global_mempool_size_ua(ua_buffer);
sim_output.output("\tMax mempool usage: %s\n",
max_mempool_size_ua.toStringBestSI().c_str());
sim_output.output("\tGlobal mempool usage: %s\n",
global_mempool_size_ua.toStringBestSI().c_str());
sim_output.output("\tGlobal active activities %" PRIu64 " activities\n",
global_active_activities);
sim_output.output("\tMax TimeVortex depth: %" PRIu64 " entries\n",
global_max_tv_depth);
sim_output.output("\tMax Sync data size: %s\n",
global_max_sync_data_size_ua.toStringBestSI().c_str());
sim_output.output("\tGlobal Sync data size: %s\n",
global_sync_data_size_ua.toStringBestSI().c_str());
}
}
} // namespace SST
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WT+0x1c706, %rbp
nop
nop
nop
nop
nop
sub %rdx, %rdx
mov $0x5152535455565758, %rdi
movq %rdi, %xmm3
and $0xffffffffffffffc0, %rbp
movaps %xmm3, (%rbp)
nop
nop
nop
add %rsi, %rsi
// Store
lea addresses_RW+0x2166, %r8
xor $13152, %r13
movl $0x51525354, (%r8)
nop
nop
and %rbp, %rbp
// Faulty Load
lea addresses_normal+0xf706, %r13
nop
nop
nop
nop
cmp %rbp, %rbp
vmovups (%r13), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %rcx
lea oracles, %r13
and $0xff, %rcx
shlq $12, %rcx
mov (%r13,%rcx,1), %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WT', 'size': 16, 'AVXalign': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_RW', 'size': 4, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'34': 1079}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
title HMem
;HMem.asm - huge memory functions HMemCpy, etc
include gpfix.inc
include kernel.inc
externFP Int21Handler
DataBegin
externW WinFlags
ifdef WOW
externD pFileTable
externW cur_dos_PDB
externW Win_PDB
endif
DataEnd
ifdef WOW
externFP WOWFileRead
externFP WOWFileWrite
endif
sBegin CODE
assumes cs,CODE
ifdef WOW
externD prevInt21proc
endif
externA __AHINCR
cProc hMemCpy,<PUBLIC,FAR>,<ds, si, di>
parmD dest ; to ES:DI
parmD src ; to DS:SI
parmD cnt ; to DX:AX
localW flags
cBegin
SetKernelDS
mov bx, WinFlags
mov flags, bx
mov dx, seg_cnt ; DX:AX is 32 bit length
mov ax, off_cnt
xor cx, cx ; 0 if fault loading operands
beg_fault_trap hmc_trap
lds si, src
les di, dest
cld
hmc_loop:
mov cx, 8000h ; try to copy 32K
cmp cx, si ; space left in source?
jae @F
mov cx, si
@@: cmp cx, di ; space left in dest?
jae @F
mov cx, di
@@: neg cx ; convert bytes left to positive
or dx, dx ; >64K left to copy?
jnz @F
cmp cx, ax ; At least this much left?
jbe @F
mov cx, ax
@@: sub ax, cx ; Decrement count while we're here
sbb dx, 0
test flags, WF_CPU386 + WF_CPU486 + WF_ENHANCED
jnz hmc_do32
shr cx, 1 ; Copy 32KB
rep movsw
adc cx, 0
rep movsb
jmps hmc_copied
hmc_do32:
.386p
push cx
shr cx, 2
rep movsd
pop cx
and cx, 3
rep movsb
.286p
hmc_copied:
mov cx, ax ; At end of copy?
or cx, dx
jz hmc_done
or si, si ; Source wrap-around?
jnz @F
mov bx, ds
add bx, __AHINCR
mov ds, bx
@@: or di, di ; Dest wrap-around?
jnz @F
mov bx, es
add bx, __AHINCR
mov es, bx
end_fault_trap
@@: jmps hmc_loop
hmc_trap:
fault_fix_stack ; DX:AX = bytes left if failure
krDebugOut DEB_ERROR, "hMemCopy: Copy past end of segment"
add ax, cx
adc dx, 0
hmc_done: ; DX:AX = 0 if success
cEnd
ifdef W_Q21
cProc _HREAD, <PUBLIC, FAR, NODATA>, <ds>
parmW h
parmD lpData
parmD dwCnt
cBegin
SetKernelDS ds
push bx
mov bx, Win_PDB
cmp bx, cur_dos_PDB
je HR_PDB_ok
push ax
mov cur_dos_PDB,bx
mov ah,50h
pushf
call cs:prevInt21Proc ; JUMP THROUGH CS VARIABLE
pop ax
HR_PDB_OK:
pop bx
cCall WowFileRead,<h,lpData,dwCnt,cur_dos_PDB,0,pFileTable>
; DX:AX = Number Bytes Read
; DX = FFFF, AX = Error Code
inc dx
jnz @f
xor dx,dx
or ax, -1
@@:
dec dx
cEnd
cProc _HWRITE, <PUBLIC, FAR, NODATA>, <ds>
parmW h
parmD lpData
parmD dwCnt
cBegin
SetKernelDS ds
push bx ; Setting the DOS PDB can probably
mov bx, Win_PDB ; be removed just pass Win_PDB to
cmp bx, cur_dos_PDB ; the WOW thunk
je HW_PDB_ok
push ax
mov cur_dos_PDB,bx
mov ah,50h
pushf
call cs:prevInt21Proc ; JUMP THROUGH CS VARIABLE
pop ax
HW_PDB_OK:
pop bx
cCall WowFileWrite,<h,lpData,dwCnt,cur_dos_PDB,0,pFileTable>
; DX:AX = Number Bytes Read
; DX = FFFF, AX = Error Code
inc dx
jnz @f
xor dx,dx
or ax, -1
@@:
dec dx
cEnd
else
public _HREAD, _HWRITE
_HREAD:
mov bx, 3f00h
jmps hugeIO
_HWRITE:
mov bx, 4000h
cProc hugeIO, <FAR, NODATA>, <ds, si, di, cx>
parmW h
parmD lpData
parmD dwCnt
localD dwTot
localW func
cBegin
mov func, bx ; read from a file
mov bx, h
xor cx, cx
mov seg_dwTot, cx
mov off_dwTot, cx
beg_fault_trap hr_fault
lds dx, lpData
mov si, seg_dwCnt
mov di, off_dwCnt
hr_loop:
mov cx, 8000h ; try to do 32KB
cmp cx, dx ; space left in data buffer
jae @F
mov cx, dx
neg cx
@@: or si, si ; at least 64K left
jnz @F
cmp cx, di
jbe @F
mov cx, di
@@: mov ax, func ; talk to DOS
DOSCALL
jc hr_oops
add off_dwTot, ax ; update transfer count
adc seg_dwTot, 0
cmp ax, cx ; end of file?
jnz hr_done
sub di, ax ; decrement count
sbb si, 0
mov cx, si ; end of count
or cx, di
jz hr_done
add dx, ax ; update pointer to data
jnz @F ; wrapped to next segment
mov ax, ds
add ax, __AHINCR
mov ds, ax
end_fault_trap
@@: jmps hr_loop
hr_fault:
pop dx
pop ax
; krDebugOut DEB_ERROR, "File I/O past end of memory block"
krDebugOut DEB_ERROR, "GP fault in _hread/_hwrite at #DX #AX"
; fault_fix_stack
hr_oops:
or dx, -1
mov seg_dwTot, dx
mov off_dwTot, dx
hr_done:
mov dx, seg_dwTot
mov ax, off_dwTot
cEnd
endif ; WOW
sEnd
end
|
; A301653: Expansion of x*(1 + 2*x)/((1 - x)*(1 + x)*(1 - x - x^2)).
; Submitted by Jon Maiga
; 0,1,3,5,10,16,28,45,75,121,198,320,520,841,1363,2205,3570,5776,9348,15125,24475,39601,64078,103680,167760,271441,439203,710645,1149850,1860496,3010348,4870845,7881195,12752041,20633238,33385280,54018520,87403801,141422323,228826125,370248450
add $0,1
mov $1,1
mov $2,2
lpb $0
sub $0,2
add $2,$1
add $1,$2
lpe
lpb $0
mov $2,$0
trn $0,$1
add $2,$1
lpe
mov $0,$2
sub $0,2
|
_wc: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "%d %d %d %s\n", l, w, c, name);
}
int
main(int argc, char *argv[])
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 57 push %edi
4: 56 push %esi
int fd, i;
if(argc <= 1){
5: be 01 00 00 00 mov $0x1,%esi
{
a: 53 push %ebx
b: 83 e4 f0 and $0xfffffff0,%esp
e: 83 ec 10 sub $0x10,%esp
11: 8b 45 0c mov 0xc(%ebp),%eax
if(argc <= 1){
14: 83 7d 08 01 cmpl $0x1,0x8(%ebp)
18: 8d 58 04 lea 0x4(%eax),%ebx
1b: 7e 60 jle 7d <main+0x7d>
1d: 8d 76 00 lea 0x0(%esi),%esi
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
20: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
27: 00
28: 8b 03 mov (%ebx),%eax
2a: 89 04 24 mov %eax,(%esp)
2d: e8 c0 03 00 00 call 3f2 <open>
32: 85 c0 test %eax,%eax
34: 89 c7 mov %eax,%edi
36: 78 26 js 5e <main+0x5e>
printf(1, "wc: cannot open %s\n", argv[i]);
exit();
}
wc(fd, argv[i]);
38: 8b 13 mov (%ebx),%edx
for(i = 1; i < argc; i++){
3a: 83 c6 01 add $0x1,%esi
3d: 83 c3 04 add $0x4,%ebx
wc(fd, argv[i]);
40: 89 04 24 mov %eax,(%esp)
43: 89 54 24 04 mov %edx,0x4(%esp)
47: e8 54 00 00 00 call a0 <wc>
close(fd);
4c: 89 3c 24 mov %edi,(%esp)
4f: e8 86 03 00 00 call 3da <close>
for(i = 1; i < argc; i++){
54: 3b 75 08 cmp 0x8(%ebp),%esi
57: 75 c7 jne 20 <main+0x20>
}
exit();
59: e8 54 03 00 00 call 3b2 <exit>
printf(1, "wc: cannot open %s\n", argv[i]);
5e: 8b 03 mov (%ebx),%eax
60: c7 44 24 04 89 08 00 movl $0x889,0x4(%esp)
67: 00
68: c7 04 24 01 00 00 00 movl $0x1,(%esp)
6f: 89 44 24 08 mov %eax,0x8(%esp)
73: e8 88 04 00 00 call 500 <printf>
exit();
78: e8 35 03 00 00 call 3b2 <exit>
wc(0, "");
7d: c7 44 24 04 7b 08 00 movl $0x87b,0x4(%esp)
84: 00
85: c7 04 24 00 00 00 00 movl $0x0,(%esp)
8c: e8 0f 00 00 00 call a0 <wc>
exit();
91: e8 1c 03 00 00 call 3b2 <exit>
96: 66 90 xchg %ax,%ax
98: 66 90 xchg %ax,%ax
9a: 66 90 xchg %ax,%ax
9c: 66 90 xchg %ax,%ax
9e: 66 90 xchg %ax,%ax
000000a0 <wc>:
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 57 push %edi
a4: 56 push %esi
inword = 0;
a5: 31 f6 xor %esi,%esi
{
a7: 53 push %ebx
l = w = c = 0;
a8: 31 db xor %ebx,%ebx
{
aa: 83 ec 3c sub $0x3c,%esp
l = w = c = 0;
ad: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
b4: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
bb: 90 nop
bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((n = read(fd, buf, sizeof(buf))) > 0){
c0: 8b 45 08 mov 0x8(%ebp),%eax
c3: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
ca: 00
cb: c7 44 24 04 80 0b 00 movl $0xb80,0x4(%esp)
d2: 00
d3: 89 04 24 mov %eax,(%esp)
d6: e8 ef 02 00 00 call 3ca <read>
db: 83 f8 00 cmp $0x0,%eax
de: 89 45 e4 mov %eax,-0x1c(%ebp)
e1: 7e 54 jle 137 <wc+0x97>
e3: 31 ff xor %edi,%edi
e5: eb 0b jmp f2 <wc+0x52>
e7: 90 nop
inword = 0;
e8: 31 f6 xor %esi,%esi
for(i=0; i<n; i++){
ea: 83 c7 01 add $0x1,%edi
ed: 3b 7d e4 cmp -0x1c(%ebp),%edi
f0: 74 38 je 12a <wc+0x8a>
if(buf[i] == '\n')
f2: 0f be 87 80 0b 00 00 movsbl 0xb80(%edi),%eax
l++;
f9: 31 c9 xor %ecx,%ecx
if(strchr(" \r\t\n\v", buf[i]))
fb: c7 04 24 66 08 00 00 movl $0x866,(%esp)
l++;
102: 3c 0a cmp $0xa,%al
104: 0f 94 c1 sete %cl
if(strchr(" \r\t\n\v", buf[i]))
107: 89 44 24 04 mov %eax,0x4(%esp)
l++;
10b: 01 cb add %ecx,%ebx
if(strchr(" \r\t\n\v", buf[i]))
10d: e8 4e 01 00 00 call 260 <strchr>
112: 85 c0 test %eax,%eax
114: 75 d2 jne e8 <wc+0x48>
else if(!inword){
116: 85 f6 test %esi,%esi
118: 75 16 jne 130 <wc+0x90>
w++;
11a: 83 45 e0 01 addl $0x1,-0x20(%ebp)
for(i=0; i<n; i++){
11e: 83 c7 01 add $0x1,%edi
121: 3b 7d e4 cmp -0x1c(%ebp),%edi
inword = 1;
124: 66 be 01 00 mov $0x1,%si
for(i=0; i<n; i++){
128: 75 c8 jne f2 <wc+0x52>
12a: 01 7d dc add %edi,-0x24(%ebp)
12d: eb 91 jmp c0 <wc+0x20>
12f: 90 nop
130: be 01 00 00 00 mov $0x1,%esi
135: eb b3 jmp ea <wc+0x4a>
if(n < 0){
137: 75 35 jne 16e <wc+0xce>
printf(1, "%d %d %d %s\n", l, w, c, name);
139: 8b 45 0c mov 0xc(%ebp),%eax
13c: 89 5c 24 08 mov %ebx,0x8(%esp)
140: c7 44 24 04 7c 08 00 movl $0x87c,0x4(%esp)
147: 00
148: c7 04 24 01 00 00 00 movl $0x1,(%esp)
14f: 89 44 24 14 mov %eax,0x14(%esp)
153: 8b 45 dc mov -0x24(%ebp),%eax
156: 89 44 24 10 mov %eax,0x10(%esp)
15a: 8b 45 e0 mov -0x20(%ebp),%eax
15d: 89 44 24 0c mov %eax,0xc(%esp)
161: e8 9a 03 00 00 call 500 <printf>
}
166: 83 c4 3c add $0x3c,%esp
169: 5b pop %ebx
16a: 5e pop %esi
16b: 5f pop %edi
16c: 5d pop %ebp
16d: c3 ret
printf(1, "wc: read error\n");
16e: c7 44 24 04 6c 08 00 movl $0x86c,0x4(%esp)
175: 00
176: c7 04 24 01 00 00 00 movl $0x1,(%esp)
17d: e8 7e 03 00 00 call 500 <printf>
exit();
182: e8 2b 02 00 00 call 3b2 <exit>
187: 66 90 xchg %ax,%ax
189: 66 90 xchg %ax,%ax
18b: 66 90 xchg %ax,%ax
18d: 66 90 xchg %ax,%ax
18f: 90 nop
00000190 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 8b 45 08 mov 0x8(%ebp),%eax
196: 8b 4d 0c mov 0xc(%ebp),%ecx
199: 53 push %ebx
char *os;
os = s;
while((*s++ = *t++) != 0)
19a: 89 c2 mov %eax,%edx
19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1a0: 83 c1 01 add $0x1,%ecx
1a3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
1a7: 83 c2 01 add $0x1,%edx
1aa: 84 db test %bl,%bl
1ac: 88 5a ff mov %bl,-0x1(%edx)
1af: 75 ef jne 1a0 <strcpy+0x10>
;
return os;
}
1b1: 5b pop %ebx
1b2: 5d pop %ebp
1b3: c3 ret
1b4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1ba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001c0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 8b 55 08 mov 0x8(%ebp),%edx
1c6: 53 push %ebx
1c7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
1ca: 0f b6 02 movzbl (%edx),%eax
1cd: 84 c0 test %al,%al
1cf: 74 2d je 1fe <strcmp+0x3e>
1d1: 0f b6 19 movzbl (%ecx),%ebx
1d4: 38 d8 cmp %bl,%al
1d6: 74 0e je 1e6 <strcmp+0x26>
1d8: eb 2b jmp 205 <strcmp+0x45>
1da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1e0: 38 c8 cmp %cl,%al
1e2: 75 15 jne 1f9 <strcmp+0x39>
p++, q++;
1e4: 89 d9 mov %ebx,%ecx
1e6: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
1e9: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1ec: 8d 59 01 lea 0x1(%ecx),%ebx
while(*p && *p == *q)
1ef: 0f b6 49 01 movzbl 0x1(%ecx),%ecx
1f3: 84 c0 test %al,%al
1f5: 75 e9 jne 1e0 <strcmp+0x20>
1f7: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1f9: 29 c8 sub %ecx,%eax
}
1fb: 5b pop %ebx
1fc: 5d pop %ebp
1fd: c3 ret
1fe: 0f b6 09 movzbl (%ecx),%ecx
while(*p && *p == *q)
201: 31 c0 xor %eax,%eax
203: eb f4 jmp 1f9 <strcmp+0x39>
205: 0f b6 cb movzbl %bl,%ecx
208: eb ef jmp 1f9 <strcmp+0x39>
20a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000210 <strlen>:
uint
strlen(const char *s)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
216: 80 39 00 cmpb $0x0,(%ecx)
219: 74 12 je 22d <strlen+0x1d>
21b: 31 d2 xor %edx,%edx
21d: 8d 76 00 lea 0x0(%esi),%esi
220: 83 c2 01 add $0x1,%edx
223: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
227: 89 d0 mov %edx,%eax
229: 75 f5 jne 220 <strlen+0x10>
;
return n;
}
22b: 5d pop %ebp
22c: c3 ret
for(n = 0; s[n]; n++)
22d: 31 c0 xor %eax,%eax
}
22f: 5d pop %ebp
230: c3 ret
231: eb 0d jmp 240 <memset>
233: 90 nop
234: 90 nop
235: 90 nop
236: 90 nop
237: 90 nop
238: 90 nop
239: 90 nop
23a: 90 nop
23b: 90 nop
23c: 90 nop
23d: 90 nop
23e: 90 nop
23f: 90 nop
00000240 <memset>:
void*
memset(void *dst, int c, uint n)
{
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 8b 55 08 mov 0x8(%ebp),%edx
246: 57 push %edi
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
247: 8b 4d 10 mov 0x10(%ebp),%ecx
24a: 8b 45 0c mov 0xc(%ebp),%eax
24d: 89 d7 mov %edx,%edi
24f: fc cld
250: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
252: 89 d0 mov %edx,%eax
254: 5f pop %edi
255: 5d pop %ebp
256: c3 ret
257: 89 f6 mov %esi,%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <strchr>:
char*
strchr(const char *s, char c)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 8b 45 08 mov 0x8(%ebp),%eax
266: 53 push %ebx
267: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
26a: 0f b6 18 movzbl (%eax),%ebx
26d: 84 db test %bl,%bl
26f: 74 1d je 28e <strchr+0x2e>
if(*s == c)
271: 38 d3 cmp %dl,%bl
273: 89 d1 mov %edx,%ecx
275: 75 0d jne 284 <strchr+0x24>
277: eb 17 jmp 290 <strchr+0x30>
279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
280: 38 ca cmp %cl,%dl
282: 74 0c je 290 <strchr+0x30>
for(; *s; s++)
284: 83 c0 01 add $0x1,%eax
287: 0f b6 10 movzbl (%eax),%edx
28a: 84 d2 test %dl,%dl
28c: 75 f2 jne 280 <strchr+0x20>
return (char*)s;
return 0;
28e: 31 c0 xor %eax,%eax
}
290: 5b pop %ebx
291: 5d pop %ebp
292: c3 ret
293: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002a0 <gets>:
char*
gets(char *buf, int max)
{
2a0: 55 push %ebp
2a1: 89 e5 mov %esp,%ebp
2a3: 57 push %edi
2a4: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
2a5: 31 f6 xor %esi,%esi
{
2a7: 53 push %ebx
2a8: 83 ec 2c sub $0x2c,%esp
cc = read(0, &c, 1);
2ab: 8d 7d e7 lea -0x19(%ebp),%edi
for(i=0; i+1 < max; ){
2ae: eb 31 jmp 2e1 <gets+0x41>
cc = read(0, &c, 1);
2b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
2b7: 00
2b8: 89 7c 24 04 mov %edi,0x4(%esp)
2bc: c7 04 24 00 00 00 00 movl $0x0,(%esp)
2c3: e8 02 01 00 00 call 3ca <read>
if(cc < 1)
2c8: 85 c0 test %eax,%eax
2ca: 7e 1d jle 2e9 <gets+0x49>
break;
buf[i++] = c;
2cc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
for(i=0; i+1 < max; ){
2d0: 89 de mov %ebx,%esi
buf[i++] = c;
2d2: 8b 55 08 mov 0x8(%ebp),%edx
if(c == '\n' || c == '\r')
2d5: 3c 0d cmp $0xd,%al
buf[i++] = c;
2d7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
2db: 74 0c je 2e9 <gets+0x49>
2dd: 3c 0a cmp $0xa,%al
2df: 74 08 je 2e9 <gets+0x49>
for(i=0; i+1 < max; ){
2e1: 8d 5e 01 lea 0x1(%esi),%ebx
2e4: 3b 5d 0c cmp 0xc(%ebp),%ebx
2e7: 7c c7 jl 2b0 <gets+0x10>
break;
}
buf[i] = '\0';
2e9: 8b 45 08 mov 0x8(%ebp),%eax
2ec: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
2f0: 83 c4 2c add $0x2c,%esp
2f3: 5b pop %ebx
2f4: 5e pop %esi
2f5: 5f pop %edi
2f6: 5d pop %ebp
2f7: c3 ret
2f8: 90 nop
2f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000300 <stat>:
int
stat(const char *n, struct stat *st)
{
300: 55 push %ebp
301: 89 e5 mov %esp,%ebp
303: 56 push %esi
304: 53 push %ebx
305: 83 ec 10 sub $0x10,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
308: 8b 45 08 mov 0x8(%ebp),%eax
30b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
312: 00
313: 89 04 24 mov %eax,(%esp)
316: e8 d7 00 00 00 call 3f2 <open>
if(fd < 0)
31b: 85 c0 test %eax,%eax
fd = open(n, O_RDONLY);
31d: 89 c3 mov %eax,%ebx
if(fd < 0)
31f: 78 27 js 348 <stat+0x48>
return -1;
r = fstat(fd, st);
321: 8b 45 0c mov 0xc(%ebp),%eax
324: 89 1c 24 mov %ebx,(%esp)
327: 89 44 24 04 mov %eax,0x4(%esp)
32b: e8 da 00 00 00 call 40a <fstat>
close(fd);
330: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
333: 89 c6 mov %eax,%esi
close(fd);
335: e8 a0 00 00 00 call 3da <close>
return r;
33a: 89 f0 mov %esi,%eax
}
33c: 83 c4 10 add $0x10,%esp
33f: 5b pop %ebx
340: 5e pop %esi
341: 5d pop %ebp
342: c3 ret
343: 90 nop
344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
348: b8 ff ff ff ff mov $0xffffffff,%eax
34d: eb ed jmp 33c <stat+0x3c>
34f: 90 nop
00000350 <atoi>:
int
atoi(const char *s)
{
350: 55 push %ebp
351: 89 e5 mov %esp,%ebp
353: 8b 4d 08 mov 0x8(%ebp),%ecx
356: 53 push %ebx
int n;
n = 0;
while('0' <= *s && *s <= '9')
357: 0f be 11 movsbl (%ecx),%edx
35a: 8d 42 d0 lea -0x30(%edx),%eax
35d: 3c 09 cmp $0x9,%al
n = 0;
35f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
364: 77 17 ja 37d <atoi+0x2d>
366: 66 90 xchg %ax,%ax
n = n*10 + *s++ - '0';
368: 83 c1 01 add $0x1,%ecx
36b: 8d 04 80 lea (%eax,%eax,4),%eax
36e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
372: 0f be 11 movsbl (%ecx),%edx
375: 8d 5a d0 lea -0x30(%edx),%ebx
378: 80 fb 09 cmp $0x9,%bl
37b: 76 eb jbe 368 <atoi+0x18>
return n;
}
37d: 5b pop %ebx
37e: 5d pop %ebp
37f: c3 ret
00000380 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
380: 55 push %ebp
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
381: 31 d2 xor %edx,%edx
{
383: 89 e5 mov %esp,%ebp
385: 56 push %esi
386: 8b 45 08 mov 0x8(%ebp),%eax
389: 53 push %ebx
38a: 8b 5d 10 mov 0x10(%ebp),%ebx
38d: 8b 75 0c mov 0xc(%ebp),%esi
while(n-- > 0)
390: 85 db test %ebx,%ebx
392: 7e 12 jle 3a6 <memmove+0x26>
394: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
398: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
39c: 88 0c 10 mov %cl,(%eax,%edx,1)
39f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
3a2: 39 da cmp %ebx,%edx
3a4: 75 f2 jne 398 <memmove+0x18>
return vdst;
}
3a6: 5b pop %ebx
3a7: 5e pop %esi
3a8: 5d pop %ebp
3a9: c3 ret
000003aa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3aa: b8 01 00 00 00 mov $0x1,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <exit>:
SYSCALL(exit)
3b2: b8 02 00 00 00 mov $0x2,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <wait>:
SYSCALL(wait)
3ba: b8 03 00 00 00 mov $0x3,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <pipe>:
SYSCALL(pipe)
3c2: b8 04 00 00 00 mov $0x4,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <read>:
SYSCALL(read)
3ca: b8 05 00 00 00 mov $0x5,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <write>:
SYSCALL(write)
3d2: b8 10 00 00 00 mov $0x10,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <close>:
SYSCALL(close)
3da: b8 15 00 00 00 mov $0x15,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <kill>:
SYSCALL(kill)
3e2: b8 06 00 00 00 mov $0x6,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <exec>:
SYSCALL(exec)
3ea: b8 07 00 00 00 mov $0x7,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <open>:
SYSCALL(open)
3f2: b8 0f 00 00 00 mov $0xf,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <mknod>:
SYSCALL(mknod)
3fa: b8 11 00 00 00 mov $0x11,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <unlink>:
SYSCALL(unlink)
402: b8 12 00 00 00 mov $0x12,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <fstat>:
SYSCALL(fstat)
40a: b8 08 00 00 00 mov $0x8,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <link>:
SYSCALL(link)
412: b8 13 00 00 00 mov $0x13,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <mkdir>:
SYSCALL(mkdir)
41a: b8 14 00 00 00 mov $0x14,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <chdir>:
SYSCALL(chdir)
422: b8 09 00 00 00 mov $0x9,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <dup>:
SYSCALL(dup)
42a: b8 0a 00 00 00 mov $0xa,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <getpid>:
SYSCALL(getpid)
432: b8 0b 00 00 00 mov $0xb,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <sbrk>:
SYSCALL(sbrk)
43a: b8 0c 00 00 00 mov $0xc,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <sleep>:
SYSCALL(sleep)
442: b8 0d 00 00 00 mov $0xd,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <uptime>:
SYSCALL(uptime)
44a: b8 0e 00 00 00 mov $0xe,%eax
44f: cd 40 int $0x40
451: c3 ret
00000452 <wait2>:
SYSCALL(wait2)
452: b8 16 00 00 00 mov $0x16,%eax
457: cd 40 int $0x40
459: c3 ret
45a: 66 90 xchg %ax,%ax
45c: 66 90 xchg %ax,%ax
45e: 66 90 xchg %ax,%ax
00000460 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
460: 55 push %ebp
461: 89 e5 mov %esp,%ebp
463: 57 push %edi
464: 56 push %esi
465: 89 c6 mov %eax,%esi
467: 53 push %ebx
468: 83 ec 4c sub $0x4c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
46b: 8b 5d 08 mov 0x8(%ebp),%ebx
46e: 85 db test %ebx,%ebx
470: 74 09 je 47b <printint+0x1b>
472: 89 d0 mov %edx,%eax
474: c1 e8 1f shr $0x1f,%eax
477: 84 c0 test %al,%al
479: 75 75 jne 4f0 <printint+0x90>
neg = 1;
x = -xx;
} else {
x = xx;
47b: 89 d0 mov %edx,%eax
neg = 0;
47d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
484: 89 75 c0 mov %esi,-0x40(%ebp)
}
i = 0;
487: 31 ff xor %edi,%edi
489: 89 ce mov %ecx,%esi
48b: 8d 5d d7 lea -0x29(%ebp),%ebx
48e: eb 02 jmp 492 <printint+0x32>
do{
buf[i++] = digits[x % base];
490: 89 cf mov %ecx,%edi
492: 31 d2 xor %edx,%edx
494: f7 f6 div %esi
496: 8d 4f 01 lea 0x1(%edi),%ecx
499: 0f b6 92 a4 08 00 00 movzbl 0x8a4(%edx),%edx
}while((x /= base) != 0);
4a0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
4a2: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
4a5: 75 e9 jne 490 <printint+0x30>
if(neg)
4a7: 8b 55 c4 mov -0x3c(%ebp),%edx
buf[i++] = digits[x % base];
4aa: 89 c8 mov %ecx,%eax
4ac: 8b 75 c0 mov -0x40(%ebp),%esi
if(neg)
4af: 85 d2 test %edx,%edx
4b1: 74 08 je 4bb <printint+0x5b>
buf[i++] = '-';
4b3: 8d 4f 02 lea 0x2(%edi),%ecx
4b6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
while(--i >= 0)
4bb: 8d 79 ff lea -0x1(%ecx),%edi
4be: 66 90 xchg %ax,%ax
4c0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax
4c5: 83 ef 01 sub $0x1,%edi
write(fd, &c, 1);
4c8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4cf: 00
4d0: 89 5c 24 04 mov %ebx,0x4(%esp)
4d4: 89 34 24 mov %esi,(%esp)
4d7: 88 45 d7 mov %al,-0x29(%ebp)
4da: e8 f3 fe ff ff call 3d2 <write>
while(--i >= 0)
4df: 83 ff ff cmp $0xffffffff,%edi
4e2: 75 dc jne 4c0 <printint+0x60>
putc(fd, buf[i]);
}
4e4: 83 c4 4c add $0x4c,%esp
4e7: 5b pop %ebx
4e8: 5e pop %esi
4e9: 5f pop %edi
4ea: 5d pop %ebp
4eb: c3 ret
4ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
x = -xx;
4f0: 89 d0 mov %edx,%eax
4f2: f7 d8 neg %eax
neg = 1;
4f4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
4fb: eb 87 jmp 484 <printint+0x24>
4fd: 8d 76 00 lea 0x0(%esi),%esi
00000500 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
500: 55 push %ebp
501: 89 e5 mov %esp,%ebp
503: 57 push %edi
char *s;
int c, i, state;
uint *ap;
state = 0;
504: 31 ff xor %edi,%edi
{
506: 56 push %esi
507: 53 push %ebx
508: 83 ec 3c sub $0x3c,%esp
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
50b: 8b 5d 0c mov 0xc(%ebp),%ebx
ap = (uint*)(void*)&fmt + 1;
50e: 8d 45 10 lea 0x10(%ebp),%eax
{
511: 8b 75 08 mov 0x8(%ebp),%esi
ap = (uint*)(void*)&fmt + 1;
514: 89 45 d4 mov %eax,-0x2c(%ebp)
for(i = 0; fmt[i]; i++){
517: 0f b6 13 movzbl (%ebx),%edx
51a: 83 c3 01 add $0x1,%ebx
51d: 84 d2 test %dl,%dl
51f: 75 39 jne 55a <printf+0x5a>
521: e9 c2 00 00 00 jmp 5e8 <printf+0xe8>
526: 66 90 xchg %ax,%ax
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
528: 83 fa 25 cmp $0x25,%edx
52b: 0f 84 bf 00 00 00 je 5f0 <printf+0xf0>
write(fd, &c, 1);
531: 8d 45 e2 lea -0x1e(%ebp),%eax
534: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
53b: 00
53c: 89 44 24 04 mov %eax,0x4(%esp)
540: 89 34 24 mov %esi,(%esp)
state = '%';
} else {
putc(fd, c);
543: 88 55 e2 mov %dl,-0x1e(%ebp)
write(fd, &c, 1);
546: e8 87 fe ff ff call 3d2 <write>
54b: 83 c3 01 add $0x1,%ebx
for(i = 0; fmt[i]; i++){
54e: 0f b6 53 ff movzbl -0x1(%ebx),%edx
552: 84 d2 test %dl,%dl
554: 0f 84 8e 00 00 00 je 5e8 <printf+0xe8>
if(state == 0){
55a: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
55c: 0f be c2 movsbl %dl,%eax
if(state == 0){
55f: 74 c7 je 528 <printf+0x28>
}
} else if(state == '%'){
561: 83 ff 25 cmp $0x25,%edi
564: 75 e5 jne 54b <printf+0x4b>
if(c == 'd'){
566: 83 fa 64 cmp $0x64,%edx
569: 0f 84 31 01 00 00 je 6a0 <printf+0x1a0>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
56f: 25 f7 00 00 00 and $0xf7,%eax
574: 83 f8 70 cmp $0x70,%eax
577: 0f 84 83 00 00 00 je 600 <printf+0x100>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
57d: 83 fa 73 cmp $0x73,%edx
580: 0f 84 a2 00 00 00 je 628 <printf+0x128>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
586: 83 fa 63 cmp $0x63,%edx
589: 0f 84 35 01 00 00 je 6c4 <printf+0x1c4>
putc(fd, *ap);
ap++;
} else if(c == '%'){
58f: 83 fa 25 cmp $0x25,%edx
592: 0f 84 e0 00 00 00 je 678 <printf+0x178>
write(fd, &c, 1);
598: 8d 45 e6 lea -0x1a(%ebp),%eax
59b: 83 c3 01 add $0x1,%ebx
59e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
5a5: 00
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
5a6: 31 ff xor %edi,%edi
write(fd, &c, 1);
5a8: 89 44 24 04 mov %eax,0x4(%esp)
5ac: 89 34 24 mov %esi,(%esp)
5af: 89 55 d0 mov %edx,-0x30(%ebp)
5b2: c6 45 e6 25 movb $0x25,-0x1a(%ebp)
5b6: e8 17 fe ff ff call 3d2 <write>
putc(fd, c);
5bb: 8b 55 d0 mov -0x30(%ebp),%edx
write(fd, &c, 1);
5be: 8d 45 e7 lea -0x19(%ebp),%eax
5c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
5c8: 00
5c9: 89 44 24 04 mov %eax,0x4(%esp)
5cd: 89 34 24 mov %esi,(%esp)
putc(fd, c);
5d0: 88 55 e7 mov %dl,-0x19(%ebp)
write(fd, &c, 1);
5d3: e8 fa fd ff ff call 3d2 <write>
for(i = 0; fmt[i]; i++){
5d8: 0f b6 53 ff movzbl -0x1(%ebx),%edx
5dc: 84 d2 test %dl,%dl
5de: 0f 85 76 ff ff ff jne 55a <printf+0x5a>
5e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
}
}
5e8: 83 c4 3c add $0x3c,%esp
5eb: 5b pop %ebx
5ec: 5e pop %esi
5ed: 5f pop %edi
5ee: 5d pop %ebp
5ef: c3 ret
state = '%';
5f0: bf 25 00 00 00 mov $0x25,%edi
5f5: e9 51 ff ff ff jmp 54b <printf+0x4b>
5fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
600: 8b 45 d4 mov -0x2c(%ebp),%eax
603: b9 10 00 00 00 mov $0x10,%ecx
state = 0;
608: 31 ff xor %edi,%edi
printint(fd, *ap, 16, 0);
60a: c7 04 24 00 00 00 00 movl $0x0,(%esp)
611: 8b 10 mov (%eax),%edx
613: 89 f0 mov %esi,%eax
615: e8 46 fe ff ff call 460 <printint>
ap++;
61a: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
61e: e9 28 ff ff ff jmp 54b <printf+0x4b>
623: 90 nop
624: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
628: 8b 45 d4 mov -0x2c(%ebp),%eax
ap++;
62b: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
s = (char*)*ap;
62f: 8b 38 mov (%eax),%edi
s = "(null)";
631: b8 9d 08 00 00 mov $0x89d,%eax
636: 85 ff test %edi,%edi
638: 0f 44 f8 cmove %eax,%edi
while(*s != 0){
63b: 0f b6 07 movzbl (%edi),%eax
63e: 84 c0 test %al,%al
640: 74 2a je 66c <printf+0x16c>
642: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
648: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
64b: 8d 45 e3 lea -0x1d(%ebp),%eax
s++;
64e: 83 c7 01 add $0x1,%edi
write(fd, &c, 1);
651: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
658: 00
659: 89 44 24 04 mov %eax,0x4(%esp)
65d: 89 34 24 mov %esi,(%esp)
660: e8 6d fd ff ff call 3d2 <write>
while(*s != 0){
665: 0f b6 07 movzbl (%edi),%eax
668: 84 c0 test %al,%al
66a: 75 dc jne 648 <printf+0x148>
state = 0;
66c: 31 ff xor %edi,%edi
66e: e9 d8 fe ff ff jmp 54b <printf+0x4b>
673: 90 nop
674: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
write(fd, &c, 1);
678: 8d 45 e5 lea -0x1b(%ebp),%eax
state = 0;
67b: 31 ff xor %edi,%edi
write(fd, &c, 1);
67d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
684: 00
685: 89 44 24 04 mov %eax,0x4(%esp)
689: 89 34 24 mov %esi,(%esp)
68c: c6 45 e5 25 movb $0x25,-0x1b(%ebp)
690: e8 3d fd ff ff call 3d2 <write>
695: e9 b1 fe ff ff jmp 54b <printf+0x4b>
69a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 10, 1);
6a0: 8b 45 d4 mov -0x2c(%ebp),%eax
6a3: b9 0a 00 00 00 mov $0xa,%ecx
state = 0;
6a8: 66 31 ff xor %di,%di
printint(fd, *ap, 10, 1);
6ab: c7 04 24 01 00 00 00 movl $0x1,(%esp)
6b2: 8b 10 mov (%eax),%edx
6b4: 89 f0 mov %esi,%eax
6b6: e8 a5 fd ff ff call 460 <printint>
ap++;
6bb: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
6bf: e9 87 fe ff ff jmp 54b <printf+0x4b>
putc(fd, *ap);
6c4: 8b 45 d4 mov -0x2c(%ebp),%eax
state = 0;
6c7: 31 ff xor %edi,%edi
putc(fd, *ap);
6c9: 8b 00 mov (%eax),%eax
write(fd, &c, 1);
6cb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
6d2: 00
6d3: 89 34 24 mov %esi,(%esp)
putc(fd, *ap);
6d6: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
6d9: 8d 45 e4 lea -0x1c(%ebp),%eax
6dc: 89 44 24 04 mov %eax,0x4(%esp)
6e0: e8 ed fc ff ff call 3d2 <write>
ap++;
6e5: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
6e9: e9 5d fe ff ff jmp 54b <printf+0x4b>
6ee: 66 90 xchg %ax,%ax
000006f0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
6f0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6f1: a1 60 0b 00 00 mov 0xb60,%eax
{
6f6: 89 e5 mov %esp,%ebp
6f8: 57 push %edi
6f9: 56 push %esi
6fa: 53 push %ebx
6fb: 8b 5d 08 mov 0x8(%ebp),%ebx
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6fe: 8b 08 mov (%eax),%ecx
bp = (Header*)ap - 1;
700: 8d 53 f8 lea -0x8(%ebx),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
703: 39 d0 cmp %edx,%eax
705: 72 11 jb 718 <free+0x28>
707: 90 nop
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
708: 39 c8 cmp %ecx,%eax
70a: 72 04 jb 710 <free+0x20>
70c: 39 ca cmp %ecx,%edx
70e: 72 10 jb 720 <free+0x30>
710: 89 c8 mov %ecx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
712: 39 d0 cmp %edx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
714: 8b 08 mov (%eax),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
716: 73 f0 jae 708 <free+0x18>
718: 39 ca cmp %ecx,%edx
71a: 72 04 jb 720 <free+0x30>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
71c: 39 c8 cmp %ecx,%eax
71e: 72 f0 jb 710 <free+0x20>
break;
if(bp + bp->s.size == p->s.ptr){
720: 8b 73 fc mov -0x4(%ebx),%esi
723: 8d 3c f2 lea (%edx,%esi,8),%edi
726: 39 cf cmp %ecx,%edi
728: 74 1e je 748 <free+0x58>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
72a: 89 4b f8 mov %ecx,-0x8(%ebx)
if(p + p->s.size == bp){
72d: 8b 48 04 mov 0x4(%eax),%ecx
730: 8d 34 c8 lea (%eax,%ecx,8),%esi
733: 39 f2 cmp %esi,%edx
735: 74 28 je 75f <free+0x6f>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
737: 89 10 mov %edx,(%eax)
freep = p;
739: a3 60 0b 00 00 mov %eax,0xb60
}
73e: 5b pop %ebx
73f: 5e pop %esi
740: 5f pop %edi
741: 5d pop %ebp
742: c3 ret
743: 90 nop
744: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
748: 03 71 04 add 0x4(%ecx),%esi
74b: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
74e: 8b 08 mov (%eax),%ecx
750: 8b 09 mov (%ecx),%ecx
752: 89 4b f8 mov %ecx,-0x8(%ebx)
if(p + p->s.size == bp){
755: 8b 48 04 mov 0x4(%eax),%ecx
758: 8d 34 c8 lea (%eax,%ecx,8),%esi
75b: 39 f2 cmp %esi,%edx
75d: 75 d8 jne 737 <free+0x47>
p->s.size += bp->s.size;
75f: 03 4b fc add -0x4(%ebx),%ecx
freep = p;
762: a3 60 0b 00 00 mov %eax,0xb60
p->s.size += bp->s.size;
767: 89 48 04 mov %ecx,0x4(%eax)
p->s.ptr = bp->s.ptr;
76a: 8b 53 f8 mov -0x8(%ebx),%edx
76d: 89 10 mov %edx,(%eax)
}
76f: 5b pop %ebx
770: 5e pop %esi
771: 5f pop %edi
772: 5d pop %ebp
773: c3 ret
774: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
77a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000780 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
780: 55 push %ebp
781: 89 e5 mov %esp,%ebp
783: 57 push %edi
784: 56 push %esi
785: 53 push %ebx
786: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
789: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
78c: 8b 1d 60 0b 00 00 mov 0xb60,%ebx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
792: 8d 48 07 lea 0x7(%eax),%ecx
795: c1 e9 03 shr $0x3,%ecx
if((prevp = freep) == 0){
798: 85 db test %ebx,%ebx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
79a: 8d 71 01 lea 0x1(%ecx),%esi
if((prevp = freep) == 0){
79d: 0f 84 9b 00 00 00 je 83e <malloc+0xbe>
7a3: 8b 13 mov (%ebx),%edx
7a5: 8b 7a 04 mov 0x4(%edx),%edi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
7a8: 39 fe cmp %edi,%esi
7aa: 76 64 jbe 810 <malloc+0x90>
7ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax
if(nu < 4096)
7b3: bb 00 80 00 00 mov $0x8000,%ebx
7b8: 89 45 e4 mov %eax,-0x1c(%ebp)
7bb: eb 0e jmp 7cb <malloc+0x4b>
7bd: 8d 76 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7c0: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
7c2: 8b 78 04 mov 0x4(%eax),%edi
7c5: 39 fe cmp %edi,%esi
7c7: 76 4f jbe 818 <malloc+0x98>
7c9: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
7cb: 3b 15 60 0b 00 00 cmp 0xb60,%edx
7d1: 75 ed jne 7c0 <malloc+0x40>
if(nu < 4096)
7d3: 8b 45 e4 mov -0x1c(%ebp),%eax
7d6: 81 fe 00 10 00 00 cmp $0x1000,%esi
7dc: bf 00 10 00 00 mov $0x1000,%edi
7e1: 0f 43 fe cmovae %esi,%edi
7e4: 0f 42 c3 cmovb %ebx,%eax
p = sbrk(nu * sizeof(Header));
7e7: 89 04 24 mov %eax,(%esp)
7ea: e8 4b fc ff ff call 43a <sbrk>
if(p == (char*)-1)
7ef: 83 f8 ff cmp $0xffffffff,%eax
7f2: 74 18 je 80c <malloc+0x8c>
hp->s.size = nu;
7f4: 89 78 04 mov %edi,0x4(%eax)
free((void*)(hp + 1));
7f7: 83 c0 08 add $0x8,%eax
7fa: 89 04 24 mov %eax,(%esp)
7fd: e8 ee fe ff ff call 6f0 <free>
return freep;
802: 8b 15 60 0b 00 00 mov 0xb60,%edx
if((p = morecore(nunits)) == 0)
808: 85 d2 test %edx,%edx
80a: 75 b4 jne 7c0 <malloc+0x40>
return 0;
80c: 31 c0 xor %eax,%eax
80e: eb 20 jmp 830 <malloc+0xb0>
if(p->s.size >= nunits){
810: 89 d0 mov %edx,%eax
812: 89 da mov %ebx,%edx
814: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
818: 39 fe cmp %edi,%esi
81a: 74 1c je 838 <malloc+0xb8>
p->s.size -= nunits;
81c: 29 f7 sub %esi,%edi
81e: 89 78 04 mov %edi,0x4(%eax)
p += p->s.size;
821: 8d 04 f8 lea (%eax,%edi,8),%eax
p->s.size = nunits;
824: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
827: 89 15 60 0b 00 00 mov %edx,0xb60
return (void*)(p + 1);
82d: 83 c0 08 add $0x8,%eax
}
}
830: 83 c4 1c add $0x1c,%esp
833: 5b pop %ebx
834: 5e pop %esi
835: 5f pop %edi
836: 5d pop %ebp
837: c3 ret
prevp->s.ptr = p->s.ptr;
838: 8b 08 mov (%eax),%ecx
83a: 89 0a mov %ecx,(%edx)
83c: eb e9 jmp 827 <malloc+0xa7>
base.s.ptr = freep = prevp = &base;
83e: c7 05 60 0b 00 00 64 movl $0xb64,0xb60
845: 0b 00 00
base.s.size = 0;
848: ba 64 0b 00 00 mov $0xb64,%edx
base.s.ptr = freep = prevp = &base;
84d: c7 05 64 0b 00 00 64 movl $0xb64,0xb64
854: 0b 00 00
base.s.size = 0;
857: c7 05 68 0b 00 00 00 movl $0x0,0xb68
85e: 00 00 00
861: e9 46 ff ff ff jmp 7ac <malloc+0x2c>
|
;
; Template
;
XXX: .block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Definitions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Vars
;
.section section_ZP
.send section_ZP
.section section_BSS
.send section_BSS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Macros
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Code
;
.section section_CODE
jumpTable:
jmp init
jmp update
jmp render
init:
rts
update:
rts
render:
rts
.send section_CODE
.bend |
/*
* Copyright (c) 2021, Intel Corporation
*
* 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 decode_mpeg2_mem_compression.cpp
//! \brief Defines the common interface for Mpeg2 decode mmc
//! \details The mmc is to handle mmc operations,
//! including compression and decompressin of Mpeg2 decode
//!
#include "mos_defs.h"
#include "decode_mpeg2_mem_compression.h"
#include "decode_utils.h"
namespace decode
{
Mpeg2DecodeMemComp::Mpeg2DecodeMemComp(CodechalHwInterface *hwInterface)
{
m_osInterface = hwInterface->GetOsInterface();
}
MOS_STATUS Mpeg2DecodeMemComp::CheckReferenceList(Mpeg2BasicFeature &mpeg2BasicFeature, MHW_VDBOX_PIPE_BUF_ADDR_PARAMS &pipeBufAddrParams)
{
DECODE_FUNC_CALL();
return CheckReferenceList(mpeg2BasicFeature, pipeBufAddrParams.PreDeblockSurfMmcState, pipeBufAddrParams.PostDeblockSurfMmcState);
}
MOS_STATUS Mpeg2DecodeMemComp::CheckReferenceList(
Mpeg2BasicFeature &mpeg2BasicFeature, MOS_MEMCOMP_STATE &preDeblockSurfMmcState, MOS_MEMCOMP_STATE &postDeblockSurfMmcState)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
DECODE_FUNC_CALL();
DECODE_CHK_NULL(m_osInterface);
if (((postDeblockSurfMmcState != MOS_MEMCOMP_DISABLED) ||
(preDeblockSurfMmcState != MOS_MEMCOMP_DISABLED)) &&
(mpeg2BasicFeature.m_mpeg2PicParams->m_pictureCodingType != I_TYPE))
{
bool selfReference = false;
if ((mpeg2BasicFeature.m_mpeg2PicParams->m_currPic.FrameIdx == mpeg2BasicFeature.m_mpeg2PicParams->m_forwardRefIdx) ||
(mpeg2BasicFeature.m_mpeg2PicParams->m_currPic.FrameIdx == mpeg2BasicFeature.m_mpeg2PicParams->m_backwardRefIdx))
{
selfReference = true;
}
if (selfReference)
{
postDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
preDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
DECODE_ASSERTMESSAGE("Self-reference is detected for P/B frames!");
//Decompress current frame to avoid green corruption in this error handling case
MOS_MEMCOMP_STATE mmcMode;
DECODE_CHK_STATUS(m_osInterface->pfnGetMemoryCompressionMode(m_osInterface,
&mpeg2BasicFeature.m_destSurface.OsResource,
&mmcMode));
if (mmcMode != MOS_MEMCOMP_DISABLED)
{
DECODE_CHK_STATUS(m_osInterface->pfnDecompResource(
m_osInterface,
&mpeg2BasicFeature.m_destSurface.OsResource));
}
}
}
return eStatus;
}
}
|
; A145134: Expansion of x/((1 - x - x^4)*(1 - x)^5).
; Submitted by Jon Maiga
; 0,1,6,21,56,127,259,490,876,1498,2472,3963,6204,9522,14374,21397,31477,45844,66203,94915,135247,191717,270570,380435,533232,745424,1039745,1447585,2012282,2793666,3874331,5368292,7432934,10285505,14225881,19667988,27183173,37560068,51887219,71667137,98973720,136669539,188705753,260536075,359688160,496552279,685469908,946236283,1306174343,1802997347,2488760080,3435312614,4741828012,6545192649,9034347739,12470084623,17212367761,23758048045,32792917639,45263560107,62476523533,86235206954
mov $3,4
lpb $0
mov $2,$0
sub $0,3
trn $0,1
add $2,$3
add $3,1
bin $2,$3
add $1,$2
lpe
mov $0,$1
|
; A028169: Expansion of 1/((1-5x)(1-6x)(1-7x)(1-12x)).
; Submitted by Christian Krause
; 1,30,577,9114,129349,1723086,22075129,275977218,3397380877,41418850902,501892142401,6058699871562,72968197588885,877537225626078,10544318356835593,126631590349302546,1520293638382550173
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,19757 ; Expansion of 1/((1-5*x)(1-6*x)(1-7*x)).
mul $1,12
add $1,$0
lpe
mov $0,$1
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Epson 24-pin driver
FILE: epshi24dual34Info.asm
AUTHOR: Tsutomu Owa
REVISION HISTORY:
Name Date Description
---- ---- -----------
Owa 1/94 Initial revision
DESCRIPTION:
This file contains the device information for the Toshiba dual34 printer
Other Printers Supported by this resource:
Toshiba DualMode Printer 4V Color
Toshiba DualMode Printer 4VE Color
$Id: epshi24dual34Info.asm,v 1.1 97/04/18 11:54:10 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;----------------------------------------------------------------------------
; Toshiba Dual Mode Printer
;----------------------------------------------------------------------------
dual34Info segment resource
; info blocks
PrinterInfo < ; ---- PrinterType -------------
< PT_RASTER,
BMF_4CMYK >, ; 4-bit CMYK (printers)
; ---- PrinterConnections ------
< IC_NO_IEEE488,
CC_NO_CUSTOM,
SC_NO_SCSI,
RC_NO_RS232C,
CC_CENTRONICS,
FC_FILE,
AC_NO_APPLETALK >,
; ---- PrinterSmarts -----------
PS_DUMB_RASTER,
;-------Custom Entry Routine-------
NULL,
;-------Custom Exit Routine-------
NULL,
; ---- Mode Info Offsets -------
offset dual34lowRes,
offset dual34medRes,
offset dual34hiRes,
offset printerFontInfo:lq800draft,
offset printerFontInfo:lq800nlq,
; ---- Font Geometry -----------
offset dual34fontGeometries,
; ---- Symbol Set list -----------
NULL,
; ---- PaperMargins ------------
< 39, ; Tractor Margins, 13mm
29, ; 10.2mm
39, ; 13mm
66>, ; 23.3mm
< 15, ; ASF Margins, 5.08mm
29, ; 10mm
15, ; 5.08mm
57>, ; 15mm + 5mm
; ---- PaperInputOptions -------
< MF_MANUAL1,
TF_NO_TRACTOR,
ASF_TRAY1 >,
; ---- PaperOutputOptions ------
< OC_NO_COPIES,
PS_NORMAL,
OD_SIMPLEX,
SO_NO_STAPLER,
OS_NO_SORTER,
OB_NO_OUTPUTBIN >,
;
1080, ; paper width (points). 381mm
NULL, ; Main UI
ASF1BinOnlyOptionsDialogBox, ; Options UI
PrintEvalASF1BinOnly ; eval routine address
>
;----------------------------------------------------------------------------
; Graphics modes info
;----------------------------------------------------------------------------
dual34lowRes GraphicsProperties < LO_RES_X_RES, ; xres
LO_RES_Y_RES, ; yres
LO_RES_BAND_HEIGHT, ; band height
LO_RES_BUFF_HEIGHT, ; buffer height
LO_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_4CMYK, ;color format
handle CorrectInk > ; color format
dual34medRes GraphicsProperties < MED_RES_X_RES, ; xres
MED_RES_Y_RES, ; yres
MED_RES_BAND_HEIGHT, ; band height
MED_RES_BUFF_HEIGHT, ; buffer height
MED_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_4CMYK, ;color format
handle CorrectInk > ; color format
dual34hiRes GraphicsProperties < HI_RES_X_RES, ; xres
HI_RES_Y_RES, ; yres
HI_RES_BAND_HEIGHT, ; band height
HI_RES_BUFF_HEIGHT, ; buffer height
HI_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_4CMYK, ;color format
handle CorrectInk > ; color format
;----------------------------------------------------------------------------
; Text modes info
;----------------------------------------------------------------------------
;need to add geometries in ascending pointsize, grouped by font
dual34fontGeometries FontGeometry \
< FID_DTC_URW_ROMAN,
8,
offset dual34_8ptpitchTab >,
< FID_DTC_URW_ROMAN,
12,
offset dual34_12ptpitchTab >,
< FID_DTC_URW_SANS,
8,
offset dual34_8ptpitchTab >,
< FID_DTC_URW_SANS,
12,
offset dual34_12ptpitchTab >
word FID_INVALID ;table terminator
dual34_8ptpitchTab label byte
byte TP_15_PITCH
byte TP_PROPORTIONAL ;"table Terminator"
dual34_12ptpitchTab label byte
byte TP_20_PITCH
byte TP_17_PITCH
byte TP_12_PITCH
byte TP_10_PITCH
byte TP_6_PITCH
byte TP_5_PITCH
byte TP_PROPORTIONAL ;"table Terminator"
dual34Info ends
|
/*! \file */
/* ************************************************************************
* Copyright (c) 2019-2020 Advanced Micro Devices, Inc.
*
* 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 "testing.hpp"
template <typename T>
void testing_csr2hyb_bad_arg(const Arguments& arg)
{
static const size_t safe_size = 100;
// Create rocsparse handle
rocsparse_local_handle handle;
// Create matrix descriptor
rocsparse_local_mat_descr descr;
// Create hyb matrix
rocsparse_local_hyb_mat hyb;
// Allocate memory on device
device_vector<rocsparse_int> dcsr_row_ptr(safe_size);
device_vector<rocsparse_int> dcsr_col_ind(safe_size);
device_vector<T> dcsr_val(safe_size);
if(!dcsr_row_ptr || !dcsr_col_ind || !dcsr_val)
{
CHECK_HIP_ERROR(hipErrorOutOfMemory);
return;
}
// Test rocsparse_csr2hyb()
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(nullptr,
safe_size,
safe_size,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_handle);
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
safe_size,
safe_size,
nullptr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_pointer);
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
safe_size,
safe_size,
descr,
nullptr,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_pointer);
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
safe_size,
safe_size,
descr,
dcsr_val,
nullptr,
dcsr_col_ind,
hyb,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_pointer);
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
safe_size,
safe_size,
descr,
dcsr_val,
dcsr_row_ptr,
nullptr,
hyb,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_pointer);
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
safe_size,
safe_size,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
nullptr,
0,
rocsparse_hyb_partition_auto),
rocsparse_status_invalid_pointer);
}
template <typename T>
void testing_csr2hyb(const Arguments& arg)
{
// Sample matrix
rocsparse_matrix_factory<T> matrix_factory(arg);
rocsparse_int M = arg.M;
rocsparse_int N = arg.N;
rocsparse_index_base base = arg.baseA;
rocsparse_hyb_partition part = arg.part;
rocsparse_int user_ell_width = arg.algo;
// Create rocsparse handle
rocsparse_local_handle handle;
// Create matrix descriptor
rocsparse_local_mat_descr descr;
// Create hyb matrix
rocsparse_local_hyb_mat hyb;
// Set matrix index base
CHECK_ROCSPARSE_ERROR(rocsparse_set_mat_index_base(descr, base));
// Argument sanity check before allocating invalid memory
if(M <= 0 || N <= 0)
{
static const size_t safe_size = 100;
// Allocate memory on device
device_vector<rocsparse_int> dcsr_row_ptr(safe_size);
device_vector<rocsparse_int> dcsr_col_ind(safe_size);
device_vector<T> dcsr_val(safe_size);
if(!dcsr_row_ptr || !dcsr_col_ind || !dcsr_val)
{
CHECK_HIP_ERROR(hipErrorOutOfMemory);
return;
}
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
M,
N,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
user_ell_width,
part),
(M < 0 || N < 0) ? rocsparse_status_invalid_size
: rocsparse_status_success);
return;
}
// Allocate host memory for CSR matrix
host_vector<rocsparse_int> hcsr_row_ptr;
host_vector<rocsparse_int> hcsr_col_ind;
host_vector<T> hcsr_val;
host_vector<rocsparse_int> hhyb_ell_col_ind_gold;
host_vector<T> hhyb_ell_val_gold;
host_vector<rocsparse_int> hhyb_coo_row_ind_gold;
host_vector<rocsparse_int> hhyb_coo_col_ind_gold;
host_vector<T> hhyb_coo_val_gold;
rocsparse_int nnz;
matrix_factory.init_csr(hcsr_row_ptr, hcsr_col_ind, hcsr_val, M, N, nnz, base);
// Allocate device memory
device_vector<rocsparse_int> dcsr_row_ptr(M + 1);
device_vector<rocsparse_int> dcsr_col_ind(nnz);
device_vector<T> dcsr_val(nnz);
if(!dcsr_row_ptr || !dcsr_col_ind || !dcsr_val)
{
CHECK_HIP_ERROR(hipErrorOutOfMemory);
return;
}
// Copy data from CPU to device
CHECK_HIP_ERROR(hipMemcpy(
dcsr_row_ptr, hcsr_row_ptr, sizeof(rocsparse_int) * (M + 1), hipMemcpyHostToDevice));
CHECK_HIP_ERROR(
hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(rocsparse_int) * nnz, hipMemcpyHostToDevice));
CHECK_HIP_ERROR(hipMemcpy(dcsr_val, hcsr_val, sizeof(T) * nnz, hipMemcpyHostToDevice));
// User width check
if(part == rocsparse_hyb_partition_user)
{
// ELL width -33 means we take a reasonable pre-computed width
user_ell_width = (user_ell_width == -33) ? nnz / M : user_ell_width;
// Test invalid user_ell_width
rocsparse_int max_allowed = (2 * nnz - 1) / M + 1;
if(user_ell_width < 0 || user_ell_width > max_allowed)
{
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
M,
N,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
user_ell_width,
part),
rocsparse_status_invalid_value);
return;
}
}
// Max width check
if(part == rocsparse_hyb_partition_max)
{
// Compute max ELL width
rocsparse_int ell_max_width = 0;
for(rocsparse_int i = 0; i < M; ++i)
{
ell_max_width = std::max(hcsr_row_ptr[i + 1] - hcsr_row_ptr[i], ell_max_width);
}
rocsparse_int width_limit = (2 * nnz - 1) / M + 1;
if(ell_max_width > width_limit)
{
EXPECT_ROCSPARSE_STATUS(rocsparse_csr2hyb<T>(handle,
M,
N,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
user_ell_width,
part),
rocsparse_status_invalid_value);
return;
}
}
if(arg.unit_check)
{
CHECK_ROCSPARSE_ERROR(rocsparse_csr2hyb<T>(
handle, M, N, descr, dcsr_val, dcsr_row_ptr, dcsr_col_ind, hyb, user_ell_width, part));
// Copy output to host
rocsparse_hyb_mat ptr = hyb;
test_hyb* dhyb = reinterpret_cast<test_hyb*>(ptr);
rocsparse_int ell_nnz = dhyb->ell_nnz;
rocsparse_int coo_nnz = dhyb->coo_nnz;
host_vector<rocsparse_int> hhyb_ell_col_ind(ell_nnz);
host_vector<T> hhyb_ell_val(ell_nnz);
host_vector<rocsparse_int> hhyb_coo_row_ind(coo_nnz);
host_vector<rocsparse_int> hhyb_coo_col_ind(coo_nnz);
host_vector<T> hhyb_coo_val(coo_nnz);
// Copy output to host
CHECK_HIP_ERROR(hipMemcpy(hhyb_ell_col_ind,
dhyb->ell_col_ind,
sizeof(rocsparse_int) * ell_nnz,
hipMemcpyDeviceToHost));
CHECK_HIP_ERROR(
hipMemcpy(hhyb_ell_val, dhyb->ell_val, sizeof(T) * ell_nnz, hipMemcpyDeviceToHost));
CHECK_HIP_ERROR(hipMemcpy(hhyb_coo_row_ind,
dhyb->coo_row_ind,
sizeof(rocsparse_int) * coo_nnz,
hipMemcpyDeviceToHost));
CHECK_HIP_ERROR(hipMemcpy(hhyb_coo_col_ind,
dhyb->coo_col_ind,
sizeof(rocsparse_int) * coo_nnz,
hipMemcpyDeviceToHost));
CHECK_HIP_ERROR(
hipMemcpy(hhyb_coo_val, dhyb->coo_val, sizeof(T) * coo_nnz, hipMemcpyDeviceToHost));
// CPU csr2hyb
rocsparse_int ell_width_gold = user_ell_width;
rocsparse_int ell_nnz_gold;
rocsparse_int coo_nnz_gold;
host_csr_to_hyb<T>(M,
nnz,
hcsr_row_ptr,
hcsr_col_ind,
hcsr_val,
hhyb_ell_col_ind_gold,
hhyb_ell_val_gold,
ell_width_gold,
ell_nnz_gold,
hhyb_coo_row_ind_gold,
hhyb_coo_col_ind_gold,
hhyb_coo_val_gold,
coo_nnz_gold,
part,
base);
unit_check_general<rocsparse_int>(1, 1, 1, &M, &dhyb->m);
unit_check_general<rocsparse_int>(1, 1, 1, &N, &dhyb->n);
unit_check_general<rocsparse_int>(1, 1, 1, &ell_width_gold, &dhyb->ell_width);
unit_check_general<rocsparse_int>(1, 1, 1, &ell_nnz_gold, &dhyb->ell_nnz);
unit_check_general<rocsparse_int>(1, 1, 1, &coo_nnz_gold, &dhyb->coo_nnz);
unit_check_general<rocsparse_int>(1, ell_nnz, 1, hhyb_ell_col_ind_gold, hhyb_ell_col_ind);
unit_check_general<T>(1, ell_nnz, 1, hhyb_ell_val_gold, hhyb_ell_val);
unit_check_general<rocsparse_int>(1, coo_nnz, 1, hhyb_coo_row_ind_gold, hhyb_coo_row_ind);
unit_check_general<rocsparse_int>(1, coo_nnz, 1, hhyb_coo_col_ind_gold, hhyb_coo_col_ind);
unit_check_general<T>(1, coo_nnz, 1, hhyb_coo_val_gold, hhyb_coo_val);
}
if(arg.timing)
{
int number_cold_calls = 2;
int number_hot_calls = arg.iters;
// Warm up
for(int iter = 0; iter < number_cold_calls; ++iter)
{
CHECK_ROCSPARSE_ERROR(rocsparse_csr2hyb<T>(handle,
M,
N,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
user_ell_width,
part));
}
double gpu_time_used = get_time_us();
// Performance run
for(int iter = 0; iter < number_hot_calls; ++iter)
{
CHECK_ROCSPARSE_ERROR(rocsparse_csr2hyb<T>(handle,
M,
N,
descr,
dcsr_val,
dcsr_row_ptr,
dcsr_col_ind,
hyb,
user_ell_width,
part));
}
gpu_time_used = (get_time_us() - gpu_time_used) / number_hot_calls;
rocsparse_hyb_mat ptr = hyb;
test_hyb* dhyb = reinterpret_cast<test_hyb*>(ptr);
rocsparse_int ell_nnz = dhyb->ell_nnz;
rocsparse_int coo_nnz = dhyb->coo_nnz;
double gpu_gbyte = csr2hyb_gbyte_count<T>(M, nnz, ell_nnz, coo_nnz) / gpu_time_used * 1e6;
std::cout.precision(2);
std::cout.setf(std::ios::fixed);
std::cout.setf(std::ios::left);
std::cout << std::setw(12) << "M" << std::setw(12) << "N" << std::setw(12) << "ELL nnz"
<< std::setw(12) << "COO nnz" << std::setw(12) << "GB/s" << std::setw(12)
<< "msec" << std::setw(12) << "iter" << std::setw(12) << "verified" << std::endl;
std::cout << std::setw(12) << M << std::setw(12) << N << std::setw(12) << ell_nnz
<< std::setw(12) << coo_nnz << std::setw(12) << gpu_gbyte << std::setw(12)
<< gpu_time_used / 1e3 << std::setw(12) << number_hot_calls << std::setw(12)
<< (arg.unit_check ? "yes" : "no") << std::endl;
}
}
#define INSTANTIATE(TYPE) \
template void testing_csr2hyb_bad_arg<TYPE>(const Arguments& arg); \
template void testing_csr2hyb<TYPE>(const Arguments& arg)
INSTANTIATE(float);
INSTANTIATE(double);
INSTANTIATE(rocsparse_float_complex);
INSTANTIATE(rocsparse_double_complex);
|
; A013761: a(n) = 17^(3*n + 2).
; 289,1419857,6975757441,34271896307633,168377826559400929,827240261886336764177,4064231406647572522401601,19967568900859523802559065713,98100666009922840441972689847969,481968572106750915091411825223071697
mov $1,4913
pow $1,$0
mul $1,196
div $1,962752
mul $1,1419568
add $1,289
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xea6c, %rsi
nop
nop
add $14516, %rdi
mov (%rsi), %ecx
nop
nop
nop
sub %r13, %r13
lea addresses_A_ht+0x3b44, %rsi
lea addresses_A_ht+0x1e684, %rdi
clflush (%rsi)
nop
xor $30065, %r9
mov $75, %rcx
rep movsq
nop
nop
nop
nop
inc %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r8
push %rbp
push %rbx
push %rdx
// Load
mov $0x4c71610000000a94, %r15
nop
cmp %r8, %r8
mov (%r15), %ebp
nop
nop
sub %rbp, %rbp
// Store
lea addresses_D+0x1783c, %r13
xor $51829, %rbx
mov $0x5152535455565758, %r15
movq %r15, %xmm3
vmovntdq %ymm3, (%r13)
nop
nop
nop
nop
nop
sub %r13, %r13
// Store
lea addresses_WT+0x3aa4, %rdx
nop
nop
nop
nop
sub %r12, %r12
movw $0x5152, (%rdx)
nop
nop
nop
nop
xor $63459, %r13
// Store
lea addresses_WT+0x2a84, %r13
nop
inc %r12
movw $0x5152, (%r13)
nop
xor $62229, %r13
// Faulty Load
lea addresses_PSE+0x12284, %rbx
nop
nop
nop
nop
nop
cmp %r8, %r8
mov (%rbx), %r15d
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rdx
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 9}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
/*
MIT License
Copyright (c) 2021 Maciej Malecki
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.
*/
#import "_zero_page.asm"
#import "_segments.asm"
#importonce
.filenamespace c64lib
/*
* Busy waits until delay counter gets down to 0.
*
* In: delay - amount of delay cycles to wait;
* if handleDelay is called in raster IRQ then 1 delay cycle = 1/50 sec (PAL) or 1/60 sec (NTSC).
* Mod: A
*/
.pseudocommand wait delay {
lda delay
sta z_delayCounter
!:
lda z_delayCounter
bne !-
}
/*
* Decrements delay counter if not zero already. To be called periodically i.e. within scope of (raster) IRQ handler.
*
* Mod: A
*/
.macro handleDelay() {
txa
ldx z_delayCounter
beq !+
dex
stx z_delayCounter
!:
tax
}
.segment Code
dly_wait10: {
wait #10
rts
}
dly_handleDelay: {
handleDelay()
rts
}
|
; A289399: Total path length of the complete ternary tree of height n.
; 0,3,21,102,426,1641,6015,21324,73812,250959,841449,2790066,9167358,29893557,96855123,312088728,1000836264,3196219035,10169787837,32252755710,101988443730,321655860993,1012039172391,3177332285412,9955641160956,31137856397031,97226367933585,303117500028234,943667688767142,2933948632348749,9110682595188219
mov $2,$0
sub $0,1
add $0,$2
mov $3,3
pow $3,$2
mov $4,$3
mov $3,1
lpb $0,1
add $3,121
mul $4,$0
mov $0,0
add $4,$3
add $1,$4
lpe
mul $1,3
sub $1,363
div $1,12
mul $1,3
|
// Copyright 2020 the V8 project 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 "src/api/api.h"
#include "src/base/platform/semaphore.h"
#include "src/handles/handles-inl.h"
#include "src/handles/local-handles-inl.h"
#include "src/handles/persistent-handles.h"
#include "src/heap/heap.h"
#include "src/heap/local-heap-inl.h"
#include "src/heap/local-heap.h"
#include "src/heap/parked-scope.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/heap-utils.h"
namespace v8 {
namespace internal {
namespace {
#define DOUBLE_VALUE 28.123456789
#define STRING_VALUE "28.123456789"
#define ARRAY_VALUE \
{ '2', '8', '.', '1', '2', '3', '4', '5', '6', '7', '8', '9' }
// Adapted from cctest/test-api.cc, and
// test/cctest/heap/test-external-string-tracker.cc.
class TestOneByteResource : public v8::String::ExternalOneByteStringResource {
public:
explicit TestOneByteResource(const char* data)
: data_(data), length_(strlen(data)) {}
~TestOneByteResource() override { i::DeleteArray(data_); }
const char* data() const override { return data_; }
size_t length() const override { return length_; }
private:
const char* data_;
size_t length_;
};
// Adapted from cctest/test-api.cc.
class TestTwoByteResource : public v8::String::ExternalStringResource {
public:
explicit TestTwoByteResource(uint16_t* data) : data_(data), length_(0) {
while (data[length_]) ++length_;
}
~TestTwoByteResource() override { i::DeleteArray(data_); }
const uint16_t* data() const override { return data_; }
size_t length() const override { return length_; }
private:
uint16_t* data_;
size_t length_;
};
class ConcurrentStringThread final : public v8::base::Thread {
public:
ConcurrentStringThread(Isolate* isolate, Handle<String> str,
std::unique_ptr<PersistentHandles> ph,
base::Semaphore* sema_started,
std::vector<uint16_t> chars)
: v8::base::Thread(base::Thread::Options("ThreadWithLocalHeap")),
isolate_(isolate),
str_(str),
ph_(std::move(ph)),
sema_started_(sema_started),
length_(chars.size()),
chars_(chars) {}
void Run() override {
LocalIsolate local_isolate(isolate_, ThreadKind::kBackground);
local_isolate.heap()->AttachPersistentHandles(std::move(ph_));
UnparkedScope unparked_scope(local_isolate.heap());
sema_started_->Signal();
// Check the three operations we do from the StringRef concurrently: get the
// string, the nth character, and convert into a double.
CHECK_EQ(str_->length(kAcquireLoad), length_);
for (unsigned int i = 0; i < length_; ++i) {
CHECK_EQ(str_->Get(i, &local_isolate), chars_[i]);
}
CHECK_EQ(TryStringToDouble(&local_isolate, str_).value(), DOUBLE_VALUE);
}
private:
Isolate* isolate_;
Handle<String> str_;
std::unique_ptr<PersistentHandles> ph_;
base::Semaphore* sema_started_;
uint64_t length_;
std::vector<uint16_t> chars_;
};
// Inspect a one byte string, while the main thread externalizes it.
TEST(InspectOneByteExternalizing) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
auto factory = isolate->factory();
HandleScope handle_scope(isolate);
// Crate an internalized one-byte string.
const char* raw_string = STRING_VALUE;
Handle<String> one_byte_string = factory->InternalizeString(
factory->NewStringFromAsciiChecked(raw_string));
CHECK(one_byte_string->IsOneByteRepresentation());
CHECK(!one_byte_string->IsExternalString());
CHECK(one_byte_string->IsInternalizedString());
Handle<String> persistent_string = ph->NewHandle(one_byte_string);
std::vector<uint16_t> chars;
for (int i = 0; i < one_byte_string->length(); ++i) {
chars.push_back(one_byte_string->Get(i));
}
base::Semaphore sema_started(0);
std::unique_ptr<ConcurrentStringThread> thread(new ConcurrentStringThread(
isolate, persistent_string, std::move(ph), &sema_started, chars));
CHECK(thread->Start());
sema_started.Wait();
// Externalize it to a one-byte external string.
// We need to use StrDup in this case since the TestOneByteResource will get
// ownership of raw_string otherwise.
CHECK(one_byte_string->MakeExternal(
new TestOneByteResource(i::StrDup(raw_string))));
CHECK(one_byte_string->IsExternalOneByteString());
CHECK(one_byte_string->IsInternalizedString());
thread->Join();
}
// Inspect a one byte string, while the main thread externalizes it into a two
// bytes string.
TEST(InspectOneIntoTwoByteExternalizing) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
auto factory = isolate->factory();
HandleScope handle_scope(isolate);
// Crate an internalized one-byte string.
const char* raw_string = STRING_VALUE;
Handle<String> one_byte_string = factory->InternalizeString(
factory->NewStringFromAsciiChecked(raw_string));
CHECK(one_byte_string->IsOneByteRepresentation());
CHECK(!one_byte_string->IsExternalString());
CHECK(one_byte_string->IsInternalizedString());
Handle<String> persistent_string = ph->NewHandle(one_byte_string);
std::vector<uint16_t> chars;
for (int i = 0; i < one_byte_string->length(); ++i) {
chars.push_back(one_byte_string->Get(i));
}
base::Semaphore sema_started(0);
std::unique_ptr<ConcurrentStringThread> thread(new ConcurrentStringThread(
isolate, persistent_string, std::move(ph), &sema_started, chars));
CHECK(thread->Start());
sema_started.Wait();
// Externalize it to a two-bytes external string. AsciiToTwoByteString does
// the string duplication for us.
CHECK(one_byte_string->MakeExternal(
new TestTwoByteResource(AsciiToTwoByteString(raw_string))));
CHECK(one_byte_string->IsExternalTwoByteString());
CHECK(one_byte_string->IsInternalizedString());
thread->Join();
}
// Inspect a two byte string, while the main thread externalizes it.
TEST(InspectTwoByteExternalizing) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
std::unique_ptr<PersistentHandles> ph = isolate->NewPersistentHandles();
auto factory = isolate->factory();
HandleScope handle_scope(isolate);
// Crate an internalized two-byte string.
// TODO(solanes): Can we have only one raw string?
const char* raw_string = STRING_VALUE;
// TODO(solanes): Is this the best way to create a two byte string from chars?
const int kLength = 12;
const uint16_t two_byte_array[kLength] = ARRAY_VALUE;
Handle<String> two_bytes_string;
{
Handle<SeqTwoByteString> raw =
factory->NewRawTwoByteString(kLength).ToHandleChecked();
DisallowGarbageCollection no_gc;
CopyChars(raw->GetChars(no_gc), two_byte_array, kLength);
two_bytes_string = raw;
}
two_bytes_string = factory->InternalizeString(two_bytes_string);
CHECK(two_bytes_string->IsTwoByteRepresentation());
CHECK(!two_bytes_string->IsExternalString());
CHECK(two_bytes_string->IsInternalizedString());
Handle<String> persistent_string = ph->NewHandle(two_bytes_string);
std::vector<uint16_t> chars;
for (int i = 0; i < two_bytes_string->length(); ++i) {
chars.push_back(two_bytes_string->Get(i));
}
base::Semaphore sema_started(0);
std::unique_ptr<ConcurrentStringThread> thread(new ConcurrentStringThread(
isolate, persistent_string, std::move(ph), &sema_started, chars));
CHECK(thread->Start());
sema_started.Wait();
// Externalize it to a two-bytes external string.
CHECK(two_bytes_string->MakeExternal(
new TestTwoByteResource(AsciiToTwoByteString(raw_string))));
CHECK(two_bytes_string->IsExternalTwoByteString());
CHECK(two_bytes_string->IsInternalizedString());
thread->Join();
}
} // anonymous namespace
} // namespace internal
} // namespace v8
|
; void __FASTCALL__ sp1_Validate(struct sp1_Rect *r)
; 01.2008 aralbrec, Sprite Pack v3.0
; ts2068 hi-res version
XLIB sp1_Validate
XDEF ASMDISP_SP1_VALIDATE
LIB sp1_GetUpdateStruct_callee
XREF ASMDISP_SP1_GETUPDATESTRUCT_CALLEE, SP1V_DISPWIDTH
.sp1_Validate
ld d,(hl)
inc hl
ld e,(hl)
inc hl
ld b,(hl)
inc hl
ld c,(hl)
.asmentry
; Validate a rectangular area, ensuring the area is not drawn
; in next update. Make sure that none of the validated area
; is invalidated by further calls before the next update otherwise
; areas of the screen may become inactive (ie are never drawn).
;
; enter : d = row coord
; e = col coord
; b = width
; c = height
; uses : f, bc, de, hl
.SP1Validate
call sp1_GetUpdateStruct_callee + ASMDISP_SP1_GETUPDATESTRUCT_CALLEE ; hl = & struct sp1_update
ld de,9
.rowloop
push bc ; save b = width
push hl ; save update position
.colloop
bit 6,(hl) ; has this update char been removed from the display?
jr nz, skipit ; if so we must not validate it
res 7,(hl) ; validate update char
.skipit
add hl,de
djnz colloop
pop hl ; hl = & struct sp1_update same row leftmost column
ld bc,9*SP1V_DISPWIDTH
add hl,bc ; hl = & struct sp1_update next row leftmost column
pop bc
dec c ; c = height
jp nz, rowloop
ret
DEFC ASMDISP_SP1_VALIDATE = asmentry - sp1_Validate
|
; void *z80_otir_callee(void *src, uint16_t port)
SECTION code_z80
PUBLIC _z80_otir_callee
EXTERN asm_z80_otir
_z80_otir_callee:
pop af
pop hl
pop bc
push af
jp asm_z80_otir
|
; A157664: a(n) = 80000*n^2 + 800*n + 1.
; 80801,321601,722401,1283201,2004001,2884801,3925601,5126401,6487201,8008001,9688801,11529601,13530401,15691201,18012001,20492801,23133601,25934401,28895201,32016001,35296801,38737601,42338401,46099201,50020001,54100801,58341601,62742401,67303201,72024001,76904801,81945601,87146401,92507201,98028001,103708801,109549601,115550401,121711201,128032001,134512801,141153601,147954401,154915201,162036001,169316801,176757601,184358401,192119201,200040001,208120801,216361601,224762401,233323201,242044001
mov $2,$0
add $0,2
mov $1,1
mul $2,100
add $1,$2
mul $1,$0
sub $1,2
mul $1,800
add $1,80801
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rax
push %rbp
push %rbx
lea addresses_WC_ht+0xffe5, %rbp
nop
and $34518, %r14
movb (%rbp), %r11b
nop
nop
nop
nop
and $56375, %rax
lea addresses_normal_ht+0x1357d, %r9
and %r14, %r14
movw $0x6162, (%r9)
nop
nop
nop
and $4221, %r14
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r15
push %r9
push %rdx
push %rsi
// Store
lea addresses_D+0xbc1d, %r15
nop
nop
nop
nop
add %rsi, %rsi
mov $0x5152535455565758, %r9
movq %r9, %xmm1
vmovntdq %ymm1, (%r15)
nop
nop
nop
sub %r14, %r14
// Faulty Load
lea addresses_US+0x5dc5, %rdx
nop
nop
nop
nop
add $22318, %r12
movb (%rdx), %r14b
lea oracles, %rsi
and $0xff, %r14
shlq $12, %r14
mov (%rsi,%r14,1), %r14
pop %rsi
pop %rdx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': True, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 3, 'size': 2, 'same': False, 'NT': False}}
{'00': 16}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; gf_5vect_mad_avx(len, vec, vec_i, mul_array, src, dest);
;;;
%include "reg_sizes.asm"
%define PS 8
%ifidn __OUTPUT_FORMAT__, win64
%define arg0 rcx
%define arg0.w ecx
%define arg1 rdx
%define arg2 r8
%define arg3 r9
%define arg4 r12
%define arg5 r15
%define tmp r11
%define tmp2 r10
%define tmp3 r13
%define tmp4 r14
%define return rax
%define return.w eax
%define stack_size 16*10 + 5*8
%define arg(x) [rsp + stack_size + PS + PS*x]
%define func(x) proc_frame x
%macro FUNC_SAVE 0
sub rsp, stack_size
movdqa [rsp+16*0],xmm6
movdqa [rsp+16*1],xmm7
movdqa [rsp+16*2],xmm8
movdqa [rsp+16*3],xmm9
movdqa [rsp+16*4],xmm10
movdqa [rsp+16*5],xmm11
movdqa [rsp+16*6],xmm12
movdqa [rsp+16*7],xmm13
movdqa [rsp+16*8],xmm14
movdqa [rsp+16*9],xmm15
save_reg r12, 10*16 + 0*8
save_reg r13, 10*16 + 1*8
save_reg r14, 10*16 + 2*8
save_reg r15, 10*16 + 3*8
end_prolog
mov arg4, arg(4)
mov arg5, arg(5)
%endmacro
%macro FUNC_RESTORE 0
movdqa xmm6, [rsp+16*0]
movdqa xmm7, [rsp+16*1]
movdqa xmm8, [rsp+16*2]
movdqa xmm9, [rsp+16*3]
movdqa xmm10, [rsp+16*4]
movdqa xmm11, [rsp+16*5]
movdqa xmm12, [rsp+16*6]
movdqa xmm13, [rsp+16*7]
movdqa xmm14, [rsp+16*8]
movdqa xmm15, [rsp+16*9]
mov r12, [rsp + 10*16 + 0*8]
mov r13, [rsp + 10*16 + 1*8]
mov r14, [rsp + 10*16 + 2*8]
mov r15, [rsp + 10*16 + 3*8]
add rsp, stack_size
%endmacro
%elifidn __OUTPUT_FORMAT__, elf64
%define arg0 rdi
%define arg0.w edi
%define arg1 rsi
%define arg2 rdx
%define arg3 rcx
%define arg4 r8
%define arg5 r9
%define tmp r11
%define tmp2 r10
%define tmp3 r12
%define tmp4 r13
%define return rax
%define return.w eax
%define func(x) x:
%macro FUNC_SAVE 0
push r12
push r13
%endmacro
%macro FUNC_RESTORE 0
pop r13
pop r12
%endmacro
%endif
;;; gf_5vect_mad_avx(len, vec, vec_i, mul_array, src, dest)
%define len arg0
%define len.w arg0.w
%define vec arg1
%define vec_i arg2
%define mul_array arg3
%define src arg4
%define dest1 arg5
%define pos return
%define pos.w return.w
%define dest2 tmp4
%define dest3 mul_array
%define dest4 tmp2
%define dest5 vec_i
%ifndef EC_ALIGNED_ADDR
;;; Use Un-aligned load/store
%define XLDR vmovdqu
%define XSTR vmovdqu
%else
;;; Use Non-temporal load/stor
%ifdef NO_NT_LDST
%define XLDR vmovdqa
%define XSTR vmovdqa
%else
%define XLDR vmovntdqa
%define XSTR vmovntdq
%endif
%endif
default rel
[bits 64]
section .text
%define xmask0f xmm15
%define xgft5_hi xmm14
%define xgft4_lo xmm13
%define xgft4_hi xmm12
%define x0 xmm0
%define xtmpa xmm1
%define xtmph1 xmm2
%define xtmpl1 xmm3
%define xtmph2 xmm4
%define xtmpl2 xmm5
%define xtmph3 xmm6
%define xtmpl3 xmm7
%define xtmph5 xmm8
%define xtmpl5 xmm9
%define xd1 xmm10
%define xd2 xmm11
%define xd3 xtmpl1
%define xd4 xtmph1
%define xd5 xtmpl2
align 16
global gf_5vect_mad_avx:function
func(gf_5vect_mad_avx)
FUNC_SAVE
sub len, 16
jl .return_fail
xor pos, pos
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
mov tmp, vec
sal vec_i, 5 ;Multiply by 32
lea tmp3, [mul_array + vec_i]
sal tmp, 6 ;Multiply by 64
vmovdqu xgft5_hi, [tmp3+2*tmp+16] ; " Ex{00}, Ex{10}, ..., Ex{f0}
sal vec, 5 ;Multiply by 32
add tmp, vec
vmovdqu xgft4_hi, [tmp3+tmp+16] ; " Dx{00}, Dx{10}, Dx{20}, ... , Dx{f0}
vmovdqu xgft4_lo, [tmp3+tmp] ;Load array Dx{00}, Dx{01}, Dx{02}, ...
mov dest3, [dest1+2*PS] ; reuse mul_array
mov dest4, [dest1+3*PS]
mov dest5, [dest1+4*PS] ; reuse vec_i
mov dest2, [dest1+PS]
mov dest1, [dest1]
.loop16:
XLDR x0, [src+pos] ;Get next source vector
vmovdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0}
vmovdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ...
vmovdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0}
vmovdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ...
vmovdqu xtmph3, [tmp3+2*vec+16] ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0}
vmovdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
vmovdqu xtmpl5, [tmp3+4*vec] ;Load array Ex{00}, Ex{01}, ..., Ex{0f}
XLDR xd1, [dest1+pos] ;Get next dest vector
XLDR xd2, [dest2+pos] ;Get next dest vector
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
; dest1
vpshufb xtmph1, xtmph1, x0 ;Lookup mul table of high nibble
vpshufb xtmpl1, xtmpl1, xtmpa ;Lookup mul table of low nibble
vpxor xtmph1, xtmph1, xtmpl1 ;GF add high and low partials
vpxor xd1, xd1, xtmph1
XLDR xd3, [dest3+pos] ;Reuse xtmpl1, Get next dest vector
XLDR xd4, [dest4+pos] ;Reuse xtmph1, Get next dest vector
; dest2
vpshufb xtmph2, xtmph2, x0 ;Lookup mul table of high nibble
vpshufb xtmpl2, xtmpl2, xtmpa ;Lookup mul table of low nibble
vpxor xtmph2, xtmph2, xtmpl2 ;GF add high and low partials
vpxor xd2, xd2, xtmph2
XLDR xd5, [dest5+pos] ;Reuse xtmpl2. Get next dest vector
; dest3
vpshufb xtmph3, xtmph3, x0 ;Lookup mul table of high nibble
vpshufb xtmpl3, xtmpl3, xtmpa ;Lookup mul table of low nibble
vpxor xtmph3, xtmph3, xtmpl3 ;GF add high and low partials
vpxor xd3, xd3, xtmph3
; dest4
vpshufb xtmph2, xgft4_hi, x0 ;Lookup mul table of high nibble
vpshufb xtmpl3, xgft4_lo, xtmpa ;Lookup mul table of low nibble
vpxor xtmph2, xtmph2, xtmpl3 ;GF add high and low partials
vpxor xd4, xd4, xtmph2
; dest5
vpshufb xtmph5, xgft5_hi, x0 ;Lookup mul table of high nibble
vpshufb xtmpl5, xtmpl5, xtmpa ;Lookup mul table of low nibble
vpxor xtmph5, xtmph5, xtmpl5 ;GF add high and low partials
vpxor xd5, xd5, xtmph5
XSTR [dest1+pos], xd1 ;Store result into dest1
XSTR [dest2+pos], xd2 ;Store result into dest2
XSTR [dest3+pos], xd3 ;Store result into dest3
XSTR [dest4+pos], xd4 ;Store result into dest4
XSTR [dest5+pos], xd5 ;Store result into dest5
add pos, 16 ;Loop on 16 bytes at a time
cmp pos, len
jle .loop16
lea tmp, [len + 16]
cmp pos, tmp
je .return_pass
.lessthan16:
;; Tail len
;; Do one more overlap pass
mov tmp, len ;Overlapped offset length-16
XLDR x0, [src+tmp] ;Get next source vector
sub len, pos
vmovdqa xtmph1, [constip16] ;Load const of i + 16
vpinsrb xtmph5, len.w, 15
vpshufb xtmph5, xmask0f ;Broadcast len to all bytes
vpcmpgtb xtmph5, xtmph5, xtmph1
vmovdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0}
vmovdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ...
vmovdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0}
vmovdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ...
vmovdqu xtmph3, [tmp3+2*vec+16] ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0}
vmovdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
vmovdqu xtmpl5, [tmp3+4*vec] ;Load array Ex{00}, Ex{01}, ..., Ex{0f}
XLDR xd1, [dest1+tmp] ;Get next dest vector
XLDR xd2, [dest2+tmp] ;Get next dest vector
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
; dest1
vpshufb xtmph1, xtmph1, x0 ;Lookup mul table of high nibble
vpshufb xtmpl1, xtmpl1, xtmpa ;Lookup mul table of low nibble
vpxor xtmph1, xtmph1, xtmpl1 ;GF add high and low partials
vpand xtmph1, xtmph1, xtmph5
vpxor xd1, xd1, xtmph1
XLDR xd3, [dest3+tmp] ;Reuse xtmpl1, Get next dest vector
XLDR xd4, [dest4+tmp] ;Reuse xtmph1, Get next dest vector
; dest2
vpshufb xtmph2, xtmph2, x0 ;Lookup mul table of high nibble
vpshufb xtmpl2, xtmpl2, xtmpa ;Lookup mul table of low nibble
vpxor xtmph2, xtmph2, xtmpl2 ;GF add high and low partials
vpand xtmph2, xtmph2, xtmph5
vpxor xd2, xd2, xtmph2
XLDR xd5, [dest5+tmp] ;Reuse xtmpl2. Get next dest vector
; dest3
vpshufb xtmph3, xtmph3, x0 ;Lookup mul table of high nibble
vpshufb xtmpl3, xtmpl3, xtmpa ;Lookup mul table of low nibble
vpxor xtmph3, xtmph3, xtmpl3 ;GF add high and low partials
vpand xtmph3, xtmph3, xtmph5
vpxor xd3, xd3, xtmph3
; dest4
vpshufb xgft4_hi, xgft4_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft4_lo, xgft4_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft4_hi, xgft4_hi, xgft4_lo ;GF add high and low partials
vpand xgft4_hi, xgft4_hi, xtmph5
vpxor xd4, xd4, xgft4_hi
; dest5
vpshufb xgft5_hi, xgft5_hi, x0 ;Lookup mul table of high nibble
vpshufb xtmpl5, xtmpl5, xtmpa ;Lookup mul table of low nibble
vpxor xgft5_hi, xgft5_hi, xtmpl5 ;GF add high and low partials
vpand xgft5_hi, xgft5_hi, xtmph5
vpxor xd5, xd5, xgft5_hi
XSTR [dest1+tmp], xd1 ;Store result into dest1
XSTR [dest2+tmp], xd2 ;Store result into dest2
XSTR [dest3+tmp], xd3 ;Store result into dest3
XSTR [dest4+tmp], xd4 ;Store result into dest4
XSTR [dest5+tmp], xd5 ;Store result into dest5
.return_pass:
FUNC_RESTORE
mov return, 0
ret
.return_fail:
FUNC_RESTORE
mov return, 1
ret
endproc_frame
section .data
align 16
mask0f: dq 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
constip16:
dq 0xf8f9fafbfcfdfeff, 0xf0f1f2f3f4f5f6f7
;;; func core, ver, snum
slversion gf_5vect_mad_avx, 02, 01, 020d
|
; A186228: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) before g(j) when f(i)=g(j), where f and g are the triangular numbers and heptagonal numbers. Complement of A186227.
; 2,5,8,11,15,18,21,24,27,31,34,37,40,44,47,50,53,57,60,63,66,70,73,76,79,82,86,89,92,95,99,102,105,108,112,115,118,121,125,128,131,134,137,141,144,147,150,154,157,160,163,167,170,173,176,180,183,186,189,192,196,199,202,205,209,212,215,218,222,225,228,231,235,238,241,244,248,251,254,257,260,264,267,270,273,277,280,283,286,290,293,296,299,303,306,309
mul $0,2
add $0,1
max $1,$0
seq $1,3259 ; Complement of A003258.
sub $1,$0
sub $1,1
mov $0,$1
|
changeNetworkConfig::
call loadTextAsset
; Change SSID
ld hl, changeSSIDText
call displayText
xor a
call typeText
; Set harware SSID
ld bc, $100
ld de, myCmdBuffer
ld hl, typedTextBuffer
call copyStr
push bc
push de
; Change passwd
ld hl, networkPasswdText
call displayText
ld a, "*"
call typeText
; Set hardware passwd
pop de
pop bc
ld hl, typedTextBuffer
call copyStr
; Calculate data size
xor a
ld b, a
sub c
ld c, a
or a
jr nz, .skip
inc b
.skip:
; Connect to wifi
xor a
ld [cartIntTrigger], a
jp loadMap |
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/app_list/search/files/zero_state_file_provider.h"
#include <string>
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_pref_names.h"
#include "ash/public/cpp/app_list/app_list_features.h"
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/task/task_runner_util.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/search/files/file_result.h"
#include "chrome/browser/ui/app_list/search/ranking/util.h"
#include "chrome/browser/ui/app_list/search/search_result_ranker/recurrence_ranker.h"
#include "components/prefs/pref_service.h"
using file_manager::file_tasks::FileTasksObserver;
namespace app_list {
namespace {
// TODO(crbug.com/1258415): kFileChipSchema can be removed once the new
// launcher is launched.
constexpr char kFileChipSchema[] = "file_chip://";
constexpr char kZeroStateFileSchema[] = "zero_state_file://";
constexpr int kMaxLocalFiles = 10;
// Given the output of RecurrenceRanker::RankTopN, partition files by whether
// they exist or not on disk. Returns a pair of vectors: <valid, invalid>.
internal::ValidAndInvalidResults ValidateFiles(
const std::vector<std::pair<std::string, float>>& ranker_results) {
internal::ScoredResults valid;
internal::Results invalid;
for (const auto& path_score : ranker_results) {
// We use FilePath::FromUTF8Unsafe to decode the filepath string. As per its
// documentation, this is a safe use of the function because
// ZeroStateFileProvider is only used on ChromeOS, for which
// filepaths are UTF8.
const auto& path = base::FilePath::FromUTF8Unsafe(path_score.first);
if (base::PathExists(path))
valid.emplace_back(path, path_score.second);
else
invalid.emplace_back(path);
}
return {valid, invalid};
}
bool IsSuggestedContentEnabled(Profile* profile) {
return profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSuggestedContentEnabled);
}
// TODO(crbug.com/1258415): This exists to reroute results depending on which
// launcher is enabled, and should be removed after the new launcher launch.
ash::SearchResultDisplayType GetDisplayType() {
return ash::features::IsProductivityLauncherEnabled()
? ash::SearchResultDisplayType::kContinue
: ash::SearchResultDisplayType::kList;
}
} // namespace
ZeroStateFileProvider::ZeroStateFileProvider(Profile* profile)
: profile_(profile), thumbnail_loader_(profile) {
DCHECK(profile_);
task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(
{base::TaskPriority::BEST_EFFORT, base::MayBlock(),
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
auto* notifier =
file_manager::file_tasks::FileTasksNotifier::GetForProfile(profile_);
if (notifier) {
file_tasks_observer_.Observe(notifier);
RecurrenceRankerConfigProto config;
config.set_min_seconds_between_saves(120u);
config.set_condition_limit(1u);
config.set_condition_decay(0.5f);
config.set_target_limit(200);
config.set_target_decay(0.9f);
config.mutable_predictor()->mutable_default_predictor();
files_ranker_ = std::make_unique<RecurrenceRanker>(
"ZeroStateLocalFiles",
profile->GetPath().AppendASCII("zero_state_local_files.pb"), config,
chromeos::ProfileHelper::IsEphemeralUserProfile(profile));
}
}
ZeroStateFileProvider::~ZeroStateFileProvider() = default;
ash::AppListSearchResultType ZeroStateFileProvider::ResultType() {
return ash::AppListSearchResultType::kZeroStateFile;
}
void ZeroStateFileProvider::Start(const std::u16string& query) {
query_start_time_ = base::TimeTicks::Now();
ClearResultsSilently();
if (!files_ranker_ || !query.empty())
return;
base::PostTaskAndReplyWithResult(
task_runner_.get(), FROM_HERE,
base::BindOnce(&ValidateFiles, files_ranker_->RankTopN(kMaxLocalFiles)),
base::BindOnce(&ZeroStateFileProvider::SetSearchResults,
weak_factory_.GetWeakPtr()));
}
void ZeroStateFileProvider::SetSearchResults(
const internal::ValidAndInvalidResults& results) {
// Delete invalid results from the model.
for (const auto& path : results.second)
files_ranker_->RemoveTarget(path.value());
// Use valid results for search results.
SearchProvider::Results new_results;
for (const auto& filepath_score : results.first) {
double score = filepath_score.second;
auto result = std::make_unique<FileResult>(
kZeroStateFileSchema, filepath_score.first,
ash::AppListSearchResultType::kZeroStateFile, GetDisplayType(), score,
std::u16string(), FileResult::Type::kFile, profile_);
// TODO(crbug.com/1258415): Only generate thumbnails if the old launcher is
// enabled. We should implement new thumbnail logic for Continue results if
// necessary.
if (result->display_type() == ash::SearchResultDisplayType::kList) {
result->RequestThumbnail(&thumbnail_loader_);
}
new_results.push_back(std::move(result));
// Add suggestion chip file results
// TODO(crbug.com/1258415): This can be removed once the new launcher is
// launched.
if (app_list_features::IsSuggestedLocalFilesEnabled() &&
IsSuggestedContentEnabled(profile_)) {
new_results.emplace_back(std::make_unique<FileResult>(
kFileChipSchema, filepath_score.first,
ash::AppListSearchResultType::kFileChip,
ash::SearchResultDisplayType::kChip, filepath_score.second,
std::u16string(), FileResult::Type::kFile, profile_));
}
}
if (app_list_features::IsForceShowContinueSectionEnabled())
AppendFakeSearchResults(&new_results);
UMA_HISTOGRAM_TIMES("Apps.AppList.ZeroStateFileProvider.Latency",
base::TimeTicks::Now() - query_start_time_);
SwapResults(&new_results);
}
void ZeroStateFileProvider::OnFilesOpened(
const std::vector<FileOpenEvent>& file_opens) {
if (!files_ranker_)
return;
// The DriveQuickAccessProvider handles Drive files, so recording them here
// would be redundant. Filter them out by checking the file resides within the
// user's cryptohome.
const auto& profile_path = profile_->GetPath();
for (const auto& file_open : file_opens) {
if (profile_path.AppendRelativePath(file_open.path, nullptr))
files_ranker_->Record(file_open.path.value());
}
}
void ZeroStateFileProvider::AppendFakeSearchResults(Results* results) {
constexpr int kTotalFakeFiles = 3;
for (int i = 0; i < kTotalFakeFiles; ++i) {
results->emplace_back(std::make_unique<FileResult>(
kFileChipSchema,
base::FilePath(FILE_PATH_LITERAL(
base::StrCat({"Fake-file-", base::NumberToString(i), ".png"}))),
ash::AppListSearchResultType::kFileChip,
ash::SearchResultDisplayType::kContinue, 0.1f, std::u16string(),
FileResult::Type::kFile, profile_));
}
}
} // namespace app_list
|
// Copyright (c) 2009-2012 The Darkcoin developers
// Copyright (c) 2017-2018 The Zumy developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bignum.h"
#include "sync.h"
#include "net.h"
#include "key.h"
#include "util.h"
#include "script.h"
#include "base58.h"
#include "protocol.h"
#include "spork.h"
#include "main.h"
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;
class CSporkMessage;
class CSporkManager;
CSporkManager sporkManager;
std::map<uint256, CSporkMessage> mapSporks;
std::map<int, CSporkMessage> mapSporksActive;
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return; //disable all darksend/masternode related functionality
if (strCommand == "spork")
{
//LogPrintf("ProcessSpork::spork\n");
CDataStream vMsg(vRecv);
CSporkMessage spork;
vRecv >> spork;
if(pindexBest == NULL) return;
uint256 hash = spork.GetHash();
if(mapSporksActive.count(spork.nSporkID)) {
if(mapSporksActive[spork.nSporkID].nTimeSigned >= spork.nTimeSigned){
if(fDebug) LogPrintf("spork - seen %s block %d \n", hash.ToString().c_str(), pindexBest->nHeight);
return;
} else {
if(fDebug) LogPrintf("spork - got updated spork %s block %d \n", hash.ToString().c_str(), pindexBest->nHeight);
}
}
LogPrintf("spork - new %s ID %d Time %d bestHeight %d\n", hash.ToString().c_str(), spork.nSporkID, spork.nValue, pindexBest->nHeight);
if(!sporkManager.CheckSignature(spork)){
LogPrintf("spork - invalid signature\n");
Misbehaving(pfrom->GetId(), 100);
return;
}
mapSporks[hash] = spork;
mapSporksActive[spork.nSporkID] = spork;
sporkManager.Relay(spork);
//does a task if needed
ExecuteSpork(spork.nSporkID, spork.nValue);
}
if (strCommand == "getsporks")
{
std::map<int, CSporkMessage>::iterator it = mapSporksActive.begin();
while(it != mapSporksActive.end()) {
pfrom->PushMessage("spork", it->second);
it++;
}
}
}
// grab the spork, otherwise say it's off
bool IsSporkActive(int nSporkID)
{
int64_t r = -1;
if(mapSporksActive.count(nSporkID)){
r = mapSporksActive[nSporkID].nValue;
} else {
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
if(nSporkID == SPORK_6_REPLAY_BLOCKS) r = SPORK_6_REPLAY_BLOCKS_DEFAULT;
if(nSporkID == SPORK_7_MASTERNODE_SCANNING) r = SPORK_7_MASTERNODE_SCANNING;
if(nSporkID == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) r = SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_10_MASTERNODE_PAY_UPDATED_NODES) r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
if(nSporkID == SPORK_11_RESET_BUDGET) r = SPORK_11_RESET_BUDGET_DEFAULT;
if(nSporkID == SPORK_12_RECONSIDER_BLOCKS) r = SPORK_12_RECONSIDER_BLOCKS_DEFAULT;
if(nSporkID == SPORK_13_ENABLE_SUPERBLOCKS) r = SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT;
if(r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
}
if(r == -1) r = 4070908800; //return 2099-1-1 by default
return r < GetTime();
}
// grab the value of the spork on the network, or the default
int64_t GetSporkValue(int nSporkID)
{
int64_t r = -1;
if(mapSporksActive.count(nSporkID)){
r = mapSporksActive[nSporkID].nValue;
} else {
if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
if(nSporkID == SPORK_6_REPLAY_BLOCKS) r = SPORK_6_REPLAY_BLOCKS_DEFAULT;
if(nSporkID == SPORK_7_MASTERNODE_SCANNING) r = SPORK_7_MASTERNODE_SCANNING;
if(nSporkID == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) r = SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_10_MASTERNODE_PAY_UPDATED_NODES) r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
if(nSporkID == SPORK_11_RESET_BUDGET) r = SPORK_11_RESET_BUDGET_DEFAULT;
if(nSporkID == SPORK_12_RECONSIDER_BLOCKS) r = SPORK_12_RECONSIDER_BLOCKS_DEFAULT;
if(nSporkID == SPORK_13_ENABLE_SUPERBLOCKS) r = SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT;
if(r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
}
return r;
}
void ExecuteSpork(int nSporkID, int nValue)
{
}
/*void ReprocessBlocks(int nBlocks)
{
std::map<uint256, int64_t>::iterator it = mapRejectedBlocks.begin();
while(it != mapRejectedBlocks.end()){
//use a window twice as large as is usual for the nBlocks we want to reset
if((*it).second > GetTime() - (nBlocks*60*5)) {
BlockMap::iterator mi = mapBlockIndex.find((*it).first);
if (mi != mapBlockIndex.end() && (*mi).second) {
LOCK(cs_main);
CBlockIndex* pindex = (*mi).second;
LogPrintf("ReprocessBlocks - %s\n", (*it).first.ToString());
CValidationState state;
ReconsiderBlock(state, pindex);
}
}
++it;
}
CValidationState state;
{
LOCK(cs_main);
DisconnectBlocksAndReprocess(nBlocks);
}
if (state.IsValid()) {
ActivateBestChain(state);
}
}*/
bool CSporkManager::CheckSignature(CSporkMessage& spork)
{
//note: need to investigate why this is failing
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
std::string strPubKey = strMainPubKey;
CPubKey pubkey(ParseHex(strPubKey));
std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(pubkey, spork.vchSig, strMessage, errorMessage)){
return false;
}
return true;
}
bool CSporkManager::Sign(CSporkMessage& spork)
{
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
CKey key2;
CPubKey pubkey2;
std::string errorMessage = "";
if(!darkSendSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2))
{
LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
return false;
}
if(!darkSendSigner.SignMessage(strMessage, errorMessage, spork.vchSig, key2)) {
LogPrintf("CMasternodePayments::Sign - Sign message failed");
return false;
}
if(!darkSendSigner.VerifyMessage(pubkey2, spork.vchSig, strMessage, errorMessage)) {
LogPrintf("CMasternodePayments::Sign - Verify message failed");
return false;
}
return true;
}
bool CSporkManager::UpdateSpork(int nSporkID, int64_t nValue)
{
CSporkMessage msg;
msg.nSporkID = nSporkID;
msg.nValue = nValue;
msg.nTimeSigned = GetTime();
if(Sign(msg)){
Relay(msg);
mapSporks[msg.GetHash()] = msg;
mapSporksActive[nSporkID] = msg;
return true;
}
return false;
}
void CSporkManager::Relay(CSporkMessage& msg)
{
CInv inv(MSG_SPORK, msg.GetHash());
RelayInventory(inv);
}
bool CSporkManager::SetPrivKey(std::string strPrivKey)
{
CSporkMessage msg;
// Test signing successful, proceed
strMasterPrivKey = strPrivKey;
Sign(msg);
if(CheckSignature(msg)){
LogPrintf("CSporkManager::SetPrivKey - Successfully initialized as spork signer\n");
return true;
} else {
return false;
}
}
int CSporkManager::GetSporkIDByName(std::string strName)
{
if(strName == "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT") return SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT;
if(strName == "SPORK_2_INSTANTX") return SPORK_2_INSTANTX;
if(strName == "SPORK_3_INSTANTX_BLOCK_FILTERING") return SPORK_3_INSTANTX_BLOCK_FILTERING;
if(strName == "SPORK_5_MAX_VALUE") return SPORK_5_MAX_VALUE;
if(strName == "SPORK_6_REPLAY_BLOCKS") return SPORK_6_REPLAY_BLOCKS;
if(strName == "SPORK_7_MASTERNODE_SCANNING") return SPORK_7_MASTERNODE_SCANNING;
if(strName == "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT") return SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT;
if(strName == "SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT") return SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT;
if(strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
if(strName == "SPORK_11_RESET_BUDGET") return SPORK_11_RESET_BUDGET;
if(strName == "SPORK_12_RECONSIDER_BLOCKS") return SPORK_12_RECONSIDER_BLOCKS;
if(strName == "SPORK_13_ENABLE_SUPERBLOCKS") return SPORK_13_ENABLE_SUPERBLOCKS;
return -1;
}
std::string CSporkManager::GetSporkNameByID(int id)
{
if(id == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) return "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT";
if(id == SPORK_2_INSTANTX) return "SPORK_2_INSTANTX";
if(id == SPORK_3_INSTANTX_BLOCK_FILTERING) return "SPORK_3_INSTANTX_BLOCK_FILTERING";
if(id == SPORK_5_MAX_VALUE) return "SPORK_5_MAX_VALUE";
if(id == SPORK_6_REPLAY_BLOCKS) return "SPORK_6_REPLAY_BLOCKS";
if(id == SPORK_7_MASTERNODE_SCANNING) return "SPORK_7_MASTERNODE_SCANNING";
if(id == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) return "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT";
if(id == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) return "SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT";
if(id == SPORK_10_MASTERNODE_PAY_UPDATED_NODES) return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
if(id == SPORK_11_RESET_BUDGET) return "SPORK_11_RESET_BUDGET";
if(id == SPORK_12_RECONSIDER_BLOCKS) return "SPORK_12_RECONSIDER_BLOCKS";
if(id == SPORK_13_ENABLE_SUPERBLOCKS) return "SPORK_13_ENABLE_SUPERBLOCKS";
return "Unknown";
}
|
; A164015: 5 times centered pentagonal numbers: 5*(5*n^2 + 5*n + 2)/2.
; 5,30,80,155,255,380,530,705,905,1130,1380,1655,1955,2280,2630,3005,3405,3830,4280,4755,5255,5780,6330,6905,7505,8130,8780,9455,10155,10880,11630,12405,13205,14030,14880,15755,16655,17580,18530,19505,20505,21530,22580,23655,24755,25880,27030,28205,29405,30630,31880,33155,34455,35780,37130,38505,39905,41330,42780,44255,45755,47280,48830,50405,52005,53630,55280,56955,58655,60380,62130,63905,65705,67530,69380,71255,73155,75080,77030,79005,81005,83030,85080,87155,89255,91380,93530,95705,97905,100130,102380,104655,106955,109280,111630,114005,116405,118830,121280,123755,126255,128780,131330,133905,136505,139130,141780,144455,147155,149880,152630,155405,158205,161030,163880,166755,169655,172580,175530,178505,181505,184530,187580,190655,193755,196880,200030,203205,206405,209630,212880,216155,219455,222780,226130,229505,232905,236330,239780,243255,246755,250280,253830,257405,261005,264630,268280,271955,275655,279380,283130,286905,290705,294530,298380,302255,306155,310080,314030,318005,322005,326030,330080,334155,338255,342380,346530,350705,354905,359130,363380,367655,371955,376280,380630,385005,389405,393830,398280,402755,407255,411780,416330,420905,425505,430130,434780,439455,444155,448880,453630,458405,463205,468030,472880,477755,482655,487580,492530,497505,502505,507530,512580,517655,522755,527880,533030,538205,543405,548630,553880,559155,564455,569780,575130,580505,585905,591330,596780,602255,607755,613280,618830,624405,630005,635630,641280,646955,652655,658380,664130,669905,675705,681530,687380,693255,699155,705080,711030,717005,723005,729030,735080,741155,747255,753380,759530,765705,771905,778130
sub $1,$0
bin $1,2
mul $1,25
add $1,5
|
<%
from pwnlib.shellcraft import i386
from pwnlib.context import context as ctx # Ugly hack, mako will not let it be called context
%>
<%page args="value"/>
<%docstring>
Thin wrapper around :func:`pwnlib.shellcraft.i386.push`, which sets
`context.os` to `'freebsd'` before calling.
Example:
>>> print(pwnlib.shellcraft.i386.freebsd.push('SYS_execve').rstrip())
/* push 'SYS_execve' */
push 0x3b
</%docstring>
% with ctx.local(os='freebsd'):
${i386.push(value)}
% endwith
|
/*******************************************************************\
Module: Coverage Instrumentation
Author: Daniel Kroening
\*******************************************************************/
/// \file
/// Coverage Instrumentation for Conditions
#include "cover_instrument.h"
#include <langapi/language_util.h>
#include "cover_util.h"
#include "cover_basic_blocks.h"
void cover_condition_instrumentert::instrument(
const irep_idt &function_id,
goto_programt &goto_program,
goto_programt::targett &i_it,
const cover_blocks_baset &,
const assertion_factoryt &make_assertion) const
{
if(is_non_cover_assertion(i_it))
i_it->turn_into_skip();
// Conditions are all atomic predicates in the programs.
if(!i_it->source_location.is_built_in())
{
const std::set<exprt> conditions = collect_conditions(i_it);
const source_locationt source_location = i_it->source_location;
for(const auto &c : conditions)
{
const std::string c_string = from_expr(ns, function_id, c);
const std::string comment_t = "condition '" + c_string + "' true";
goto_program.insert_before_swap(i_it);
*i_it = make_assertion(c, source_location);
initialize_source_location(i_it, comment_t, function_id);
const std::string comment_f = "condition '" + c_string + "' false";
goto_program.insert_before_swap(i_it);
*i_it = make_assertion(not_exprt(c), source_location);
initialize_source_location(i_it, comment_f, function_id);
}
for(std::size_t i = 0; i < conditions.size() * 2; i++)
i_it++;
}
}
|
/*
welcome.cc
----------
*/
#ifndef __amigaos4__
// Mac OS X
#ifdef __APPLE__
#include <Carbon/Carbon.h>
#endif
// Mac OS
#ifndef __MACWINDOWS__
#include <MacWindows.h>
#endif
// missing-macos
#ifdef MAC_OS_X_VERSION_10_7
#ifndef MISSING_QUICKDRAW_H
#include "missing/Quickdraw.h"
#endif
#ifndef MISSING_QUICKDRAWTEXT_H
#include "missing/QuickdrawText.h"
#endif
#endif
// mac-sys-utils
#include "mac_sys/gestalt.hh"
#include "mac_sys/trap_available.hh"
// mac-qd-utils
#include "mac_qd/get_portRect.hh"
#include "mac_qd/main_display_bounds.hh"
#include "mac_qd/plot_icon_id.hh"
#if TARGET_API_MAC_CARBON
#define SystemTask() /**/
#endif
#ifdef __MC68K__
#define AT( addr ) : addr
#else
#define AT( addr )
#endif
short MBarHeight AT( 0x0BAA ); // only used in v68k for AMS
using mac::qd::get_portRect;
using mac::qd::main_display_bounds;
static inline
bool in_v68k()
{
return mac::sys::gestalt_defined( 'v68k' );
}
static inline
bool has_color_quickdraw()
{
return mac::sys::gestalt( 'qd ' ) > 0;
}
#endif
#ifdef __amigaos4__
#include "libMacEmu.h"
#include "missing.h"
#define rDocProc NULL
#define dBoxProc NULL
static inline bool in_v68k()
{
return true;
}
static inline bool has_color_quickdraw()
{
return true;
}
typedef signed int SInt32;
int MBarHeight = 0;
#endif
static
WindowRef new_window( const Rect* bounds,
const unsigned char* title,
Boolean vis,
short proc,
WindowRef behind,
Boolean closable,
SInt32 ref )
{
static bool has_color = has_color_quickdraw();
if ( has_color )
{
return NewCWindow( 0, bounds, title, vis, proc, behind, closable, ref );
}
else
{
return NewWindow( 0, bounds, (const char *) title, vis, proc, behind, closable, ref );
}
}
static
WindowRef create_window()
{
Rect bounds = main_display_bounds();
const short width = 428;
const short height = 112;
bounds.left = (bounds.right - width) / 2;
bounds.right = bounds.left + width;
bounds.top = (bounds.bottom - height) / 3 - 4;
bounds.bottom = bounds.top + height;
return new_window( &bounds, (const unsigned char*) "", true, dBoxProc, (WindowRef) -1, false, 0 );
}
#define WELCOME( name ) "Welcome to " name "."
static
void draw_window( WindowRef window )
{
const Rect& portRect = get_portRect( window );
SetPortWindowPort( window );
EraseRect( &portRect );
#ifdef __amigaos4__
SInt32 micn = 0;
#else
SInt32 micn = mac::sys::gestalt( 'micn' );
#endif
const short icon_h = 16;
const short icon_v = 16;
const Rect icon_rect = { icon_v, icon_h, icon_v + 32, icon_h + 32 };
#ifndef __amigaos4__
mac::qd::plot_icon_id( icon_rect, micn );
#endif
const short text_h = 100;
const short text_v = 36;
MoveTo( text_h, text_v );
DrawString( "Welcome to Advanced Mac Substitute." );
}
#ifndef __amigaos4__
static inline
bool has_WaitNextEvent()
{
enum { _WaitNextEvent = 0xA860 };
return ! TARGET_CPU_68K || mac::sys::trap_available( _WaitNextEvent );
}
static inline
Boolean WaitNextEvent( EventRecord& event )
{
return WaitNextEvent( everyEvent, &event, 0x7FFFFFFF, NULL );
}
#else
#define has_WaitNextEvent() false
#define WaitNextEvent(ev ) false
#endif
static inline
Boolean GetNextEvent( EventRecord& event )
{
SystemTask();
return GetNextEvent( everyEvent, &event );
}
int main()
{
Boolean quitting = false;
#ifdef __amigaos4__
if (OpenMacEMU() == false) return -30;
#endif
#if ! TARGET_API_MAC_CARBON
if ( TARGET_CPU_68K && in_v68k() )
{
MBarHeight = 0;
}
InitGraf( &qd.thePort );
InitFonts();
InitWindows();
InitMenus();
InitCursor();
if ( TARGET_CPU_68K && in_v68k() )
{
HideCursor();
}
#endif
WindowRef main_window = create_window();
const bool has_WNE = has_WaitNextEvent();
draw_window( main_window );
while ( ! quitting )
{
EventRecord event;
if ( has_WNE ? WaitNextEvent( event ) : GetNextEvent( event ) )
{
WindowRef window;
switch ( event.what )
{
case mouseDown:
case keyDown:
quitting = true;
break;
case updateEvt:
window = (WindowRef) event.message;
BeginUpdate( window );
draw_window( window );
EndUpdate ( window );
break;
default:
break;
}
}
}
CloseMacEMU();
return 0;
}
|
//
// bind_noexcept_test.cpp
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/bind/bind.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
using namespace boost::placeholders;
#if defined(BOOST_NO_CXX11_NOEXCEPT)
int main()
{
}
#else
//
long f_0() noexcept
{
return 17041L;
}
long f_1(long a) noexcept
{
return a;
}
long f_2(long a, long b) noexcept
{
return a + 10 * b;
}
long f_3(long a, long b, long c) noexcept
{
return a + 10 * b + 100 * c;
}
long f_4(long a, long b, long c, long d) noexcept
{
return a + 10 * b + 100 * c + 1000 * d;
}
long f_5(long a, long b, long c, long d, long e) noexcept
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
}
long f_6(long a, long b, long c, long d, long e, long f) noexcept
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
}
long f_7(long a, long b, long c, long d, long e, long f, long g) noexcept
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
}
long f_8(long a, long b, long c, long d, long e, long f, long g, long h) noexcept
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
}
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) noexcept
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
}
void function_test()
{
int const i = 1;
BOOST_TEST( boost::bind(f_0)(i) == 17041L );
BOOST_TEST( boost::bind(f_1, _1)(i) == 1L );
BOOST_TEST( boost::bind(f_2, _1, 2)(i) == 21L );
BOOST_TEST( boost::bind(f_3, _1, 2, 3)(i) == 321L );
BOOST_TEST( boost::bind(f_4, _1, 2, 3, 4)(i) == 4321L );
BOOST_TEST( boost::bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
BOOST_TEST( boost::bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
BOOST_TEST( boost::bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
BOOST_TEST( boost::bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
BOOST_TEST( boost::bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
}
int main()
{
function_test();
return boost::report_errors();
}
#endif
|
; A037537: Base-4 digits are, in order, the first n terms of the periodic sequence with initial period 1,2,1.
; 1,6,25,101,406,1625,6501,26006,104025,416101,1664406,6657625,26630501,106522006,426088025,1704352101,6817408406,27269633625,109078534501,436314138006,1745256552025,6981026208101,27924104832406
mov $1,4
pow $1,$0
mul $1,100
div $1,63
mov $0,$1
|
; move ids
; indexes for:
; - Moves (see data/moves/moves.asm)
; - MoveNames (see data/moves/names.asm)
; - MoveDescriptions (see data/moves/descriptions.asm)
; - BattleAnimations (see data/moves/animations.asm)
const_def
const NO_MOVE ; 00
const POUND ; 01
const KARATE_CHOP ; 02
const DOUBLESLAP ; 03
const COMET_PUNCH ; 04
const MEGA_PUNCH ; 05
const PAY_DAY ; 06
const FIRE_PUNCH ; 07
const ICE_PUNCH ; 08
const THUNDERPUNCH ; 09
const SCRATCH ; 0a
const VICEGRIP ; 0b
const GUILLOTINE ; 0c
const RAZOR_WIND ; 0d
const SWORDS_DANCE ; 0e
const CUT ; 0f
const GUST ; 10
const WING_ATTACK ; 11
const WHIRLWIND ; 12
const FLY ; 13
const BIND ; 14
const SLAM ; 15
const VINE_WHIP ; 16
const STOMP ; 17
const DOUBLE_KICK ; 18
const MEGA_KICK ; 19
const JUMP_KICK ; 1a
const ROLLING_KICK ; 1b
const SAND_ATTACK ; 1c
const HEADBUTT ; 1d
const HORN_ATTACK ; 1e
const FURY_ATTACK ; 1f
const HORN_DRILL ; 20
const TACKLE ; 21
const BODY_SLAM ; 22
const WRAP ; 23
const TAKE_DOWN ; 24
const THRASH ; 25
const DOUBLE_EDGE ; 26
const TAIL_WHIP ; 27
const POISON_STING ; 28
const TWINEEDLE ; 29
const PIN_MISSILE ; 2a
const LEER ; 2b
const BITE ; 2c
const GROWL ; 2d
const ROAR ; 2e
const SING ; 2f
const SUPERSONIC ; 30
const SONICBOOM ; 31
const DISABLE ; 32
const ACID ; 33
const EMBER ; 34
const FLAMETHROWER ; 35
const MIST ; 36
const WATER_GUN ; 37
const HYDRO_PUMP ; 38
const SURF ; 39
const ICE_BEAM ; 3a
const BLIZZARD ; 3b
const PSYBEAM ; 3c
const BUBBLEBEAM ; 3d
const AURORA_BEAM ; 3e
const HYPER_BEAM ; 3f
const PECK ; 40
const DRILL_PECK ; 41
const SUBMISSION ; 42
const LOW_KICK ; 43
const COUNTER ; 44
const SEISMIC_TOSS ; 45
const STRENGTH ; 46
const ABSORB ; 47
const MEGA_DRAIN ; 48
const LEECH_SEED ; 49
const GROWTH ; 4a
const RAZOR_LEAF ; 4b
const SOLARBEAM ; 4c
const POISONPOWDER ; 4d
const STUN_SPORE ; 4e
const SLEEP_POWDER ; 4f
const PETAL_DANCE ; 50
const STRING_SHOT ; 51
const DRAGON_RAGE ; 52
const FIRE_SPIN ; 53
const THUNDERSHOCK ; 54
const THUNDERBOLT ; 55
const THUNDER_WAVE ; 56
const THUNDER ; 57
const ROCK_THROW ; 58
const EARTHQUAKE ; 59
const FISSURE ; 5a
const DIG ; 5b
const TOXIC ; 5c
const CONFUSION ; 5d
const PSYCHIC_M ; 5e
const HYPNOSIS ; 5f
const MEDITATE ; 60
const AGILITY ; 61
const QUICK_ATTACK ; 62
const RAGE ; 63
const TELEPORT ; 64
const NIGHT_SHADE ; 65
const MIMIC ; 66
const SCREECH ; 67
const DOUBLE_TEAM ; 68
const RECOVER ; 69
const HARDEN ; 6a
const MINIMIZE ; 6b
const SMOKESCREEN ; 6c
const CONFUSE_RAY ; 6d
const WITHDRAW ; 6e
const DEFENSE_CURL ; 6f
const BARRIER ; 70
const LIGHT_SCREEN ; 71
const HAZE ; 72
const REFLECT ; 73
const FOCUS_ENERGY ; 74
const BIDE ; 75
const METRONOME ; 76
const MIRROR_MOVE ; 77
const SELFDESTRUCT ; 78
const EGG_BOMB ; 79
const LICK ; 7a
const SMOG ; 7b
const SLUDGE ; 7c
const BONE_CLUB ; 7d
const FIRE_BLAST ; 7e
const WATERFALL ; 7f
const CLAMP ; 80
const SWIFT ; 81
const SKULL_BASH ; 82
const SPIKE_CANNON ; 83
const CONSTRICT ; 84
const AMNESIA ; 85
const KINESIS ; 86
const SOFTBOILED ; 87
const HI_JUMP_KICK ; 88
const GLARE ; 89
const DREAM_EATER ; 8a
const POISON_GAS ; 8b
const BARRAGE ; 8c
const LEECH_LIFE ; 8d
const LOVELY_KISS ; 8e
const SKY_ATTACK ; 8f
const TRANSFORM ; 90
const BUBBLE ; 91
const DIZZY_PUNCH ; 92
const SPORE ; 93
const FLASH ; 94
const PSYWAVE ; 95
const SPLASH ; 96
const ACID_ARMOR ; 97
const CRABHAMMER ; 98
const EXPLOSION ; 99
const FURY_SWIPES ; 9a
const BONEMERANG ; 9b
const REST ; 9c
const ROCK_SLIDE ; 9d
const HYPER_FANG ; 9e
const SHARPEN ; 9f
const CONVERSION ; a0
const TRI_ATTACK ; a1
const SUPER_FANG ; a2
const SLASH ; a3
const SUBSTITUTE ; a4
const STRUGGLE ; a5
const SKETCH ; a6
const TRIPLE_KICK ; a7
const THIEF ; a8
const SPIDER_WEB ; a9
const MIND_READER ; aa
const NIGHTMARE ; ab
const FLAME_WHEEL ; ac
const SNORE ; ad
const CURSE ; ae
const FLAIL ; af
const CONVERSION2 ; b0
const AEROBLAST ; b1
const COTTON_SPORE ; b2
const REVERSAL ; b3
const SPITE ; b4
const POWDER_SNOW ; b5
const PROTECT ; b6
const MACH_PUNCH ; b7
const SCARY_FACE ; b8
const FAINT_ATTACK ; b9
const SWEET_KISS ; ba
const BELLY_DRUM ; bb
const SLUDGE_BOMB ; bc
const MUD_SLAP ; bd
const OCTAZOOKA ; be
const SPIKES ; bf
const ZAP_CANNON ; c0
const FORESIGHT ; c1
const DESTINY_BOND ; c2
const PERISH_SONG ; c3
const ICY_WIND ; c4
const DETECT ; c5
const BONE_RUSH ; c6
const LOCK_ON ; c7
const OUTRAGE ; c8
const SANDSTORM ; c9
const GIGA_DRAIN ; ca
const ENDURE ; cb
const CHARM ; cc
const ROLLOUT ; cd
const FALSE_SWIPE ; ce
const SWAGGER ; cf
const MILK_DRINK ; d0
const SPARK ; d1
const FURY_CUTTER ; d2
const STEEL_WING ; d3
const MEAN_LOOK ; d4
const ATTRACT ; d5
const SLEEP_TALK ; d6
const HEAL_BELL ; d7
const RETURN ; d8
const PRESENT ; d9
const FRUSTRATION ; da
const SAFEGUARD ; db
const PAIN_SPLIT ; dc
const SACRED_FIRE ; dd
const MAGNITUDE ; de
const DYNAMICPUNCH ; df
const MEGAHORN ; e0
const DRAGONBREATH ; e1
const BATON_PASS ; e2
const ENCORE ; e3
const PURSUIT ; e4
const RAPID_SPIN ; e5
const SWEET_SCENT ; e6
const IRON_TAIL ; e7
const METAL_CLAW ; e8
const VITAL_THROW ; e9
const MORNING_SUN ; ea
const SYNTHESIS ; eb
const MOONLIGHT ; ec
const HIDDEN_POWER ; ed
const CROSS_CHOP ; ee
const TWISTER ; ef
const RAIN_DANCE ; f0
const SUNNY_DAY ; f1
const CRUNCH ; f2
const MIRROR_COAT ; f3
const PSYCH_UP ; f4
const EXTREMESPEED ; f5
const ANCIENTPOWER ; f6
const SHADOW_BALL ; f7
const FUTURE_SIGHT ; f8
const ROCK_SMASH ; f9
const WHIRLPOOL ; fa
const BEAT_UP ; fb
NUM_ATTACKS EQU const_value + -1
const MOVE_OR_ANIM_FC ; fc
const MOVE_OR_ANIM_FD ; fd
const MOVE_OR_ANIM_FE ; fe
; Battle animations use the same constants as the moves up to this point
const ANIM_SWEET_SCENT_2 ; ff
const ANIM_THROW_POKE_BALL ; 100
const ANIM_SEND_OUT_MON ; 101
const ANIM_RETURN_MON ; 102
const ANIM_CONFUSED ; 103
const ANIM_SLP ; 104
const ANIM_BRN ; 105
const ANIM_PSN ; 106
const ANIM_SAP ; 107
const ANIM_FRZ ; 108
const ANIM_PAR ; 109
const ANIM_IN_LOVE ; 10a
const ANIM_IN_SANDSTORM ; 10b
const ANIM_IN_NIGHTMARE ; 10c
const ANIM_IN_WHIRLPOOL ; 10d
; battle anims
const ANIM_MISS ; 10e
const ANIM_ENEMY_DAMAGE ; 10f
const ANIM_ENEMY_STAT_DOWN ; 110
const ANIM_PLAYER_STAT_DOWN ; 111
const ANIM_PLAYER_DAMAGE ; 112
const ANIM_WOBBLE ; 113
const ANIM_SHAKE ; 114
const ANIM_HIT_CONFUSION ; 115
; wNumHits uses offsets from ANIM_MISS
const_def
const BATTLEANIM_NONE
const BATTLEANIM_ENEMY_DAMAGE
const BATTLEANIM_ENEMY_STAT_DOWN
const BATTLEANIM_PLAYER_STAT_DOWN
const BATTLEANIM_PLAYER_DAMAGE
const BATTLEANIM_WOBBLE
const BATTLEANIM_SHAKE
const BATTLEANIM_HIT_CONFUSION
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r15
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x73b3, %r11
nop
nop
nop
nop
and %r10, %r10
movb $0x61, (%r11)
nop
nop
nop
nop
nop
add $50784, %r8
lea addresses_normal_ht+0x1acbf, %r14
nop
nop
nop
nop
nop
inc %r9
movw $0x6162, (%r14)
nop
nop
nop
nop
lfence
lea addresses_WT_ht+0xf5f, %r9
sub %r14, %r14
mov $0x6162636465666768, %r8
movq %r8, (%r9)
nop
nop
inc %r9
lea addresses_A_ht+0x8f5f, %r15
nop
nop
nop
nop
nop
dec %r10
movw $0x6162, (%r15)
nop
nop
nop
nop
nop
inc %r9
lea addresses_WC_ht+0xb25f, %rsi
nop
nop
nop
nop
sub $16459, %r9
movups (%rsi), %xmm7
vpextrq $0, %xmm7, %r11
add %r15, %r15
lea addresses_WT_ht+0x435f, %rsi
lea addresses_D_ht+0x26af, %rdi
inc %r10
mov $108, %rcx
rep movsq
nop
nop
nop
and $49037, %r10
lea addresses_WT_ht+0x1d1df, %r9
nop
nop
and $37413, %r14
vmovups (%r9), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rcx
nop
nop
nop
inc %r9
lea addresses_WT_ht+0x16f5f, %rsi
and %r8, %r8
mov (%rsi), %r10
nop
sub %r9, %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_normal+0xf75f, %rsi
lea addresses_normal+0x8adf, %rdi
nop
xor %r14, %r14
mov $18, %rcx
rep movsq
nop
cmp $46271, %rcx
// REPMOV
lea addresses_UC+0x183ef, %rsi
lea addresses_PSE+0x1575f, %rdi
clflush (%rdi)
add $6417, %r13
mov $14, %rcx
rep movsl
nop
nop
nop
add %r13, %r13
// Faulty Load
lea addresses_UC+0xdf5f, %r10
nop
cmp $41946, %r14
vmovups (%r10), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %rsi
lea oracles, %rdx
and $0xff, %rsi
shlq $12, %rsi
mov (%rdx,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_PSE', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
SECTION "Intro", ROMX
Intro::
jr @
|
# PowerPC-32 mpn_submul_1 -- Multiply a limb vector with a limb and subtract
# the result from a second limb vector.
# Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
# This file is part of the GNU MP Library.
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# The GNU MP Library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
# You should have received a copy of the GNU Library General Public License
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
# INPUT PARAMETERS
# res_ptr r3
# s1_ptr r4
# size r5
# s2_limb r6
# This is optimized for the PPC604. It has not been tested on PPC601, PPC603
# or PPC750 since I don't have access to any such machines.
include(`../config.m4')
ASM_START()
PROLOGUE(mpn_submul_1)
cmpi cr0,r5,9 # more than 9 limbs?
bgt cr0,.Lbig # branch if more than 9 limbs
mtctr r5
lwz r0,0(r4)
mullw r7,r0,r6
mulhwu r10,r0,r6
lwz r9,0(r3)
subfc r8,r7,r9
addc r7,r7,r8 # invert cy (r7 is junk)
addi r3,r3,-4
bdz .Lend
.Lloop:
lwzu r0,4(r4)
stwu r8,4(r3)
mullw r8,r0,r6
adde r7,r8,r10
mulhwu r10,r0,r6
lwz r9,4(r3)
addze r10,r10
subfc r8,r7,r9
addc r7,r7,r8 # invert cy (r7 is junk)
bdnz .Lloop
.Lend: stw r8,4(r3)
addze r3,r10
blr
.Lbig: stmw r30,-32(r1)
addi r5,r5,-1
srwi r0,r5,2
mtctr r0
lwz r7,0(r4)
mullw r8,r7,r6
mulhwu r0,r7,r6
lwz r7,0(r3)
subfc r7,r8,r7
addc r8,r8,r7
stw r7,0(r3)
.LloopU:
lwz r7,4(r4)
lwz r12,8(r4)
lwz r30,12(r4)
lwzu r31,16(r4)
mullw r8,r7,r6
mullw r9,r12,r6
mullw r10,r30,r6
mullw r11,r31,r6
adde r8,r8,r0 # add cy_limb
mulhwu r0,r7,r6
lwz r7,4(r3)
adde r9,r9,r0
mulhwu r0,r12,r6
lwz r12,8(r3)
adde r10,r10,r0
mulhwu r0,r30,r6
lwz r30,12(r3)
adde r11,r11,r0
mulhwu r0,r31,r6
lwz r31,16(r3)
addze r0,r0 # new cy_limb
subfc r7,r8,r7
stw r7,4(r3)
subfe r12,r9,r12
stw r12,8(r3)
subfe r30,r10,r30
stw r30,12(r3)
subfe r31,r11,r31
stwu r31,16(r3)
subfe r11,r11,r11 # invert ...
addic r11,r11,1 # ... carry
bdnz .LloopU
andi. r31,r5,3
mtctr r31
beq cr0,.Lendx
.LloopE:
lwzu r7,4(r4)
mullw r8,r7,r6
adde r8,r8,r0 # add cy_limb
mulhwu r0,r7,r6
lwz r7,4(r3)
addze r0,r0 # new cy_limb
subfc r7,r8,r7
addc r8,r8,r7
stwu r7,4(r3)
bdnz .LloopE
.Lendx:
addze r3,r0
lmw r30,-32(r1)
blr
EPILOGUE(mpn_submul_1)
|
include 'hardware/custom.i'
include 'hardware/cia.i'
include 'exec/memory.i'
ChipStart equ $400
ChipEnd equ $80000
SlowStart equ $c00000
SlowEnd equ $c80000
; custom chips addresses
custom equ $dff000
ciaa equ $bfe001
ciab equ $bfd000
; 512kB kickstart begin address
org $f80000
Kickstart:
dc.l $400 ; Initial SP
dc.l Entry ; Initial PC
; The ROM is located at $fc0000 but is mapped at $0 after reset shadowing RAM
Entry:
lea ciaa,a4
lea ciab,a5
lea custom,a6
move.b #3,ciaddra(a4) ; Set port A direction to output for /LED and OVL
move.b #0,ciapra(a4) ; Disable OVL (Memory from $0 onwards available)
InitHW:
move.w #$7fff,d0 ; Make sure DMA and interrupts are disabled
move.w d0,intena(a5)
move.w d0,intreq(a5)
move.w d0,dmacon(a5)
; Wake up line & frame counters
clr.b ciatodhi(a4)
clr.b ciatodmid(a4)
clr.b ciatodlow(a4)
clr.b ciatodhi(a5)
clr.b ciatodmid(a5)
clr.b ciatodlow(a5)
Setup:
move.l #(HunkFileEnd-HunkFile),d2
move.l #HunkFile,d3
move.l #BD_SIZE+2*MR_SIZE,a3
sub.l a3,sp
move.l sp,a6
clr.l BD_HUNK(a6)
clr.l BD_VBR(a6)
clr.w BD_CPUMODEL(a6)
move.w #2,BD_NREGIONS(a6)
lea BD_REGION(a6),a0
move.l #SlowStart,(a0)+
move.l #SlowEnd,(a0)+
move.w #MEMF_FAST|MEMF_PUBLIC,(a0)+
move.l #ChipStart,(a0)+
move.l #ChipEnd,(a0)+
move.w #MEMF_CHIP|MEMF_PUBLIC,(a0)+
ROM = 1
include '$(TOPDIR)/bootloader.asm'
HunkFile
incbin '$(EFFECT).exe'
HunkFileEnd
org $fffff0
dc.w $4718, $4819, $4f1a, $531b
dc.w $541c, $4f1d, $571e, $4e1f
; vim: ft=asm68k:ts=8:sw=8:noet:
|
; Credits
SE02B: DEFM "Code, GFX, Story etc",0
SE02D: DEFM "Patrick Prendergast",0
SE02F: DEFM "Acknowledgements",0
SE031: DEFM "Durk Kingma - Grayscale",0
SE033: DEFM "Kerey Roper - Huffman",0
SE035: DEFM "Joe Pemberton - RLE",0
SE037: DEFM "Joe Wingbermuehle - Ion",0
SE039: DEFM "Tijl Coosemans - Venus",0
SE03B: DEFM "DetachedS - MirageOS",0
SE03D: DEFM "Testers",0
SE03F: DEFM "David Sleight",0
SE041: DEFM "John Sleight",0
SE043: DEFM "Durk Kingma",0
SE045: DEFM "Joe Pemberton",0
SE047: DEFM "Shawn McAndrews",0
SE049: DEFM "Tom King",0
SE04B: DEFM "Domi Alex",0
SE04D: DEFM "Sammy Griff",0
SE04F: DEFM "Dennis Tseng",0
SE051: DEFM "AndySoft",0
SE053: DEFM "jedbouy",0
SE055: DEFM "Bram Tant",0
SE057: DEFM "Martin Warmer",0
SE059: DEFM "Vincent Junemann",0
SE05B: DEFM "Michael Angel",0
SE05D: DEFM "Special Thanks & Greetz",0
SE05F: DEFM "Everyone @ MaxCoderz",0
SE061: DEFM "Everyone on #TCPA (EFNet)",0
SE063: DEFM "ticalc.org",0
SE065: DEFM "No animals were hurt more",0
SE067: DEFM "than once during the",0
SE069: DEFM "making of this game.",0
SE06B: DEFM "Just Kidding ;P",0
SE06D: DEFM "Thanks for Playing!",0
SE06F: DEFM "visit www.MaxCoderz.com",0
SE071: DEFM "ABlakRain",0
SE073: DEFM "Travis Supalla",0
SE075: DEFM "Jim Dieckmann",0
SE077: DEFM "tr1p1ea@yahoo.com.au",0
SCR40: DEFM "Ported to ZX Spectrum",0
SCR41: DEFM "by nzeemin, 2020",0
; Data Cartridge messages
SE079: DEFM "Im hurt bad . . . I dont|think im gonna make it.|I changed the Level 1|Access Code to: 4057|"
DEFM "Maybe that will hold|them off for a while . . .",0
SE07B: DEFM "For security reasons|I had to change the|Level 2 Access Code.|Maybe now the crew|will stop",$02
DEFM "stealing",$02,"stuff!|It is:",0
SE07D: DEFM "The system is going|haywire. The Level 3|Access Code was over-|written. I only just|recovered it."
DEFM "Turns",$02,"out|it is:",0
SE07F: DEFM "Crew I am honoured to|have served as your|captain. The Level 4|Access Code will get|"
DEFM "to the evacuation deck|It is:",0
SE081: DEFM "Willis and I are stuck.|Needless to say we are|both done for.",$02
DEFM "We",$02,"might|have had a chance, but|some idiot changed the|Level 1 Access Code!",0
SE083: DEFM "I",$02,"dont see",$02,"why I",$02,"should|be the one who has to|fix the generator.|"
DEFM "There is no way im|going with those things|all over the place . . .",0
SE085: DEFM "DrMorgan: Meteorite|shower claimed a lot|of the crew, however|some feature strange|abrations. "
DEFM "Almost like|bite marks . . ?",0
SE087: DEFM "DrMorgan: I found a|strange creature. At|first I thought it was|deceased.",$02
DEFM "But",$02,"it",$02,"sprang|up and attacked my|associate! . . .",0
SE089: DEFM "DrMorgan: To make|matters worse the|creatures are|evolving rapidly. My|associate claims he|"
DEFM "saw one over 7 feet!",0
SE08B: DEFM "It truly baffles me|considering our cargo|why they insist on|equipping the ship with|ONLY "
DEFM "Ion-Phasers.|They are useless!!!",0
SE08D: DEFM "Capt Millin: We are|losing crew fast.",$02,"I",$02,"sent|Willis to re-animate|the clones. "
DEFM "Right now|they are the only|chance we have . . .",0
SE08F: DEFM "Capt Millin: I am very|anxious to see the|clones in action. I|hear that they are the|"
DEFM "most advanced clone|soldiers ever created.",0
SE091: DEFM "Capt Millin: We are|transporting a cargo|of genetically|modified clones to a|IH-2 Military Facility|"
DEFM "for field testing . . .",0
SE093: DEFM "Capt Millin: I have|just recieved word|that the facility on|earth was destroyed.|"
DEFM "We now carry the only|clone prototypes.",0
SE095: DEFM "Willis: We are in BIG|trouble.",$02,"Only one",$02,"clone|survived the",$02,"meteorite|shower.",$02
DEFM "And the",$02,"system|says Re-animation will|take over 6 hours!!!",0
SE097: DEFM "This is ludicrous!|65 credits for",$02,"a proton|bar? How are we|meant to snack while|we work? "
DEFM "The agency|is",$02,"getting",$02,"on",$02,"my",$02,"nerves.",0
;
SE09B: DEFM $10,"No Data Cartridge|",$1F,$04,"Selected",0
SE09D: DEFM "MaxCoderz Presents",0
SE09F: DEFM "a tr1p1ea game",0
SE0A1: DEFM "Items Found (/24):|",$1F,$02,"Enemies Killed:|",$1F,$03,"Player Deaths:||Awards:",0
SE0A3: DEFM "OverWrite Current Game?|Enter - Yes :: G - No",0
SE0A5: DEFM "- Controls -",0
SE0A7: DEFM "QAOP 1234 6789: Arrows|Space ZBMN05: Look/shoot|U I: Inventory|S D: Look/shoot mode|"
DEFM "W E: Close all pop-ups|G: Quit to Menu",0
SE0A9: DEFM "Earn 3 Good Awards for|an Extended Ending!",0
SE0AB: DEFM "Sir Miss-A-Lot",0
SE0AD: DEFM "Sherlock Holmes",0
SE0AF: DEFM "Running Scared",0
SE0B1: DEFM "Terminator",0
SE0B3: DEFM "Over & Over Again",0
SE0B5: DEFM "Survivor",0
SE0B7: DEFM $18,"Ion Phaser",0
SE0B9: DEFM "$",0 ; Arrow down
SE0BB: DEFM " - INVENTORY - ",0
SE0BD: DEFM "The Desolate has claimed|your life too . . .",0
SE0BF: DEFM "OMG! This Person Is DEAD!",0
SE0C1: DEFM "What Happened Here!?!",0
SE0C3: DEFM $0A,"Another Dead Person.",0
SE0C5: DEFM " Search Reveals Nothing",0
SE0C7: DEFM $0F,"This Person is Dead . . .",0
SE0C9: DEFM "They Seem To Be Holding",0
SE0CB: DEFM "Something",0
SE0CD: DEFM $0F,"Hey Whats This",$06,".",$06,".",$06,". ?",0
SE0CF: DEFM "You Picked Up A",0
SE0D1: DEFM "You Already Have The",0
SE0D3: DEFM "You dont have a|",$1E,"Weapon to equip!",0
SE0D5: DEFM "It is not wise to proceed|",$19,"without a weapon.",0
SE0D7: DEFM "You cant enter that sector|",$09,"Life-Support is offline.",0
SE0D9: DEFM "You cant enter until the|AirLock is re-pressurised",0
SE0DB: DEFM $0D,"---- N o",$06,"I t e m ----",0
SE0DD: DEFM $05,"Door Locked",0
SE0DF: DEFM "INVALID",$02,"CODE",0
SE0E1: DEFM $0E,"Accepted!",0
SE0E3: DEFM $1F,"You Need A|Data Cartridge Reader",0
; Inventory items
SE0E5: DEFM $06,"Data Cartridge Reader",0
SE0E7: DEFM $18,"Data Cartridge 1",0
SE0E9: DEFM $18,"Data Cartridge 2",0
SE0EB: DEFM $18,"Data Cartridge 3",0
SE0ED: DEFM $18,"Data Cartridge 4",0
SE0EF: DEFM $18,"Data Cartridge 5",0
SE0F1: DEFM $18,"Data Cartridge 6",0
SE0F3: DEFM $18,"Data Cartridge 7",0
SE0F5: DEFM $18,"Data Cartridge 8",0
SE0F7: DEFM $18,"Data Cartridge 9",0
SE0F9: DEFM $14,"Data Cartridge 10",0
SE0FB: DEFM $14,"Data Cartridge 11",0
SE0FD: DEFM $14,"Data Cartridge 12",0
SE0FF: DEFM $14,"Data Cartridge 13",0
SE101: DEFM $14,"Data Cartridge 14",0
SE103: DEFM $14,"Data Cartridge 15",0
SE105: DEFM $14,"Data Cartridge 16",0
SE107: DEFM $1F,$0B,"Power Drill",0
SE109: DEFM $06,"Life Support Data Disk",0
SE10B: DEFM $1F,$06,"Air-Lock Tool",0
SE10D: DEFM $12,"Box of Power Cells",0
SE10F: DEFM $1F,$07,"Pile of Parts",0
SE111: DEFM $1F,$0A,"Duck Idol ;)",0
SE113: DEFM $1F,$08,"Rubik's Cube",0
;
SE115: DEFM "In the Distant Future . . .",0
SE117: DEFM "'The Desolate' Space Cruiser|leaves orbit. Its mission is|secret, its cargo classified.|"
DEFM "6014 Cycles into the journey|the ship encounters a savage|meteorite shower.||"
DEFM "Contact with Desolate is lost.",0
SE119: DEFM "The ship sustains heavy|damage. Onboard a cryo-|genic incubation cell|finishes re-animation. "
DEFM "Its|occupant steps out of the|chamber not knowing who he|is, or what he is going to do.||"
DEFM "But at least he is alive.",0
SE11B: DEFM "The onboard guidance|system picks up a mining|facility close by. The course|is set",$02
DEFM "and you sit back,",$02,"finally|free of 'The Desolate' & its|murderous hord of Aliens.|"
DEFM "You were a clone, an|experiment. Now, 'you' are|the sole survivor.",0
SE11D: DEFM "System Alert triggered: |'Foreign Objects Detected|OnBoard'. The Aliens have|attached to the hull!|"
DEFM "'Main Drive System Offline'|The ship was on a crash|course for",$02,"the Mining Facility||"
DEFM "It wasnt over yet",$06,".",$06,".",$06,".",0
SE11F: DEFM "The End",0
;
SAccessLevel1: DEFM $1B,"Level 1|",$09,"Access Code|",$15,"Required",0
SAccessLevel2: DEFM $1B,"Level 2|",$09,"Access Code|",$15,"Required",0
SAccessLevel3: DEFM $1B,"Level 3|",$09,"Access Code|",$15,"Required",0
SAccessLevel4: DEFM $1B,"Level 4|",$09,"Access Code|",$15,"Required",0
;
SE129: DEFM "You dont seem to be able|",$0F,"to use this item here",0
SE12B: DEFM "You dont have any time|",$08,"to play with this now",0
SE12D: DEFM $10,"It doesnt look like you|",$04,"can do anything else here",0
SE12F: DEFM "This Generator is damaged|All of the panels are loose",0
SE131: DEFM $0F,"This Workstation doesnt|seem to have any power...?",0
SE133: DEFM $0A,"The Workstation has now|",$09,"successfully booted up",$06,"$",0
SE135: DEFM "The Workstation Ejected A|",$1F,$05,"Data Cartridge 2",0
SE137: DEFM " You use the Power Drill|to Repair the Generator",0
SE139: DEFM $12,"Life-Support System|has been fully restored",0
SE13B: DEFM "The Evacuation Deck has|",$09,"been re-pressurised",0
SE13D: DEFM "You Insert a Power Cell.|Guidance System Online",0
SE13F: DEFM $0C,"The Life Support System|",$15,"needs Re-Configuring",0
SE141: DEFM $1F,$04,"AirLock Control &| Re-Pressurisation Station",0
SE143: DEFM $05,"This MainFrame is missing|",$1F,$16,"a Power Cell",0
SE145: DEFM $09,"This Pod cant naviagate.|Guidance System is offline",0
SQuit: DEFM "Its now safe to turn off|",$1F,$0E,"your computer.",0
|
; A273367: Numbers k such that 10*k+6 is a perfect square.
; 1,3,19,25,57,67,115,129,193,211,291,313,409,435,547,577,705,739,883,921,1081,1123,1299,1345,1537,1587,1795,1849,2073,2131,2371,2433,2689,2755,3027,3097,3385,3459,3763,3841,4161,4243,4579,4665,5017,5107,5475,5569,5953,6051,6451,6553,6969,7075,7507,7617,8065,8179,8643,8761,9241,9363,9859,9985,10497,10627,11155,11289,11833,11971,12531,12673,13249,13395,13987,14137,14745,14899,15523,15681,16321,16483,17139,17305,17977,18147,18835,19009,19713,19891,20611,20793,21529,21715,22467,22657,23425,23619
seq $0,47221 ; Numbers that are congruent to {2, 3} mod 5.
pow $0,2
div $0,5
mul $0,2
add $0,1
|
/* Copyright 2019 The TensorFlow 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 "tensorflow/compiler/xla/pjrt/tracked_device_buffer.h"
#include <memory>
#include "tensorflow/compiler/xla/client/client_library.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/test.h"
#include "tensorflow/stream_executor/device_memory_allocator.h"
namespace xla {
namespace {
StatusOr<std::shared_ptr<TrackedDeviceBuffer>> MakeArray(const Shape& shape,
LocalClient* client) {
std::vector<stream_executor::DeviceMemoryBase> device_buffers;
TF_RETURN_IF_ERROR(ShapeUtil::ForEachSubshapeWithStatus(
client->backend().transfer_manager()->HostShapeToDeviceShape(shape),
[&](const Shape& subshape, const ShapeIndex&) -> Status {
TF_ASSIGN_OR_RETURN(
se::OwningDeviceMemory device_memory,
client->backend().memory_allocator()->Allocate(
/*device_ordinal=*/0,
client->backend().transfer_manager()->GetByteSizeRequirement(
subshape)));
device_buffers.push_back(device_memory.Release());
return Status::OK();
}));
return std::make_shared<TrackedDeviceBuffer>(
client->backend().memory_allocator(), /*device_ordinal=*/0,
device_buffers,
absl::Span<const std::shared_ptr<BufferSequencingEvent>>(), nullptr);
}
TEST(TrackedDeviceBufferTest, AsShapedBuffer) {
LocalClient* client = ClientLibrary::LocalClientOrDie();
Shape a_shape = ShapeUtil::MakeShape(F32, {3, 101, 4});
Shape b_shape = ShapeUtil::MakeShape(S8, {77});
Shape c_shape = ShapeUtil::MakeShape(S64, {});
TF_ASSERT_OK_AND_ASSIGN(auto a_buffer, MakeArray(a_shape, client));
TF_ASSERT_OK_AND_ASSIGN(auto b_buffer, MakeArray(b_shape, client));
TF_ASSERT_OK_AND_ASSIGN(auto c_buffer, MakeArray(c_shape, client));
ASSERT_EQ(a_buffer->device_memory().size(), 1);
ASSERT_EQ(b_buffer->device_memory().size(), 1);
ASSERT_EQ(c_buffer->device_memory().size(), 1);
std::vector<se::DeviceMemoryBase> expected_buffer_sequence = {
a_buffer->device_memory()[0], b_buffer->device_memory()[0],
c_buffer->device_memory()[0]};
ShapedBuffer shaped_a = a_buffer->AsShapedBuffer(
a_shape,
client->backend().transfer_manager()->HostShapeToDeviceShape(a_shape));
ShapedBuffer shaped_b = b_buffer->AsShapedBuffer(
b_shape,
client->backend().transfer_manager()->HostShapeToDeviceShape(b_shape));
ShapedBuffer shaped_c = c_buffer->AsShapedBuffer(
c_shape,
client->backend().transfer_manager()->HostShapeToDeviceShape(c_shape));
auto expected_it = expected_buffer_sequence.begin();
for (auto it = shaped_a.buffers().begin(); it != shaped_a.buffers().end();
++it) {
ASSERT_TRUE(expected_it != expected_buffer_sequence.end());
EXPECT_TRUE(expected_it->IsSameAs(it->second));
++expected_it;
}
for (auto it = shaped_b.buffers().begin(); it != shaped_b.buffers().end();
++it) {
ASSERT_TRUE(expected_it != expected_buffer_sequence.end());
EXPECT_TRUE(expected_it->IsSameAs(it->second));
++expected_it;
}
for (auto it = shaped_c.buffers().begin(); it != shaped_c.buffers().end();
++it) {
ASSERT_TRUE(expected_it != expected_buffer_sequence.end());
EXPECT_TRUE(expected_it->IsSameAs(it->second));
++expected_it;
}
EXPECT_TRUE(expected_it == expected_buffer_sequence.end());
}
TEST(TrackedDeviceBufferTest, FromScopedShapedBuffer) {
LocalClient* client = ClientLibrary::LocalClientOrDie();
Literal literal = LiteralUtil::MakeTupleOwned(
LiteralUtil::CreateFullWithDescendingLayout<float>({10, 3, 7}, 33.4f),
LiteralUtil::One(S64));
TF_ASSERT_OK_AND_ASSIGN(
ScopedShapedBuffer shaped_buffer,
client->LiteralToShapedBuffer(literal, /*device_ordinal=*/0));
std::shared_ptr<TrackedDeviceBuffer> device_buffer =
TrackedDeviceBuffer::FromScopedShapedBuffer(&shaped_buffer, {});
EXPECT_EQ(device_buffer->device_memory().size(),
ShapeUtil::SubshapeCount(
client->backend().transfer_manager()->HostShapeToDeviceShape(
literal.shape())));
}
} // namespace
} // namespace xla
|
; Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; FlushCacheLine.Asm
;
; Abstract:
;
; AsmFlushCacheLine function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; AsmFlushCacheLine (
; IN VOID *LinearAddress
; );
;------------------------------------------------------------------------------
AsmFlushCacheLine PROC
clflush [rcx]
mov rax, rcx
ret
AsmFlushCacheLine ENDP
END
|
<%
from pwnlib.shellcraft.thumb.linux import syscall
%>
<%page args="pid, sig"/>
<%docstring>
Invokes the syscall kill. See 'man 2 kill' for more information.
Arguments:
pid(pid_t): pid
sig(int): sig
</%docstring>
${syscall('SYS_kill', pid, sig)}
|
extern _ShellExecuteA ; Using external function from Shell32.dll
global _main
section .data
TP DB "open", 0
FL DB "cmd", 0
ARG DB "/c notepad.exe",0
section .text
_main:
PUSH 0 ; Window type: 0 -> SW_Hide
PUSH 0
PUSH ARG
PUSH FL
PUSH TP
PUSH 0
CALL _ShellExecuteA
|
; Example 3:
; A user mode task accesses the keypad and the
; text display using two non-blocking system
; calls. The task polls the keypad until a key
; has been pressed and prints the value on the
; text display.
JMP boot
JMP isr ; Interrupt vector
JMP svc ; System call vector
sStackTop EQU 0x0FF ; Initial Supervisor SP
uStackTop EQU 0x1FF ; Initial User Task SP
txtDisplay EQU 0x2E0
keypressed: ; 1 = key pressed
DB 0 ; 0 = No key pressed
value: ; The number of the
DB 0 ; key pressed in ASCII
boot:
MOV SP, sStackTop ; Set Supervisor SP
MOV A, 1 ; Set bit 0 of IRQMASK
OUT 0 ; Unmask keypad IRQ
MOV A, 0x01FF ; Set the end of the
OUT 8 ; protection to 0x01FF
MOV A, 0x0109 ; Protection in seg. mode
OUT 7 ; from 0x0100, S=1, U=0
PUSH 0x0010 ; User Task SR: IRQMASK = 1
PUSH uStackTop ; User Task SP = 0x1FF
PUSH task ; User Task IP = task
SRET ; Jump to user mode
HLT ; Parachute
isr:
PUSH A ; Read the key pressed
IN 6 ; and store the ASCII
MOVB [value], AL
MOVB AL, 1
MOVB [keypressed], AL
MOV A, 1
OUT 2 ; Write to signal IRQEOI
POP A
IRET
svc: ; Supervisor call
CMP A, 0 ; A = syscall number
JNZ .not0 ; 0 -> readchar
CLI
MOV A, [keypressed] ; Write vars
PUSH B ; with IRQs
MOV B, 0 ; disabled
MOV [keypressed], B
POP B
STI
JMP .return
.not0:
CMP A, 1 ; 1 -> putchar
JNZ .return
MOVB [txtDisplay], BL
.return:
SRET ; Return to user space
ORG 0x100 ; Following instructions
; will be assembled at 0x100
task: ; The user task
MOV A, 0
MOV B, 0
loop:
CALL readchar ; Polls the keypad
CMPB AH, 1 ; using readchar
JNZ loop
MOVB BL, AL ; If key was pressed use
CALL putchar ; putchar to print it
JMP loop
readchar: ; User space wrapper
MOV A, 0 ; for readchar syscall
SVC ; Syscall #0
RET ; A -> syscall number
putchar: ; User space wrapper
PUSH A ; for putchar syscall
MOV A, 1 ; Syscall #1
SVC ; A -> syscall number
POP A ; BL -> char to print
RET
|
; A027053: a(n) = T(n,n+2), T given by A027052.
; 1,4,9,18,35,66,123,228,421,776,1429,2630,4839,8902,16375,30120,55401,101900,187425,344730,634059,1166218,2145011,3945292,7256525,13346832,24548653,45152014,83047503,152748174,280947695,516743376,950439249,1748130324,3215312953,5913882530,10877325811,20006521298,36797729643,67681576756,124485827701,228965134104,421132538565,774583500374,1424681173047,2620397211990,4819661885415,8864740270456,16304799367865,29989201523740,55158741162065,101452742053674,186600684739483,343212167955226,631265594748387,1161078447443100,2135556210146717,3927900252338208,7224534909928029
add $0,3
cal $0,196700 ; Number of n X 1 0..4 arrays with each element x equal to the number of its horizontal and vertical neighbors equal to 3,1,0,4,2 for x=0,1,2,3,4.
add $1,$0
sub $1,3
div $1,2
|
; A272614: Numbers whose binary digits, except for the first "1", are given by floor(((k-n)/n) mod 2) with 1<=k<=n.
; Submitted by Jon Maiga
; 1,2,6,8,28,40,104,144,496,672,1632,2240,7872,11648,27520,33536,120576,175616,445952,629760,2014208,2701312,6453248,8712192,33353728,48881664,114548736,144949248,476561408,684687360,1787789312,2501836800,8510177280,11647451136,27590000640
mov $2,2
mov $4,$0
lpb $2
sub $2,1
add $0,$2
sub $0,1
lpb $0
sub $0,1
mul $1,2
add $3,1
mov $5,$4
div $5,$3
gcd $5,2
add $1,$5
lpe
lpe
mov $0,$1
add $0,1
|
; A092516: Decimal expansion of e^(1/7).
; 1,1,5,3,5,6,4,9,9,4,8,9,5,1,0,7,7,5,3,4,6,1,3,3,9,6,2,4,4,7,1,8,6,2,4,4,1,9,9,5,6,8,7,7,3,2,7,3,9,6,6,0,9,5,1,5,3,8,8,0,1,0,8,2,4,7,6,8,4,0,3,7,0,2,7,2,1,0,6,8,4,3,0,3,5,9,9,1,3,6,2,1,8,2,3,5,8,6,0,8
mov $2,1
mov $3,$0
mul $3,5
lpb $3
div $1,7
mul $2,$3
add $1,$2
cmp $4,0
mov $5,$0
div $5,3
add $5,$4
div $1,$5
div $2,$5
sub $3,1
cmp $4,0
lpe
mov $6,10
pow $6,$0
div $2,$6
div $1,$2
add $1,$6
mod $1,10
mov $0,$1
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Print Drivers
FILE: textSendFont101215Prop.asm
AUTHOR: Dave Durran
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 6/8/92 Initial revision from epson24Styles.asm
Dave 8/92 Obsolesced by the print style run routines
OBSOLETE: DO NOT USE!
DC_ESCRIPTION:
$Id: textSendFont101215Prop.asm,v 1.1 97/04/18 11:49:59 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintSendFont
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send the right stuff to set the font in the printer
CALLED BY: INTERNAL
PrintSetFont
PASS: es - PState segment
RETURN: carry - set if some communications error
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Jim 01/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintSendFont proc near
uses si
.enter
mov si, offset cs:pr_codes_Set10Pitch ; assume it's 10CPI
cmp es:[PS_curFont].FE_fontID, FID_PRINTER_10CPI ; chk ass
je sendTheFont
mov si, offset cs:pr_codes_SetProportional
cmp es:[PS_curFont].FE_fontID, FID_PRINTER_PROP_SERIF
je sendTheFont
mov si, offset cs:pr_codes_Set12Pitch ; check the next one
cmp es:[PS_curFont].FE_fontID, FID_PRINTER_12CPI ; chk ass
je sendTheFont
mov si, offset cs:pr_codes_Set15Pitch ; check the next one
;must be either 15 pitch or unsupported: set 15 pitch
sendTheFont:
call SendCodeOut ; set it at printer
exit:
.leave
ret
PrintSendFont endp
|
#pragma once
void SetupLevelInfoUI();
void ResetLevelInfoUI(); |
SECTION code_clib
PUBLIC respixel
EXTERN __gfx_coords
;
; $Id: respixl.asm,v 1.10 2016-07-02 09:01:36 dom Exp $
;
; ******************************************************************
;
; Clears pixel at (x,y) coordinate.
;
; ZX 81 version.
; 64x48 dots.
;
;
.respixel
ld a,h
cp 64
ret nc
ld a,l
;cp maxy
cp 48
ret nc ; y0 out of range
ld (__gfx_coords),hl
push bc
ld c,l
ld b,h
push bc
srl b
srl c
IF FORlambda
ld hl,16510
ELSE
ld hl,(16396) ; D_FILE
inc hl
ENDIF
;ld a,b
ld a,c
ld c,b ; !!
ld de,33 ; 32+1. Every text line ends with an HALT
and a
jr z,r_zero
ld b,a
.r_loop
add hl,de
djnz r_loop
.r_zero ; hl = char address
ld e,c
add hl,de
ld a,(hl) ; get current symbol
cp 8
jr c,islow ; recode graph symbol to binary -> 0..F
ld a,143
sub (hl)
.islow ex (sp),hl ; save char address <=> restore x,y
cp 16 ; Just to be sure:
jr c,issym ; if it isn't a symbol...
xor a ; .. force to blank sym
.issym
ld b,a
ld a,1 ; the bit we want to clear
bit 0,h
jr z,iseven
add a,a ; move right the bit
.iseven
bit 0,l
jr z,evenrow
add a,a
add a,a ; move down the bit
.evenrow
cpl
and b
cp 8 ; Now back from binary to
jr c,hisym ; graph symbols.
ld b,a
ld a,15
sub b
add a,128
.hisym
pop hl
ld (hl),a
pop bc
ret
|
;; This file is a part of the IncludeOS unikernel - www.includeos.org
;;
;; Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences
;; and Alfred Bratterud
;;
;; 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.
USE32
extern __arch_start
extern __serial_print1
global __multiboot_magic
global __multiboot_addr
global _start
global __xsave_enabled
global __avx_enabled
%define MB_MAGIC 0x1BADB002
%define MB_FLAGS 0x3 ;; ALIGN + MEMINFO
;; stack base address at EBDA border
;; NOTE: Multiboot can use 9d400 to 9ffff
%define STACK_LOCATION 0x9D3F0
extern _MULTIBOOT_START_
extern _LOAD_START_
extern _LOAD_END_
extern _end
ALIGN 4
section .multiboot
dd MB_MAGIC
dd MB_FLAGS
dd -(MB_MAGIC + MB_FLAGS)
dd _MULTIBOOT_START_
dd _LOAD_START_
dd _LOAD_END_
dd _end
dd _start
%define data_segment 0x10
%define code_segment 0x08
section .data
__xsave_enabled:
dw 0x0
__avx_enabled:
dw 0x0
__multiboot_magic:
dd 0x0
__multiboot_addr:
dd 0x0
section .text
;; Multiboot places boot paramters on eax and ebx.
_start:
;; load simple GDT
lgdt [gdtr]
;; Reload all data segments to new GDT
jmp code_segment:rock_bottom
;; Set up stack and load segment registers
;; (e.g. this is the very bottom of the stack)
rock_bottom:
mov cx, data_segment
mov ss, cx
mov ds, cx
mov es, cx
mov fs, cx
mov cx, 0x18 ;; GS segment
mov gs, cx
;; 32-bit stack ptr
mov esp, STACK_LOCATION
mov ebp, esp
;; enable SSE before we enter C/C++ land
call enable_sse
;; Enable modern x87 FPU exception handling
call enable_fpu_native
;; try to enable XSAVE before checking AVX
call enable_xsave
;; enable AVX if xsave and avx supported on CPU
call enable_avx
;; Save multiboot params
mov DWORD [__multiboot_magic], eax
mov DWORD [__multiboot_addr], ebx
call __arch_start
jmp __start_panic
enable_fpu_native:
push eax
mov eax, cr0
or eax, 0x20
mov cr0, eax
pop eax
ret
enable_sse:
push eax ;preserve eax for multiboot
mov eax, cr0
and ax, 0xFFFB ;clear coprocessor emulation CR0.EM
or ax, 0x2 ;set coprocessor monitoring CR0.MP
mov cr0, eax
mov eax, cr4
or ax, 3 << 9 ;set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
mov cr4, eax
pop eax
ret
enable_xsave:
push eax
push ebx
; check for XSAVE support
mov eax, 1
xor ecx, ecx
cpuid
; bit 26 ecx
and ecx, 0x04000000
cmp ecx, 0x04000000
jne xsave_not_supported
; enable XSAVE
mov eax, cr4
or eax, 0x40000
mov cr4, eax
mov WORD [__xsave_enabled], 0x1
xsave_not_supported:
pop ebx
pop eax
ret
enable_avx:
push eax
push ebx
;; assuming cpuid with eax=1 supported
mov eax, 1
xor ecx, ecx
cpuid
;; check bits 27, 28 (xsave, avx)
and ecx, 0x18000000
cmp ecx, 0x18000000
jne avx_not_supported
;; enable AVX support
xor ecx, ecx
xgetbv
or eax, 0x7
xsetbv
mov WORD [__avx_enabled], 0x1
avx_not_supported:
pop ebx
pop eax
ret
__start_panic:
sub esp, 4
and esp, -16
mov DWORD [esp], str.panic
call __serial_print1
cli
hlt
ALIGN 32
gdtr:
dw gdt32_end - gdt32 - 1
dd gdt32
ALIGN 32
gdt32:
;; Entry 0x0: Null descriptor
dq 0x0
;; Entry 0x8: Code segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf9a ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
;; Entry 0x10: Data segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf92 ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
;; Entry 0x18: GS Data segment
dw 0x0100 ;Limit
dw 0x1000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0x4092 ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
gdt32_end:
str:
.panic:
db `Panic: OS returned to x86 start.asm. Halting\n`,0x0
|
\ ******************************************************************************
\
\ ELECTRON ELITE LOADER SOURCE
\
\ Electron Elite was written by Ian Bell and David Braben and is copyright
\ Acornsoft 1984
\
\ The code on this site has been disassembled from the version released on Ian
\ Bell's personal website at http://www.elitehomepage.org/
\
\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes
\ in the documentation are entirely my fault
\
\ The terminology and notations used in this commentary are explained at
\ https://www.bbcelite.com/about_site/terminology_used_in_this_commentary.html
\
\ ------------------------------------------------------------------------------
\
\ This source file produces the following binary file:
\
\ * output/ELITEDA.bin
\
\ ******************************************************************************
INCLUDE "sources/elite-header.h.asm"
\ ******************************************************************************
\
\ Configuration variables
\
\ ******************************************************************************
N% = 17 \ N% is set to the number of bytes in the VDU table, so
\ we can loop through them in part 2 below
LE% = &0B00 \ LE% is the address to which the code from UU% onwards
\ is copied in part 3
C% = &0D00 \ C% is set to the location that the main game code gets
\ moved to after it is loaded
L% = &2000 \ L% is the load address of the main game code file
S% = C% \ S% points to the entry point for the main game code
USERV = &0200 \ The address for the user vector
BRKV = &0202 \ The address for the break vector
IRQ1V = &0204 \ The address for the interrupt vector
WRCHV = &020E \ The address for the write character vector
RDCHV = &0210 \ The address for the read character vector
KEYV = &0228 \ The address for the keyboard vector
OSWRCH = &FFEE \ The address for the OSWRCH routine
OSBYTE = &FFF4 \ The address for the OSBYTE routine
OSWORD = &FFF1 \ The address for the OSWORD routine
OSCLI = &FFF7 \ The address for the OSCLI routine
VIA = &FE00 \ Memory-mapped space for accessing internal hardware,
\ such as the video ULA, 6845 CRTC and 6522 VIAs (also
\ known as SHEILA)
\ ******************************************************************************
\
\ Name: ZP
\ Type: Workspace
\ Address: &0004 to &0005 and &0070 to &0086
\ Category: Workspaces
\ Summary: Important variables used by the loader
\
\ ******************************************************************************
ORG &0004
.TRTB%
SKIP 2 \ TRTB%(1 0) points to the keyboard translation table,
\ which is used to translate internal key numbers to
\ ASCII
ORG &0070
.ZP
SKIP 2 \ Stores addresses used for moving content around
.P
SKIP 1 \ Temporary storage, used in a number of places
.Q
SKIP 1 \ Temporary storage, used in a number of places
.YY
SKIP 1 \ Temporary storage, used in a number of places
.T
SKIP 1 \ Temporary storage, used in a number of places
.SC
SKIP 1 \ Screen address (low byte)
\
\ Elite draws on-screen by poking bytes directly into
\ screen memory, and SC(1 0) is typically set to the
\ address of the character block containing the pixel
\ we want to draw (see the deep dives on "Drawing
\ monochrome pixels in mode 4" and "Drawing pixels
\ in the Electron version" for more details)
.SCH
SKIP 1 \ Screen address (high byte)
.BLPTR
SKIP 2 \ Gets set to &03CA as part of the obfuscation code
.V219
SKIP 2 \ Gets set to &0218 as part of the obfuscation code
SKIP 4 \ These bytes appear to be unused
.K3
SKIP 1 \ Temporary storage, used in a number of places
.BLCNT
SKIP 2 \ Stores the tape loader block count as part of the copy
\ protection code in IRQ1
.BLN
SKIP 2 \ Gets set to &03C6 as part of the obfuscation code
.EXCN
SKIP 2 \ Gets set to &03C2 as part of the obfuscation code
\ ******************************************************************************
\
\ ELITE LOADER
\
\ ******************************************************************************
CODE% = &4400
LOAD% = &4400
ORG CODE%
\ ******************************************************************************
\
\ Name: Elite loader (Part 1 of 5)
\ Type: Subroutine
\ Category: Loader
\ Summary: Include binaries for recursive tokens and images
\
\ ------------------------------------------------------------------------------
\
\ The loader bundles a number of binary files in with the loader code, and moves
\ them to their correct memory locations in part 3 below.
\
\ There is one file containing code:
\
\ * WORDS9.bin contains the recursive token table, which is moved to &0400
\ before the main game is loaded
\
\ and four files containing images, which are all moved into screen memory by
\ the loader:
\
\ * P.A-SOFT.bin contains the "ACORNSOFT" title across the top of the loading
\ screen, which gets moved to screen address &5960, on the second character
\ row of the space view
\
\ * P.ELITE.bin contains the "ELITE" title across the top of the loading
\ screen, which gets moved to screen address &5B00, on the fourth character
\ row of the space view
\
\ * P.(C)ASFT.bin contains the "(C) Acornsoft 1984" title across the bottom
\ of the loading screen, which gets moved to screen address &73A0, the
\ penultimate character row of the space view, just above the dashboard
\
\ * P.DIALS.bin contains the dashboard, which gets moved to screen address
\ &7620, which is the starting point of the dashboard, just below the space
\ view
\
\ The routine ends with a jump to the start of the loader code at ENTRY.
\
\ ******************************************************************************
PRINT "WORDS9 = ",~P%
INCBIN "output/WORDS9.bin"
ALIGN 256
PRINT "P.DIALS = ",~P%
INCBIN "binaries/P.DIALS.bin"
PRINT "P.ELITE = ",~P%
INCBIN "binaries/P.ELITE.bin"
PRINT "P.A-SOFT = ",~P%
INCBIN "binaries/P.A-SOFT.bin"
PRINT "P.(C)ASFT = ",~P%
INCBIN "binaries/P.(C)ASFT.bin"
.run
JMP ENTRY \ Jump to ENTRY to start the loading process
\ ******************************************************************************
\
\ Name: B%
\ Type: Variable
\ Category: Screen mode
\ Summary: VDU commands for changing to a standard mode 4 screen
\
\ ------------------------------------------------------------------------------
\
\ This block contains the bytes that get written by OSWRCH to set up the screen
\ mode (this is equivalent to using the VDU statement in BASIC).
\
\ The Electron version of Elite is unique in that it uses a standard mode 4
\ screen, rather than the custom square mode used in the BBC versions. This is
\ because the Electron lacks the 6845 CRTC chip, which the BBC versions use to
\ customise the mode.
\
\ To make the Electron screen appear square like the BBC versions, there is a
\ blank 32-byte (&20-byte) margin on each end of each character row, so each
\ character row consists of 32 blank bytes on the left, then a page (256 bytes)
\ of screen memory containing the game display, then another 32 blank bytes on
\ the right. Screen memory is from &5800 to &7FFF, and the bottom row from &7EC0
\ to &7FFF is left blank, again to be consistent with look of the BBC version.
\ This means the screen takes up more memory on the Electron version than on the
\ BBC versions, despite showing the same amount of content.
\
\ On top of this, the Electron also lacks the Video ULA of the BBC Micro, so the
\ famous split-screen mode of the BBC versions can't be implemented in the
\ Electron version, as the BBC versions reprogram the ULA to create the coloured
\ dashboard. As a result, not only does the Electron suffer from the bigger
\ memory footprint of the screen, it also has to stick to the same palette for
\ the whole screen, so while the space view is the same monochrome mode 4 view
\ as in the BBC versions, the dashboard has to be in the same screen mode, so
\ it's also monochrome (though it has twice the number of horizontal pixels as
\ the four-colour mode 5 dashboard of the BBC versions, so it is noticeably
\ sharper, at least).
\
\ The following are also set up:
\
\ * The text window is 9 rows high and 15 columns wide, and is at (8, 10)
\
\ * The cursor is disabled
\
\ ******************************************************************************
.B%
EQUB 22, 4 \ Switch to screen mode 4
EQUB 28 \ Define a text window as follows:
EQUB 8, 19, 23, 10 \
\ * Left = 8
\ * Right = 23
\ * Top = 10
\ * Bottom = 19
\
\ i.e. 9 rows high, 15 columns wide at (8, 10)
EQUB 23, 1, 0, 0 \ Disable the cursor
EQUB 0, 0, 0
EQUB 0, 0, 0
\ ******************************************************************************
\
\ Name: E%
\ Type: Variable
\ Category: Sound
\ Summary: Sound envelope definitions
\
\ ------------------------------------------------------------------------------
\
\ This table contains the sound envelope data, which is passed to OSWORD by the
\ FNE macro to create the four sound envelopes used in-game. Refer to chapter 22
\ of the Acorn Electron User Guide for details of sound envelopes and what all
\ the parameters mean.
\
\ The envelopes are as follows:
\
\ * Envelope 1 is the sound of our own laser firing
\
\ * Envelope 2 is the sound of lasers hitting us, or hyperspace
\
\ * Envelope 3 is the first sound in the two-part sound of us dying, or the
\ second sound in the two-part sound of us making hitting or killing an
\ enemy ship
\
\ * Envelope 4 is the sound of E.C.M. firing
\
\ ******************************************************************************
.E%
EQUB 1, 1, 0, 111, -8, 4, 1, 8, 126, 0, 0, -126, 126, 126
EQUB 2, 1, 14, -18, -1, 44, 32, 50, 6, 1, 0, -2, 120, 126
EQUB 3, 1, 1, -1, -3, 17, 32, 128, 1, 0, 0, -1, 1, 1
EQUB 4, 1, 4, -8, 44, 4, 6, 8, 22, 0, 0, -127, 126, 0
\ ******************************************************************************
\
\ Name: swine
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Resets the machine if the copy protection detects a problem
\
\ ******************************************************************************
.swine
JMP (&FFFC) \ Jump to the address in &FFFC to reset the machine
\ ******************************************************************************
\
\ Name: OSB
\ Type: Subroutine
\ Category: Utility routines
\ Summary: A convenience routine for calling OSBYTE with Y = 0
\
\ ******************************************************************************
.OSB
LDY #0 \ Call OSBYTE with Y = 0, returning from the subroutine
JMP OSBYTE \ using a tail call (so we can call OSB to call OSBYTE
\ for when we know we want Y set to 0)
\ ******************************************************************************
\
\ Name: Authors' names
\ Type: Variable
\ Category: Copy protection
\ Summary: The authors' names, buried in the code
\
\ ------------------------------------------------------------------------------
\
\ Contains the authors' names, plus an unused OS command string that would
\ *RUN the main game code, which isn't what actually happens (so presumably
\ this is to throw the crackers off the scent).
\
\ ******************************************************************************
EQUS "RUN ELITEcode"
EQUB 13
EQUS "By D.Braben/I.Bell"
EQUB 13
EQUB &B0
\ ******************************************************************************
\
\ Name: oscliv
\ Type: Variable
\ Category: Utility routines
\ Summary: Contains the address of OSCLIV, for executing OS commands
\
\ ******************************************************************************
.oscliv
EQUW &FFF7 \ Address of OSCLIV, for executing OS commands
\ (specifically the *LOAD that loads the main game code)
\ ******************************************************************************
\
\ Name: David9
\ Type: Variable
\ Category: Copy protection
\ Summary: Address used as part of the stack-based decryption loop
\
\ ------------------------------------------------------------------------------
\
\ This address is used in the decryption loop starting at David2 in part 4, and
\ is used to jump back into the loop at David5.
\
\ ******************************************************************************
.David9
EQUW David5 \ The address of David5
CLD \ This instruction is not used
\ ******************************************************************************
\
\ Name: David23
\ Type: Variable
\ Category: Copy protection
\ Summary: Address pointer to the start of the 6502 stack
\
\ ------------------------------------------------------------------------------
\
\ This two-byte address points to the start of the 6502 stack, which descends
\ from the end of page 2, less LEN bytes, which comes out as &01DF. So when we
\ push 33 bytes onto the stack (LEN being 33), this address will point to the
\ start of those bytes, which means we can push executable code onto the stack
\ and run it by calling this address with a JMP (David23) instruction. Sneaky
\ stuff!
\
\ ******************************************************************************
.David23
EQUW 6 \ This value is not used in this unprotected version of
\ the loader, though why the crackers set it to 6 is a
\ mystery
\ ******************************************************************************
\
\ Name: doPROT1
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Routine to self-modify the loader code
\
\ ------------------------------------------------------------------------------
\
\ This routine modifies various bits of code in-place as part of the copy
\ protection mechanism. It is called with A = &48 and X = 255.
\
\ ******************************************************************************
.doPROT1
LDY #&DB \ Store &EFDB in TRTB%(1 0) to point to the keyboard
STY TRTB% \ translation table for OS 0.1 (which we will overwrite
LDY #&EF \ with a call to OSBYTE later)
STY TRTB%+1
LDY #2 \ Set the high byte of V219(1 0) to 2
STY V219+1
CMP swine-5,X \ This part of the loader has been disabled by the
\ crackers, by changing an STA to a CMP (as this is an
\ unprotected version)
LDY #&18
STY V219+1,X \ Set the low byte of V219(1 0) to &18 (as X = 255), so
\ V219(1 0) now contains &0218
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: MHCA
\ Type: Variable
\ Category: Copy protection
\ Summary: Used to set one of the vectors in the copy protection code
\
\ ------------------------------------------------------------------------------
\
\ This value is used to set the low byte of BLPTR(1 0), when it's set in PLL1
\ as part of the copy protection.
\
\ ******************************************************************************
.MHCA
EQUB &CA \ The low byte of BLPTR(1 0)
\ ******************************************************************************
\
\ Name: David7
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Part of the multi-jump obfuscation code in PROT1
\
\ ------------------------------------------------------------------------------
\
\ This instruction is part of the multi-jump obfuscation in PROT1 (see part 2 of
\ the loader), which does the following jumps:
\
\ David8 -> FRED1 -> David7 -> Ian1 -> David3
\
\ ******************************************************************************
.David7
BCC Ian1 \ This instruction is part of the multi-jump obfuscation
\ in PROT1
\ ******************************************************************************
\
\ Name: FNE
\ Type: Macro
\ Category: Sound
\ Summary: Macro definition for defining a sound envelope
\
\ ------------------------------------------------------------------------------
\
\ The following macro is used to define the four sound envelopes used in the
\ game. It uses OSWORD 8 to create an envelope using the 14 parameters in the
\ the I%-th block of 14 bytes at location E%. This OSWORD call is the same as
\ BBC BASIC's ENVELOPE command.
\
\ See variable E% for more details of the envelopes themselves.
\
\ ******************************************************************************
MACRO FNE I%
LDX #LO(E%+I%*14) \ Set (Y X) to point to the I%-th set of envelope data
LDY #HI(E%+I%*14) \ in E%
LDA #8 \ Call OSWORD with A = 8 to set up sound envelope I%
JSR OSWORD
ENDMACRO
\ ******************************************************************************
\
\ Name: Elite loader (Part 2 of 5)
\ Type: Subroutine
\ Category: Loader
\ Summary: Perform a number of OS calls, set up sound, push routines on stack
\
\ ------------------------------------------------------------------------------
\
\ This part of the loader does a number of calls to OS routines, sets up the
\ sound envelopes, and pushes 33 bytes onto the stack. A lot of the code in this
\ routine has been removed or hobbled to remove the protection; for a full
\ picture of the protection that's missing, see the source code for the BBC
\ Micro cassette version, which contains almost exactly the same protection code
\ as the original Electron version.
\
\ ******************************************************************************
.ENTRY
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
LDA #&60 \ This appears to be a lone instruction left over from
STA &0088 \ the unprotected code, as this value is never used
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
LDA #&20 \ Set A to the op code for a JSR call with absolute
\ addressing
NOP \ This part of the loader has been disabled by the
\ crackers, as this is an unprotected version
.Ian1
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version
NOP
NOP
NOP
LSR A \ Set A = 16
LDX #3 \ Set the high bytes of BLPTR(1 0), BLN(1 0) and
STX BLPTR+1 \ EXCN(1 0) to &3. We will fill in the high bytes in
STX BLN+1 \ the PLL1 routine, and will then use these values in
STX EXCN+1 \ the IRQ1 handler
LDX #0 \ Call OSBYTE with A = 16 and X = 0 to set the joystick
LDY #0 \ port to sample 0 channels (i.e. disable it)
JSR OSBYTE
LDX #255 \ Call doPROT1 to change an instruction in the PROT1
LDA #&95 \ routine and set up another couple of variables
JSR doPROT1
LDA #144 \ Call OSBYTE with A = 144, X = 255 and Y = 0 to move
JSR OSB \ the screen down one line and turn screen interlace on
EQUB &2C \ Skip the next instruction by turning it into
\ &2C &D0 &92, or BIT &92D0, which does nothing apart
\ from affect the flags
.FRED1
BNE David7 \ This instruction is skipped if we came from above,
\ otherwise this is part of the multi-jump obfuscation
\ in PROT1
LDA #247 \ Call OSBYTE with A = 247 and X = Y = 0 to disable the
LDX #0 \ BREAK intercept code by poking 0 into the first value
JSR OSB
LDA #143 \ Call OSBYTE 143 to issue a paged ROM service call of
LDX #&C \ type &C with argument &FF, which is the "NMI claim"
LDY #&FF \ service call that asks the current user of the NMI
JSR OSBYTE \ space to clear it out
LDA #13 \ Set A = 13 for the next OSBYTE call
.abrk
LDX #0 \ Call OSBYTE with A = 13, X = 0 and Y = 0 to disable
JSR OSB \ the "output buffer empty" event
LDA #225 \ Call OSBYTE with A = 225, X = 128 and Y = 0 to set
LDX #128 \ the function keys to return ASCII codes for SHIFT-fn
JSR OSB \ keys (i.e. add 128)
LDA #172 \ Call OSBYTE 172 to read the address of the MOS
LDX #0 \ keyboard translation table into (Y X)
LDY #255
JSR OSBYTE
STX TRTB% \ Store the address of the keyboard translation table in
STY TRTB%+1 \ TRTB%(1 0)
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
LDA #13 \ Call OSBYTE with A = 13, X = 2 and Y = 0 to disable
LDX #2 \ the "character entering keyboard buffer" event
JSR OSB
.OS01
LDX #&FF \ Set the stack pointer to &01FF, which is the standard
TXS \ location for the 6502 stack, so this instruction
\ effectively resets the stack
INX \ Set X = 0, to use as a counter in the following loop
\ The following loop copies the crunchit routine into
\ zero page, though this unprotected version of the
\ loader doesn't call it there, so this has no effect
LDY #0 \ Set a counter in Y for the copy
.David3
LDA crunchit,Y \ Copy the Y-th byte of crunchit
.PROT1
STA TRTB%+2,X \ And store it in the X-th byte of zero page after the
\ TRTB%(1 0) variable
INX \ Increment both byte counters
INY
CPY #33 \ Loop back to copy the next byte until we have copied
BNE David3 \ all 33 bytes
LDA #LO(B%) \ Set the low byte of ZP(1 0) to point to the VDU code
STA ZP \ table at B%
LDA #&95 \ This part of the loader has been disabled by the
BIT PROT1 \ crackers, as this is an unprotected version (the BIT
\ instruction is an STA instruction in the full version,
\ but it has been hobbled here)
LDA #HI(B%) \ Set the high byte of ZP(1 0) to point to the VDU code
STA ZP+1 \ table at B%
LDY #0 \ We are now going to send the N% VDU bytes in the table
\ at B% to OSWRCH to set up the screen mode
.LOOP
LDA (ZP),Y \ Pass the Y-th byte of the B% table to OSWRCH
JSR OSWRCH
INY \ Increment the loop counter
CPY #N% \ Loop back for the next byte until we have done them
BNE LOOP \ all (the number of bytes was set in N% above)
LDA #1 \ This part of the loader has been disabled by the
TAX \ crackers, as this is an unprotected version (the CMP
TAY \ instruction is an STA instruction in the full version,
LDA abrk+1 \ but it has been hobbled here)
CMP (V219),Y
LDA #4 \ Call OSBYTE with A = 4, X = 1 and Y = 0 to disable
JSR OSB \ cursor editing, so the cursor keys return ASCII values
\ and can therefore be used in-game
LDA #9 \ Call OSBYTE with A = 9, X = 0 and Y = 0 to disable
LDX #0 \ flashing colours
JSR OSB
LDA #&6C \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version (the BIT
NOP \ instruction is an STA instruction in the full version,
NOP \ but it has been hobbled here)
BIT &544F
FNE 0 \ Set up sound envelopes 0-3 using the FNE macro
FNE 1
FNE 2
FNE 3
\ ******************************************************************************
\
\ Name: Elite loader (Part 3 of 5)
\ Type: Subroutine
\ Category: Loader
\ Summary: Move recursive tokens and images
\
\ ------------------------------------------------------------------------------
\
\ Move the following memory blocks:
\
\ * WORDS9: move 4 pages (1024 bytes) from &4400 (CODE%) to &0400
\
\ * P.ELITE: move 1 page (256 bytes) from &4F00 (CODE% + &B00) to &5BE0
\
\ * P.A-SOFT: move 1 page (256 bytes) from &5000 (CODE% + &C00) to &5960
\
\ * P.(C)ASFT: move 1 page (256 bytes) from &5100 (CODE% + &D00) to &73A0
\
\ * P.DIALS: move 7 pages (1792 bytes) from &4800 (CODE% + &400) to &7620
\
\ * Move 1 page (256 bytes) from &5615 (UU%) to &0B00-&0BFF
\
\ and call the routine to draw Saturn between P.(C)ASFT and P.DIALS.
\
\ The dashboard image (P.DIALS) is moved into screen memory one page at a time,
\ but not in a contiguous manner - it has to take into account the &20 bytes of
\ blank margin at each edge of the screen (see the description of the screen
\ mode in B% above). So the seven rows of the dashboard are actually moved into
\ screen memory like this:
\
\ 1 page from &4800 to &7620 = &7620
\ 1 page from &4900 to &7720 + &40 = &7760
\ 1 page from &4A00 to &7820 + 2 * &40 = &78A0
\ 1 page from &4B00 to &7920 + 3 * &40 = &79E0
\ 1 page from &4C00 to &7A20 + 4 * &40 = &7B20
\ 1 page from &4D00 to &7B20 + 5 * &40 = &7C60
\ 1 page from &4E00 to &7C20 + 6 * &40 = &7DA0
\
\ See part 1 above for more details on the above files and the locations that
\ they are moved to.
\
\ The code at UU% (see below) forms part of the loader code and is moved before
\ being run, so it's tucked away safely while the main game code is loaded and
\ decrypted.
\
\ In the unprotected version of the loader, the images are encrypted and this
\ part also decrypts them, but this is an unprotected version of the game, so
\ the encryption part of the crunchit routine is disabled.
\
\ ******************************************************************************
LDX #4 \ Set the following:
STX P+1 \
LDA #HI(CODE%) \ P(1 0) = &0400
STA ZP+1 \ ZP(1 0) = CODE%
LDY #0 \ (X Y) = &400 = 1024
LDA #256-232 \
CMP (V219-4,X) \ The CMP instruction is an STA instruction in the
STY ZP \ protected version of the loader, but this version has
STY P \ been hacked to remove the protection, and the crackers
\ just switched the STA to a CMP to disable this bit of
\ the protection code
JSR crunchit \ Call crunchit to move &400 bytes from CODE% to &0400.
\ We loaded WORDS9.bin to CODE% in part 1, so this moves
\ WORDS9
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&B) \
STA ZP+1 \ P(1 0) = &5BE0
LDA #&5B \ ZP(1 0) = CODE% + &B
STA P+1 \ (X Y) = &100 = 256
LDA #&E0
STA P
LDY #0
JSR crunchit \ Call crunchit to move &100 bytes from CODE% + &B to
\ &5BE0, so this moves P.ELITE
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&C) \
STA ZP+1 \ P(1 0) = &5960
LDA #&59 \ ZP(1 0) = CODE% + &C
STA P+1 \ (X Y) = &100 = 256
LDA #&60
STA P
LDY #0
JSR crunchit \ Call crunchit to move &100 bytes from CODE% + &C to
\ &5960, so this moves P.A-SOFT
LDX #1 \ Set the following:
LDA #(HI(CODE%)+&D) \
STA ZP+1 \ P(1 0) = &73A0
LDA #&73 \ ZP(1 0) = CODE% + &D
STA P+1 \ (X Y) = &100 = 256
LDA #&A0
STA P
LDY #0
JSR crunchit \ Call crunchit to move &100 bytes from CODE% + &D to
\ &73A0, so this moves P.(C)ASFT
JSR PLL1 \ Call PLL1 to draw Saturn
LDA #(HI(CODE%)+4) \ Set the following:
STA ZP+1 \
LDA #&76 \ P(1 0) = &7620
STA P+1 \ ZP(1 0) = CODE% + &4
LDY #0 \ Y = 0
STY ZP \
LDX #&20 \ Also set BLCNT = 0
STY BLCNT
STX P
.dialsL
LDX #1 \ Set (X Y) = &100 = 256
JSR crunchit \ Call crunchit to move &100 bytes from ZP(1 0) to
\ P(1 0), so this moves P.DIALS one row at a time
CLC \ Set P(1 0) = P(1 0) + &40 to skip the screen margins
LDA P
ADC #&40
STA P
LDA P+1
ADC #0
STA P+1
CMP #&7E \ Loop back to copy the next row of the dashboard until
BCC dialsL \ we have poked the last one into screen memory
LDX #1 \ Set the following:
LDA #HI(UU%) \
STA ZP+1 \ P(1 0) = LE%
LDA #LO(UU%) \ ZP(1 0) = UU%
STA ZP \ (X Y) = &100 = 256
LDA #HI(LE%)
STA P+1
LDY #0
STY P
JSR crunchit \ Call crunchit to move &100 bytes from UU% to LE%
\ ******************************************************************************
\
\ Name: Elite loader (Part 4 of 5)
\ Type: Subroutine
\ Category: Loader
\ Summary: Call part 5 of the loader now that is has been relocated
\
\ ------------------------------------------------------------------------------
\
\ In the protected version of the loader, this part copies more code onto the
\ stack and decrypts a chunk of loader code before calling part 5, but in the
\ unprotected version it's mostly NOPs.
\
\ ******************************************************************************
JMP &0B11 \ Call relocated UU% routine to load the main game code
\ at &2000, move it down to &0D00 and run it
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
.RAND
EQUD &6C785349 \ The random number seed used for drawing Saturn
.David5
NOP \ This part of the loader has been disabled by the
NOP \ crackers, as this is an unprotected version
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
\ ******************************************************************************
\
\ Name: PLL1
\ Type: Subroutine
\ Category: Drawing planets
\ Summary: Draw Saturn on the loading screen
\
\ ------------------------------------------------------------------------------
\
\ Part 1 (PLL1) x 1280 - planet
\
\ * Draw pixels at (x, y) where:
\
\ r1 = random number from 0 to 255
\ r2 = random number from 0 to 255
\ (r1^2 + r1^2) < 128^2
\
\ y = r2, squished into 64 to 191 by negation
\
\ x = SQRT(128^2 - (r1^2 + r1^2)) / 2
\
\ Part 2 (PLL2) x 477 - stars
\
\ * Draw pixels at (x, y) where:
\
\ y = random number from 0 to 255
\ y = random number from 0 to 255
\ (x^2 + y^2) div 256 > 17
\
\ Part 3 (PLL3) x 1280 - rings
\
\ * Draw pixels at (x, y) where:
\
\ r5 = random number from 0 to 255
\ r6 = random number from 0 to 255
\ r7 = r5, squashed into -32 to 31
\
\ 32 <= (r5^2 + r6^2 + r7^2) / 256 <= 79
\ Draw 50% fewer pixels when (r6^2 + r7^2) / 256 <= 16
\
\ x = r5 + r7
\ y = r5
\
\ Draws pixels within the diagonal band of horizontal width 64, from top-left to
\ bottom-right of the screen.
\
\ ******************************************************************************
.PLL1
\ The following loop iterates CNT(1 0) times, i.e. &500
\ or 1280 times, and draws the planet part of the
\ loading screen's Saturn
JSR DORND \ Set A and X to random numbers, say A = r1
JSR SQUA2 \ Set (A P) = A * A
\ = r1^2
STA ZP+1 \ Set ZP(1 0) = (A P)
LDA P \ = r1^2
STA ZP
JSR DORND \ Set A and X to random numbers, say A = r2
STA YY \ Set YY = A
\ = r2
JSR SQUA2 \ Set (A P) = A * A
\ = r2^2
TAX \ Set (X P) = (A P)
\ = r2^2
LDA P \ Set (A ZP) = (X P) + ZP(1 0)
ADC ZP \
STA ZP \ first adding the low bytes
TXA \ And then adding the high bytes
ADC ZP+1
BCS PLC1 \ If the addition overflowed, jump down to PLC1 to skip
\ to the next pixel
STA ZP+1 \ Set ZP(1 0) = (A ZP)
\ = r1^2 + r2^2
LDA #1 \ Set ZP(1 0) = &4001 - ZP(1 0) - (1 - C)
SBC ZP \ = 128^2 - ZP(1 0)
STA ZP \
\ (as the C flag is clear), first subtracting the low
\ bytes
LDA #&40 \ And then subtracting the high bytes
SBC ZP+1
STA ZP+1
BCC PLC1 \ If the subtraction underflowed, jump down to PLC1 to
\ skip to the next pixel
\ If we get here, then both calculations fitted into
\ 16 bits, and we have:
\
\ ZP(1 0) = 128^2 - (r1^2 + r2^2)
\
\ where ZP(1 0) >= 0
JSR ROOT \ Set ZP = SQRT(ZP(1 0))
LDA ZP \ Set X = ZP >> 1
LSR A \ = SQRT(128^2 - (a^2 + b^2)) / 2
TAX
LDA YY \ Set A = YY
\ = r2
CMP #128 \ If YY >= 128, set the C flag (so the C flag is now set
\ to bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 6 and 7 are now the same, i.e. A is a random number in
\ one of these ranges:
\
\ %00000000 - %00111111 = 0 to 63 (r2 = 0 - 127)
\ %11000000 - %11111111 = 192 to 255 (r2 = 128 - 255)
\
\ The PIX routine flips bit 7 of A before drawing, and
\ that makes -A in these ranges:
\
\ %10000000 - %10111111 = 128-191
\ %01000000 - %01111111 = 64-127
\
\ so that's in the range 64 to 191
JSR PIX \ Draw a pixel at screen coordinate (X, -A), i.e. at
\
\ (ZP / 2, -A)
\
\ where ZP = SQRT(128^2 - (r1^2 + r2^2))
\
\ So this is the same as plotting at (x, y) where:
\
\ r1 = random number from 0 to 255
\ r1 = random number from 0 to 255
\ (r1^2 + r1^2) < 128^2
\
\ y = r2, squished into 64 to 191 by negation
\
\ x = SQRT(128^2 - (r1^2 + r1^2)) / 2
\
\ which is what we want
.PLC1
DEC CNT \ Decrement the counter in CNT (the low byte)
BNE PLL1 \ Loop back to PLL1 until CNT = 0
DEC CNT+1 \ Decrement the counter in CNT+1 (the high byte)
BNE PLL1 \ Loop back to PLL1 until CNT+1 = 0
LDX #&C2 \ Set the low byte of EXCN(1 0) to &C2, so we now have
STX EXCN \ EXCN(1 0) = &03C2, which we will use in the IRQ1
\ handler (this has nothing to do with drawing Saturn,
\ it's all part of the copy protection)
LDX #&60 \ This is normally part of the copy protection, but it's
STX &0087 \ been disabled in this unprotected version so this has
\ no effect (though the crackers presumably thought they
\ might as well still set the value just in case)
\ The following loop iterates CNT2(1 0) times, i.e. &1DD
\ or 477 times, and draws the background stars on the
\ loading screen
.PLL2
JSR DORND \ Set A and X to random numbers, say A = r3
TAX \ Set X = A
\ = r3
JSR SQUA2 \ Set (A P) = A * A
\ = r3^2
STA ZP+1 \ Set ZP+1 = A
\ = r3^2 / 256
JSR DORND \ Set A and X to random numbers, say A = r4
STA YY \ Set YY = r4
JSR SQUA2 \ Set (A P) = A * A
\ = r4^2
ADC ZP+1 \ Set A = A + r3^2 / 256
\ = r4^2 / 256 + r3^2 / 256
\ = (r3^2 + r4^2) / 256
CMP #&11 \ If A < 17, jump down to PLC2 to skip to the next pixel
BCC PLC2
LDA YY \ Set A = r4
JSR PIX \ Draw a pixel at screen coordinate (X, -A), i.e. at
\ (r3, -r4), where (r3^2 + r4^2) / 256 >= 17
\
\ Negating a random number from 0 to 255 still gives a
\ random number from 0 to 255, so this is the same as
\ plotting at (x, y) where:
\
\ x = random number from 0 to 255
\ y = random number from 0 to 255
\ (x^2 + y^2) div 256 >= 17
\
\ which is what we want
.PLC2
DEC CNT2 \ Decrement the counter in CNT2 (the low byte)
BNE PLL2 \ Loop back to PLL2 until CNT2 = 0
DEC CNT2+1 \ Decrement the counter in CNT2+1 (the high byte)
BNE PLL2 \ Loop back to PLL2 until CNT2+1 = 0
LDX #&CA \ This is normally part of the copy protection, but it's
NOP \ been disabled in this unprotected version so this has
STX BLPTR \ no effect (though the crackers presumably thought they
LDX #&C6 \ might as well still set the values just in case)
STX BLN
\ The following loop iterates CNT3(1 0) times, i.e. &500
\ or 1280 times, and draws the rings around the loading
\ screen's Saturn
.PLL3
JSR DORND \ Set A and X to random numbers, say A = r5
STA ZP \ Set ZP = r5
JSR SQUA2 \ Set (A P) = A * A
\ = r5^2
STA ZP+1 \ Set ZP+1 = A
\ = r5^2 / 256
JSR DORND \ Set A and X to random numbers, say A = r6
STA YY \ Set YY = r6
JSR SQUA2 \ Set (A P) = A * A
\ = r6^2
STA T \ Set T = A
\ = r6^2 / 256
ADC ZP+1 \ Set ZP+1 = A + r5^2 / 256
STA ZP+1 \ = r6^2 / 256 + r5^2 / 256
\ = (r5^2 + r6^2) / 256
LDA ZP \ Set A = ZP
\ = r5
CMP #128 \ If A >= 128, set the C flag (so the C flag is now set
\ to bit 7 of ZP, i.e. bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 6 and 7 are now the same
CMP #128 \ If A >= 128, set the C flag (so again, the C flag is
\ set to bit 7 of A)
ROR A \ Rotate A and set the sign bit to the C flag, so bits
\ 5-7 are now the same, i.e. A is a random number in one
\ of these ranges:
\
\ %00000000 - %00011111 = 0-31
\ %11100000 - %11111111 = 224-255
\
\ In terms of signed 8-bit integers, this is a random
\ number from -32 to 31. Let's call it r7
ADC YY \ Set X = A + YY
TAX \ = r7 + r6
JSR SQUA2 \ Set (A P) = r7 * r7
TAY \ Set Y = A
\ = r7 * r7 / 256
ADC ZP+1 \ Set A = A + ZP+1
\ = r7^2 / 256 + (r5^2 + r6^2) / 256
\ = (r5^2 + r6^2 + r7^2) / 256
BCS PLC3 \ If the addition overflowed, jump down to PLC3 to skip
\ to the next pixel
CMP #80 \ If A >= 80, jump down to PLC3 to skip to the next
BCS PLC3 \ pixel
CMP #32 \ If A < 32, jump down to PLC3 to skip to the next pixel
BCC PLC3
TYA \ Set A = Y + T
ADC T \ = r7^2 / 256 + r6^2 / 256
\ = (r6^2 + r7^2) / 256
CMP #16 \ If A > 16, skip to PL1 to plot the pixel
BCS PL1
LDA ZP \ If ZP is positive (50% chance), jump down to PLC3 to
BPL PLC3 \ skip to the next pixel
.PL1
LDA YY \ Set A = YY
\ = r6
JSR PIX \ Draw a pixel at screen coordinate (X, -A), where:
\
\ X = (random -32 to 31) + r6
\ A = r6
\
\ Negating a random number from 0 to 255 still gives a
\ random number from 0 to 255, so this is the same as
\ plotting at (x, y) where:
\
\ r5 = random number from 0 to 255
\ r6 = random number from 0 to 255
\ r7 = r5, squashed into -32 to 31
\
\ x = r5 + r7
\ y = r5
\
\ 32 <= (r5^2 + r6^2 + r7^2) / 256 <= 79
\ Draw 50% fewer pixels when (r6^2 + r7^2) / 256 <= 16
\
\ which is what we want
.PLC3
DEC CNT3 \ Decrement the counter in CNT3 (the low byte)
BNE PLL3 \ Loop back to PLL3 until CNT3 = 0
DEC CNT3+1 \ Decrement the counter in CNT3+1 (the high byte)
BNE PLL3 \ Loop back to PLL3 until CNT3+1 = 0
\ ******************************************************************************
\
\ Name: DORND
\ Type: Subroutine
\ Category: Utility routines
\ Summary: Generate random numbers
\ Deep dive: Generating random numbers
\
\ ------------------------------------------------------------------------------
\
\ Set A and X to random numbers. The C and V flags are also set randomly.
\
\ This is a simplified version of the DORND routine in the main game code. It
\ swaps the two calculations around and omits the ROL A instruction, but is
\ otherwise very similar. See the DORND routine in the main game code for more
\ details.
\
\ ******************************************************************************
.DORND
LDA RAND+1 \ r1´ = r1 + r3 + C
TAX \ r3´ = r1
ADC RAND+3
STA RAND+1
STX RAND+3
LDA RAND \ X = r2´ = r0
TAX \ A = r0´ = r0 + r2
ADC RAND+2
STA RAND
STX RAND+2
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: SQUA2
\ Type: Subroutine
\ Category: Maths (Arithmetic)
\ Summary: Calculate (A P) = A * A
\
\ ------------------------------------------------------------------------------
\
\ Do the following multiplication of unsigned 8-bit numbers:
\
\ (A P) = A * A
\
\ This uses the same approach as routine SQUA2 in the main game code, which
\ itself uses the MU11 routine to do the multiplication. See those routines for
\ more details.
\
\ ******************************************************************************
.SQUA2
BPL SQUA \ If A > 0, jump to SQUA
EOR #&FF \ Otherwise we need to negate A for the SQUA algorithm
CLC \ to work, so we do this using two's complement, by
ADC #1 \ setting A = ~A + 1
.SQUA
STA Q \ Set Q = A and P = A
STA P \ Set P = A
LDA #0 \ Set A = 0 so we can start building the answer in A
LDY #8 \ Set up a counter in Y to count the 8 bits in P
LSR P \ Set P = P >> 1
\ and C flag = bit 0 of P
.SQL1
BCC SQ1 \ If C (i.e. the next bit from P) is set, do the
CLC \ addition for this bit of P:
ADC Q \
\ A = A + Q
.SQ1
ROR A \ Shift A right to catch the next digit of our result,
\ which the next ROR sticks into the left end of P while
\ also extracting the next bit of P
ROR P \ Add the overspill from shifting A to the right onto
\ the start of P, and shift P right to fetch the next
\ bit for the calculation into the C flag
DEY \ Decrement the loop counter
BNE SQL1 \ Loop back for the next bit until P has been rotated
\ all the way
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: PIX
\ Type: Subroutine
\ Category: Drawing pixels
\ Summary: Draw a single pixel at a specific coordinate
\ Deep dive: Drawing pixels in the Electron version
\
\ ------------------------------------------------------------------------------
\
\ Draw a pixel at screen coordinate (X, -A). The sign bit of A gets flipped
\ before drawing, and then the routine uses the same approach as the PIXEL
\ routine in the main game code, except it plots a single pixel from TWOS
\ instead of a two pixel dash from TWOS2. This applies to the top part of the
\ screen (the monochrome mode 4 space view).
\ screen (the space view).
\
\ See the PIXEL routine in the main game code for more details.
\
\ Arguments:
\
\ X The screen x-coordinate of the pixel to draw
\
\ A The screen y-coordinate of the pixel to draw, negated
\
\ Other entry points:
\
\ PIX-1 Contains an RTS
\
\ ******************************************************************************
.PIX
LDY #128 \ Set ZP = 128 for use in the calculation below
STY ZP
TAY \ Copy A into Y, for use later
EOR #%10000000 \ Flip the sign of A
CMP #248 \ If the y-coordinate in A >= 248, then this is the
BCS PIX-1 \ bottom row of the screen, which we want to leave blank
\ as it's below the bottom of the dashboard, so return
\ from the subroutine (as PIX-1 contains an RTS)
\ We now calculate the address of the character block
\ containing the pixel (x, y) and put it in ZP(1 0), as
\ follows:
\
\ ZP = &5800 + (y div 8 * 256) + (y div 8 * 64) + 32
\
\ See the deep dive on "Drawing pixels in the Electron
\ version" for details
LSR A \ Set A = A >> 3
LSR A \ = y div 8
LSR A \ = character row number
\ Also, as ZP = 128, we have:
\
\ (A ZP) = (A 128)
\ = (A * 256) + 128
\ = 4 * ((A * 64) + 32)
\ = 4 * ((char row * 64) + 32)
STA ZP+1 \ Set ZP+1 = A, so (ZP+1 0) = A * 256
\ = char row * 256
LSR A \ Set (A ZP) = (A ZP) / 4
ROR ZP \ = (4 * ((char row * 64) + 32)) / 4
LSR A \ = char row * 64 + 32
ROR ZP
ADC ZP+1 \ Set ZP(1 0) = (A ZP) + (ZP+1 0) + &5800
ADC #&58 \ = (char row * 64 + 32)
STA ZP+1 \ + char row * 256
\ + &5800
\
\ which is what we want, so ZP(1 0) contains the address
\ of the first visible pixel on the character row
\ containing the point (x, y)
TXA \ To get the address of the character block on this row
EOR #%10000000 \ that contains (x, y):
AND #%11111000 \
ADC ZP \ ZP(1 0) = ZP(1 0) + (X >> 3) * 8
STA ZP
BCC P%+4 \ If the addition of the low bytes overflowed, increment
INC ZP+1 \ the high byte
\ So ZP(1 0) now contains the address of the first pixel
\ in the character block containing the (x, y), taking
\ the screen borders into consideration
TYA \ Set Y = Y AND %111
AND #%00000111
TAY
TXA \ Set X = X AND %111
AND #%00000111
TAX
LDA TWOS,X \ Fetch a pixel from TWOS and OR it into ZP+Y
ORA (ZP),Y
STA (ZP),Y
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: TWOS
\ Type: Variable
\ Category: Drawing pixels
\ Summary: Ready-made single-pixel character row bytes for mode 4
\
\ ------------------------------------------------------------------------------
\
\ Ready-made bytes for plotting one-pixel points in mode 4 (the top part of the
\ split screen). See the PIX routine for details.
\
\ ******************************************************************************
.TWOS
EQUB %10000000
EQUB %01000000
EQUB %00100000
EQUB %00010000
EQUB %00001000
EQUB %00000100
EQUB %00000010
EQUB %00000001
\ ******************************************************************************
\
\ Name: CNT
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's planetary body
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL1 loop, which draws the planet part
\ of the loading screen's Saturn.
\
\ ******************************************************************************
.CNT
EQUW &0500 \ The number of iterations of the PLL1 loop (1280)
\ ******************************************************************************
\
\ Name: CNT2
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's background stars
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL2 loop, which draws the background
\ stars on the loading screen.
\
\ ******************************************************************************
.CNT2
EQUW &01DD \ The number of iterations of the PLL2 loop (477)
\ ******************************************************************************
\
\ Name: CNT3
\ Type: Variable
\ Category: Drawing planets
\ Summary: A counter for use in drawing Saturn's rings
\
\ ------------------------------------------------------------------------------
\
\ Defines the number of iterations of the PLL3 loop, which draws the rings
\ around the loading screen's Saturn.
\
\ ******************************************************************************
.CNT3
EQUW &0500 \ The number of iterations of the PLL3 loop (1280)
\ ******************************************************************************
\
\ Name: ROOT
\ Type: Subroutine
\ Category: Maths (Arithmetic)
\ Summary: Calculate ZP = SQRT(ZP(1 0))
\
\ ------------------------------------------------------------------------------
\
\ Calculate the following square root:
\
\ ZP = SQRT(ZP(1 0))
\
\ This routine is identical to LL5 in the main game code - it even has the same
\ label names. The only difference is that LL5 calculates Q = SQRT(R Q), but
\ apart from the variables used, the instructions are identical, so see the LL5
\ routine in the main game code for more details on the algorithm used here.
\
\ ******************************************************************************
.ROOT
LDY ZP+1 \ Set (Y Q) = ZP(1 0)
LDA ZP
STA Q
\ So now to calculate ZP = SQRT(Y Q)
LDX #0 \ Set X = 0, to hold the remainder
STX ZP \ Set ZP = 0, to hold the result
LDA #8 \ Set P = 8, to use as a loop counter
STA P
.LL6
CPX ZP \ If X < ZP, jump to LL7
BCC LL7
BNE LL8 \ If X > ZP, jump to LL8
CPY #64 \ If Y < 64, jump to LL7 with the C flag clear,
BCC LL7 \ otherwise fall through into LL8 with the C flag set
.LL8
TYA \ Set Y = Y - 64
SBC #64 \
TAY \ This subtraction will work as we know C is set from
\ the BCC above, and the result will not underflow as we
\ already checked that Y >= 64, so the C flag is also
\ set for the next subtraction
TXA \ Set X = X - ZP
SBC ZP
TAX
.LL7
ROL ZP \ Shift the result in Q to the left, shifting the C flag
\ into bit 0 and bit 7 into the C flag
ASL Q \ Shift the dividend in (Y S) to the left, inserting
TYA \ bit 7 from above into bit 0
ROL A
TAY
TXA \ Shift the remainder in X to the left
ROL A
TAX
ASL Q \ Shift the dividend in (Y S) to the left
TYA
ROL A
TAY
TXA \ Shift the remainder in X to the left
ROL A
TAX
DEC P \ Decrement the loop counter
BNE LL6 \ Loop back to LL6 until we have done 8 loops
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: crunchit
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Multi-byte decryption and copying routine
\
\ ------------------------------------------------------------------------------
\
\ In the unprotected version of the loader on this site, this routine just moves
\ data frommone location to another. In the protected version, it also decrypts
\ the data as it is moved, but that part is disabled in the following.
\
\ Arguments:
\
\ (X Y) The number of bytes to copy
\
\ ZP(1 0) The source address
\
\ P(1 0) The destination address
\
\ ******************************************************************************
.crunchit
LDA (ZP),Y \ Copy the Y-th byte of ZP(1 0) to the Y-th byte of
NOP \ P(1 0), without any decryption (hence the NOPs)
NOP
NOP
STA (P),Y
DEY \ Decrement the byte counter
BNE crunchit \ Loop back to crunchit to copy the next byte until we
\ have done a whole page
INC P+1 \ Increment the high bytes of the source and destination
INC ZP+1 \ addresses so we can copy the next page
DEX \ Decrement the page counter
BNE crunchit \ Loop back to crunchit to copy the next page until we
\ have done X pages
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: BEGIN%
\ Type: Subroutine
\ Category: Copy protection
\ Summary: Single-byte decryption and copying routine, run on the stack
\
\ ------------------------------------------------------------------------------
\
\ This code is not run in the unprotected version of the loader. In the full
\ version it is stored with the instructions reversed so it can be copied onto
\ the stack to be run, and it doesn't contain any NOPs, so this is presumably a
\ remnant of the cracking process.
\
\ ******************************************************************************
PLA
PLA
LDA &0C24,Y
PHA
EOR &0B3D,Y
NOP
NOP
NOP
JMP (David9)
\ ******************************************************************************
\
\ Name: UU%
\ Type: Workspace
\ Address: &0B00
\ Category: Workspaces
\ Summary: Marker for a block that is moved as part of the obfuscation
\
\ ------------------------------------------------------------------------------
\
\ The code from here to the end of the file gets copied to &0B00 (LE%) by part
\ 3. It is called from part 4.
\
\ ******************************************************************************
.UU%
Q% = P% - LE%
ORG LE%
\ ******************************************************************************
\
\ Name: Elite loader (Part 5 of 5)
\ Type: Subroutine
\ Category: Loader
\ Summary: Set up interrupt vectors, calculate checksums, run main game code
\
\ ------------------------------------------------------------------------------
\
\ This is the final part of the loader. It sets up some of the main game's
\ interrupt vectors and calculates various checksums, before finally handing
\ over to the main game.
\
\ ******************************************************************************
EQUD &10101010 \ This data appears to be unused
EQUD &10101010
EQUD &10101010
EQUD &10101010
EQUB &10
.ENTRY2
LDX #LO(MESS1) \ Set (Y X) to point to MESS1 ("LOAD EliteCo FFFF2000")
LDY #HI(MESS1)
JSR OSCLI \ Call OSCLI to run the OS command in MESS1, which loads
\ the maon game code at location &2000
LDA #3 \ Directly update &0258, the memory location associated
STA &0258 \ with OSBYTE 200, so this is the same as calling OSBYTE
\ with A = 200, X = 3 and Y = 0 to disable the ESCAPE
\ key and clear memory if the BREAK key is pressed
LDA #140 \ Call OSBYTE with A = 140 and X = 12 to select the
LDX #12 \ tape filing system (i.e. do a *TAPE command)
LDY #0
JSR OSBYTE
LDA #143 \ Call OSBYTE 143 to issue a paged ROM service call of
LDX #&C \ type &C with argument &FF, which is the "NMI claim"
LDY #&FF \ service call that asks the current user of the NMI
JSR OSBYTE \ space to clear it out
LDA #&40 \ Set S% to an RTI instruction (opcode &40), so we can
STA S% \ claim the NMI workspace at &0D00 (the RTI makes sure
\ we return from any spurious NMIs that still call this
\ workspace)
LDX #&4A \ Set X = &4A, as we want to copy the &4A pages of main
\ game code from where we just loaded it at &2000, down
\ to &0D00 where we will run it
LDY #0 \ Set the source and destination addresses for the copy:
STY ZP \
STY P \ ZP(1 0) = L% = &2000
LDA #HI(L%) \ P(1 0) = C% = &0D00
STA ZP+1 \
LDA #HI(C%) \ and set Y = 0 to act as a byte counter in the
STA P+1 \ following loop
.MVDL
LDA (ZP),Y \ Copy the Y-th byte from the source to the Y-th byte of
STA (P),Y \ the destination
LDA #0 \ Zero the source byte we just copied, so that this loop
STA (ZP),Y \ moves the memory block rather than copying it
INY \ Increment the byte counter
BNE MVDL \ Loop back until we have copied a whole page of bytes
INC ZP+1 \ Increment the high bytes of ZP(1 0) and P(1 0) so we
INC P+1 \ copy bytes from the next page in memory
DEX \ Decrement the page counter in X
BPL MVDL \ Loop back to move the next page of bytes until we have
\ moved the number of pages in X (this also sets X to
\ &FF)
SEI \ Disable all interrupts
TXS \ Set the stack pointer to &01FF, which is the standard
\ location for the 6502 stack, so this instruction
\ effectively resets the stack
LDA RDCHV \ Set the user vector USERV to the same value as the
STA USERV \ read character vector RDCHV
LDA RDCHV+1
STA USERV+1
LDA KEYV \ Store the current value of the keyboard vector KEYV
STA S%+4 \ in S%+4
LDA KEYV+1
STA S%+5
LDA #LO(S%+16) \ Point the keyboard vector KEYV to S%+16 in the main
STA KEYV \ game code
LDA #HI(S%+16)
STA KEYV+1
LDA S%+14 \ Point the break vector BRKV to the address stored in
STA BRKV \ S%+14 in the main game code
LDA S%+15
STA BRKV+1
LDA S%+10 \ Point the write character vector WRCHV to the address
STA WRCHV \ stored in S%+10 in the main game code
LDA S%+11
STA WRCHV+1
LDA IRQ1V \ Store the current value of the interrupt vector IRQ1V
STA S%+2 \ in S%+2
LDA IRQ1V+1
STA S%+3
LDA S%+12 \ Point the interrupt vector IRQ1V to the address stored
STA IRQ1V \ in S%+12 in the main game code
LDA S%+13
STA IRQ1V+1
LDA #%11111100 \ Clear all interrupts (bits 4-7) and de-select the
JSR VIA05 \ BASIC ROM (bit 3) by setting the interrupt clear and
\ paging register at SHEILA &05
LDA #%00001000 \ Select ROM 8 (the keyboard) by setting the interrupt
JSR VIA05 \ clear and paging register at SHEILA &05
LDA #&60 \ Set the screen start address registers at SHEILA &02
STA VIA+&02 \ and SHEILA &03 so screen memory starts at &7EC0. This
LDA #&3F \ gives us a blank line at the top of the screen (for
STA VIA+&03 \ the screen memory between &7EC0 and &7FFF, as one row
\ of mode 4 is &140 bytes), and then the rest of the
\ screen memory from &5800 to &7EBF cover the second
\ row and down
CLI \ Re-enable interrupts
JMP (S%+8) \ Jump to the address in S%+8 in the main game code,
\ which points to TT170, so this starts the game
.VIA05
STA &00F4 \ Store A in &00F4
STA VIA+&05 \ Set the value of the interrupt clear and paging
\ register at SHEILA &05 to A
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: MESS1
\ Type: Variable
\ Category: Utility routines
\ Summary: Contains an OS command string for loading the main game code
\
\ ******************************************************************************
.MESS1
EQUS "LOAD EliteCo FFFF2000"
EQUB 13
SKIP 13 \ These bytes appear to be unused
\ ******************************************************************************
\
\ Save output/ELITE.unprot.bin
\
\ ******************************************************************************
COPYBLOCK LE%, P%, UU% \ Copy the block that we assembled at LE% to UU%, which
\ is where it will actually run
PRINT "S.ELITEDA ", ~CODE%, " ", ~UU% + (P% - LE%), " ", ~run, " ", ~CODE%
SAVE "output/ELITEDA.bin", CODE%, UU% + (P% - LE%), run, CODE%
|
/*************************************************************************/
/* default_theme.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* 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 "default_theme.h"
#include "scene/resources/theme.h"
#include "core/os/os.h"
#include "theme_data.h"
#include "font_hidpi.inc"
#include "font_lodpi.inc"
typedef Map<const void *, Ref<ImageTexture> > TexCacheMap;
static TexCacheMap *tex_cache;
static float scale = 1;
template <class T>
static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
Ref<ImageTexture> texture;
if (tex_cache->has(p_src)) {
texture = (*tex_cache)[p_src];
} else {
texture = Ref<ImageTexture>(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
if (scale > 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->expand_x2_hq2x();
if (scale != 2.0) {
img->resize(orig_size.x * scale, orig_size.y * scale);
}
} else if (scale < 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
}
texture->create_from_image(img, ImageTexture::FLAG_FILTER);
(*tex_cache)[p_src] = texture;
}
Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
style->set_texture(texture);
style->set_margin_size(MARGIN_LEFT, p_left * scale);
style->set_margin_size(MARGIN_RIGHT, p_right * scale);
style->set_margin_size(MARGIN_BOTTOM, p_botton * scale);
style->set_margin_size(MARGIN_TOP, p_top * scale);
style->set_default_margin(MARGIN_LEFT, p_margin_left * scale);
style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale);
style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale);
style->set_default_margin(MARGIN_TOP, p_margin_top * scale);
style->set_draw_center(p_draw_center);
return style;
}
static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left, float p_top, float p_right, float p_botton) {
p_sbox->set_expand_margin_size(MARGIN_LEFT, p_left * scale);
p_sbox->set_expand_margin_size(MARGIN_TOP, p_top * scale);
p_sbox->set_expand_margin_size(MARGIN_RIGHT, p_right * scale);
p_sbox->set_expand_margin_size(MARGIN_BOTTOM, p_botton * scale);
return p_sbox;
}
template <class T>
static Ref<Texture> make_icon(T p_src) {
Ref<ImageTexture> texture(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
if (scale > 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->expand_x2_hq2x();
if (scale != 2.0) {
img->resize(orig_size.x * scale, orig_size.y * scale);
}
} else if (scale < 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
}
texture->create_from_image(img, ImageTexture::FLAG_FILTER);
return texture;
}
static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, const int *p_char_rects, int p_kerning_count, const int *p_kernings, int p_w, int p_h, const unsigned char *p_img) {
Ref<BitmapFont> font(memnew(BitmapFont));
Ref<Image> image = memnew(Image(p_img));
Ref<ImageTexture> tex = memnew(ImageTexture);
tex->create_from_image(image);
font->add_texture(tex);
for (int i = 0; i < p_charcount; i++) {
const int *c = &p_char_rects[i * 8];
int chr = c[0];
Rect2 frect;
frect.position.x = c[1];
frect.position.y = c[2];
frect.size.x = c[3];
frect.size.y = c[4];
Point2 align(c[6], c[5]);
int advance = c[7];
font->add_char(chr, 0, frect, align, advance);
}
for (int i = 0; i < p_kerning_count; i++) {
font->add_kerning_pair(p_kernings[i * 3 + 0], p_kernings[i * 3 + 1], p_kernings[i * 3 + 2]);
}
font->set_height(p_height);
font->set_ascent(p_ascent);
return font;
}
static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1) {
Ref<StyleBox> style(memnew(StyleBoxEmpty));
style->set_default_margin(MARGIN_LEFT, p_margin_left * scale);
style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale);
style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale);
style->set_default_margin(MARGIN_TOP, p_margin_top * scale);
return style;
}
void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
scale = p_scale;
tex_cache = memnew(TexCacheMap);
// Font Colors
Color control_font_color = Color::html("e0e0e0");
Color control_font_color_lower = Color::html("a0a0a0");
Color control_font_color_low = Color::html("b0b0b0");
Color control_font_color_hover = Color::html("f0f0f0");
Color control_font_color_disabled = Color(0.9, 0.9, 0.9, 0.2);
Color control_font_color_pressed = Color::html("ffffff");
Color font_color_selection = Color::html("7d7d7d");
// Panel
theme->set_stylebox("panel", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
// Focus
Ref<StyleBoxTexture> focus = make_stylebox(focus_png, 5, 5, 5, 5);
for (int i = 0; i < 4; i++) {
focus->set_expand_margin_size(Margin(i), 1 * scale);
}
// Button
Ref<StyleBox> sb_button_normal = sb_expand(make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 3, 6, 3), 2, 2, 2, 2);
Ref<StyleBox> sb_button_pressed = sb_expand(make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 3, 6, 3), 2, 2, 2, 2);
Ref<StyleBox> sb_button_hover = sb_expand(make_stylebox(button_hover_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_button_disabled = sb_expand(make_stylebox(button_disabled_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_button_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
theme->set_stylebox("normal", "Button", sb_button_normal);
theme->set_stylebox("pressed", "Button", sb_button_pressed);
theme->set_stylebox("hover", "Button", sb_button_hover);
theme->set_stylebox("disabled", "Button", sb_button_disabled);
theme->set_stylebox("focus", "Button", sb_button_focus);
theme->set_font("font", "Button", default_font);
theme->set_color("font_color", "Button", control_font_color);
theme->set_color("font_color_pressed", "Button", control_font_color_pressed);
theme->set_color("font_color_hover", "Button", control_font_color_hover);
theme->set_color("font_color_disabled", "Button", control_font_color_disabled);
theme->set_constant("hseparation", "Button", 2 * scale);
// LinkButton
theme->set_stylebox("focus", "LinkButton", focus);
theme->set_font("font", "LinkButton", default_font);
theme->set_color("font_color", "LinkButton", control_font_color);
theme->set_color("font_color_pressed", "LinkButton", control_font_color_pressed);
theme->set_color("font_color_hover", "LinkButton", control_font_color_hover);
theme->set_constant("underline_spacing", "LinkButton", 2 * scale);
// ColorPickerButton
theme->set_stylebox("normal", "ColorPickerButton", sb_button_normal);
theme->set_stylebox("pressed", "ColorPickerButton", sb_button_pressed);
theme->set_stylebox("hover", "ColorPickerButton", sb_button_hover);
theme->set_stylebox("disabled", "ColorPickerButton", sb_button_disabled);
theme->set_stylebox("focus", "ColorPickerButton", sb_button_focus);
theme->set_font("font", "ColorPickerButton", default_font);
theme->set_color("font_color", "ColorPickerButton", Color(1, 1, 1, 1));
theme->set_color("font_color_pressed", "ColorPickerButton", Color(0.8, 0.8, 0.8, 1));
theme->set_color("font_color_hover", "ColorPickerButton", Color(1, 1, 1, 1));
theme->set_color("font_color_disabled", "ColorPickerButton", Color(0.9, 0.9, 0.9, 0.3));
theme->set_constant("hseparation", "ColorPickerButton", 2 * scale);
// ToolButton
theme->set_stylebox("normal", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("pressed", "ToolButton", make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("hover", "ToolButton", make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 4, 6, 4));
theme->set_stylebox("disabled", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
theme->set_stylebox("focus", "ToolButton", focus);
theme->set_font("font", "ToolButton", default_font);
theme->set_color("font_color", "ToolButton", control_font_color);
theme->set_color("font_color_pressed", "ToolButton", control_font_color_pressed);
theme->set_color("font_color_hover", "ToolButton", control_font_color_hover);
theme->set_color("font_color_disabled", "ToolButton", Color(0.9, 0.95, 1, 0.3));
theme->set_constant("hseparation", "ToolButton", 3);
// OptionButton
Ref<StyleBox> sb_optbutton_normal = sb_expand(make_stylebox(option_button_normal_png, 4, 4, 21, 4, 6, 3, 21, 3), 2, 2, 2, 2);
Ref<StyleBox> sb_optbutton_pressed = sb_expand(make_stylebox(option_button_pressed_png, 4, 4, 21, 4, 6, 3, 21, 3), 2, 2, 2, 2);
Ref<StyleBox> sb_optbutton_hover = sb_expand(make_stylebox(option_button_hover_png, 4, 4, 21, 4, 6, 2, 21, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_optbutton_disabled = sb_expand(make_stylebox(option_button_disabled_png, 4, 4, 21, 4, 6, 2, 21, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_optbutton_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
theme->set_stylebox("normal", "OptionButton", sb_optbutton_normal);
theme->set_stylebox("pressed", "OptionButton", sb_optbutton_pressed);
theme->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
theme->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
theme->set_stylebox("focus", "OptionButton", sb_optbutton_focus);
theme->set_icon("arrow", "OptionButton", make_icon(option_arrow_png));
theme->set_font("font", "OptionButton", default_font);
theme->set_color("font_color", "OptionButton", control_font_color);
theme->set_color("font_color_pressed", "OptionButton", control_font_color_pressed);
theme->set_color("font_color_hover", "OptionButton", control_font_color_hover);
theme->set_color("font_color_disabled", "OptionButton", control_font_color_disabled);
theme->set_constant("hseparation", "OptionButton", 2 * scale);
theme->set_constant("arrow_margin", "OptionButton", 2 * scale);
// MenuButton
theme->set_stylebox("normal", "MenuButton", sb_button_normal);
theme->set_stylebox("pressed", "MenuButton", sb_button_pressed);
theme->set_stylebox("hover", "MenuButton", sb_button_hover);
theme->set_stylebox("disabled", "MenuButton", sb_button_disabled);
theme->set_stylebox("focus", "MenuButton", sb_button_focus);
theme->set_font("font", "MenuButton", default_font);
theme->set_color("font_color", "MenuButton", control_font_color);
theme->set_color("font_color_pressed", "MenuButton", control_font_color_pressed);
theme->set_color("font_color_hover", "MenuButton", control_font_color_hover);
theme->set_color("font_color_disabled", "MenuButton", Color(1, 1, 1, 0.3));
theme->set_constant("hseparation", "MenuButton", 3 * scale);
// ButtonGroup
theme->set_stylebox("panel", "ButtonGroup", memnew(StyleBoxEmpty));
// CheckBox
Ref<StyleBox> cbx_empty = memnew(StyleBoxEmpty);
cbx_empty->set_default_margin(MARGIN_LEFT, 4 * scale);
cbx_empty->set_default_margin(MARGIN_RIGHT, 4 * scale);
cbx_empty->set_default_margin(MARGIN_TOP, 4 * scale);
cbx_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale);
Ref<StyleBox> cbx_focus = focus;
cbx_focus->set_default_margin(MARGIN_LEFT, 4 * scale);
cbx_focus->set_default_margin(MARGIN_RIGHT, 4 * scale);
cbx_focus->set_default_margin(MARGIN_TOP, 4 * scale);
cbx_focus->set_default_margin(MARGIN_BOTTOM, 4 * scale);
theme->set_stylebox("normal", "CheckBox", cbx_empty);
theme->set_stylebox("pressed", "CheckBox", cbx_empty);
theme->set_stylebox("disabled", "CheckBox", cbx_empty);
theme->set_stylebox("hover", "CheckBox", cbx_empty);
theme->set_stylebox("hover_pressed", "CheckBox", cbx_empty);
theme->set_stylebox("focus", "CheckBox", cbx_focus);
theme->set_icon("checked", "CheckBox", make_icon(checked_png));
theme->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
theme->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
theme->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
theme->set_font("font", "CheckBox", default_font);
theme->set_color("font_color", "CheckBox", control_font_color);
theme->set_color("font_color_pressed", "CheckBox", control_font_color_pressed);
theme->set_color("font_color_hover", "CheckBox", control_font_color_hover);
theme->set_color("font_color_hover_pressed", "CheckBox", control_font_color_pressed);
theme->set_color("font_color_disabled", "CheckBox", control_font_color_disabled);
theme->set_constant("hseparation", "CheckBox", 4 * scale);
theme->set_constant("check_vadjust", "CheckBox", 0 * scale);
// CheckButton
Ref<StyleBox> cb_empty = memnew(StyleBoxEmpty);
cb_empty->set_default_margin(MARGIN_LEFT, 6 * scale);
cb_empty->set_default_margin(MARGIN_RIGHT, 6 * scale);
cb_empty->set_default_margin(MARGIN_TOP, 4 * scale);
cb_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale);
theme->set_stylebox("normal", "CheckButton", cb_empty);
theme->set_stylebox("pressed", "CheckButton", cb_empty);
theme->set_stylebox("disabled", "CheckButton", cb_empty);
theme->set_stylebox("hover", "CheckButton", cb_empty);
theme->set_stylebox("hover_pressed", "CheckButton", cb_empty);
theme->set_stylebox("focus", "CheckButton", focus);
theme->set_icon("on", "CheckButton", make_icon(toggle_on_png));
theme->set_icon("off", "CheckButton", make_icon(toggle_off_png));
theme->set_font("font", "CheckButton", default_font);
theme->set_color("font_color", "CheckButton", control_font_color);
theme->set_color("font_color_pressed", "CheckButton", control_font_color_pressed);
theme->set_color("font_color_hover", "CheckButton", control_font_color_hover);
theme->set_color("font_color_hover_pressed", "CheckButton", control_font_color_pressed);
theme->set_color("font_color_disabled", "CheckButton", control_font_color_disabled);
theme->set_constant("hseparation", "CheckButton", 4 * scale);
theme->set_constant("check_vadjust", "CheckButton", 0 * scale);
// Label
theme->set_stylebox("normal", "Label", memnew(StyleBoxEmpty));
theme->set_font("font", "Label", default_font);
theme->set_color("font_color", "Label", Color(1, 1, 1));
theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
theme->set_color("font_outline_modulate", "Label", Color(1, 1, 1));
theme->set_constant("shadow_offset_x", "Label", 1 * scale);
theme->set_constant("shadow_offset_y", "Label", 1 * scale);
theme->set_constant("shadow_as_outline", "Label", 0 * scale);
theme->set_constant("line_spacing", "Label", 3 * scale);
// LineEdit
theme->set_stylebox("normal", "LineEdit", make_stylebox(line_edit_png, 5, 5, 5, 5));
theme->set_stylebox("focus", "LineEdit", focus);
theme->set_stylebox("read_only", "LineEdit", make_stylebox(line_edit_disabled_png, 6, 6, 6, 6));
theme->set_font("font", "LineEdit", default_font);
theme->set_color("font_color", "LineEdit", control_font_color);
theme->set_color("font_color_selected", "LineEdit", Color(0, 0, 0));
theme->set_color("cursor_color", "LineEdit", control_font_color_hover);
theme->set_color("selection_color", "LineEdit", font_color_selection);
theme->set_color("clear_button_color", "LineEdit", control_font_color);
theme->set_color("clear_button_color_pressed", "LineEdit", control_font_color_pressed);
theme->set_constant("minimum_spaces", "LineEdit", 12 * scale);
theme->set_icon("clear", "LineEdit", make_icon(line_edit_clear_png));
// ProgressBar
theme->set_stylebox("bg", "ProgressBar", make_stylebox(progress_bar_png, 4, 4, 4, 4, 0, 0, 0, 0));
theme->set_stylebox("fg", "ProgressBar", make_stylebox(progress_fill_png, 6, 6, 6, 6, 2, 1, 2, 1));
theme->set_font("font", "ProgressBar", default_font);
theme->set_color("font_color", "ProgressBar", control_font_color_hover);
theme->set_color("font_color_shadow", "ProgressBar", Color(0, 0, 0));
// TextEdit
theme->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3, 0, 0, 0, 0));
theme->set_stylebox("focus", "TextEdit", focus);
theme->set_stylebox("read_only", "TextEdit", make_stylebox(tree_bg_disabled_png, 4, 4, 4, 4, 0, 0, 0, 0));
theme->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3, 0, 0, 0, 0));
theme->set_icon("tab", "TextEdit", make_icon(tab_png));
theme->set_font("font", "TextEdit", default_font);
theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
theme->set_color("completion_background_color", "TextEdit", Color::html("2C2A32"));
theme->set_color("completion_selected_color", "TextEdit", Color::html("434244"));
theme->set_color("completion_existing_color", "TextEdit", Color::html("21dfdfdf"));
theme->set_color("completion_scroll_color", "TextEdit", control_font_color_pressed);
theme->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa"));
theme->set_color("font_color", "TextEdit", control_font_color);
theme->set_color("font_color_selected", "TextEdit", Color(0, 0, 0));
theme->set_color("selection_color", "TextEdit", font_color_selection);
theme->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4));
theme->set_color("breakpoint_color", "TextEdit", Color(0.8, 0.8, 0.4, 0.2));
theme->set_color("code_folding_color", "TextEdit", Color(0.8, 0.8, 0.8, 0.8));
theme->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8));
theme->set_color("caret_color", "TextEdit", control_font_color);
theme->set_color("caret_background_color", "TextEdit", Color::html("000000"));
theme->set_color("symbol_color", "TextEdit", control_font_color_hover);
theme->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
theme->set_color("line_number_color", "TextEdit", Color::html("66aaaaaa"));
theme->set_color("safe_line_number_color", "TextEdit", Color::html("99aac8aa"));
theme->set_color("function_color", "TextEdit", Color::html("66a2ce"));
theme->set_color("member_variable_color", "TextEdit", Color::html("e64e59"));
theme->set_color("number_color", "TextEdit", Color::html("EB9532"));
theme->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
theme->set_constant("completion_lines", "TextEdit", 7);
theme->set_constant("completion_max_width", "TextEdit", 50);
theme->set_constant("completion_scroll_width", "TextEdit", 3);
theme->set_constant("line_spacing", "TextEdit", 4 * scale);
Ref<Texture> empty_icon = memnew(ImageTexture);
// HScrollBar
theme->set_stylebox("scroll", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("grabber", "HScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(scroll_grabber_pressed_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_icon("increment", "HScrollBar", empty_icon);
theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
theme->set_icon("decrement", "HScrollBar", empty_icon);
theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
// VScrollBar
theme->set_stylebox("scroll", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("grabber", "VScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(scroll_grabber_pressed_png, 5, 5, 5, 5, 2, 2, 2, 2));
theme->set_icon("increment", "VScrollBar", empty_icon);
theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
theme->set_icon("decrement", "VScrollBar", empty_icon);
theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
// HSlider
theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
theme->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
theme->set_stylebox("focus", "HSlider", focus);
theme->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
theme->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
theme->set_icon("grabber_disabled", "HSlider", make_icon(hslider_grabber_disabled_png));
theme->set_icon("tick", "HSlider", make_icon(hslider_tick_png));
// VSlider
theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
theme->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
theme->set_stylebox("focus", "VSlider", focus);
theme->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
theme->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
theme->set_icon("grabber_disabled", "VSlider", make_icon(vslider_grabber_disabled_png));
theme->set_icon("tick", "VSlider", make_icon(vslider_tick_png));
// SpinBox
theme->set_icon("updown", "SpinBox", make_icon(spinbox_updown_png));
//scroll container
Ref<StyleBoxEmpty> empty;
empty.instance();
theme->set_stylebox("bg", "ScrollContainer", empty);
// WindowDialog
theme->set_stylebox("panel", "WindowDialog", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
theme->set_constant("scaleborder_size", "WindowDialog", 4 * scale);
theme->set_font("title_font", "WindowDialog", large_font);
theme->set_color("title_color", "WindowDialog", Color(0, 0, 0));
theme->set_constant("title_height", "WindowDialog", 20 * scale);
theme->set_icon("close", "WindowDialog", make_icon(close_png));
theme->set_icon("close_highlight", "WindowDialog", make_icon(close_hl_png));
theme->set_constant("close_h_ofs", "WindowDialog", 18 * scale);
theme->set_constant("close_v_ofs", "WindowDialog", 18 * scale);
// File Dialog
theme->set_icon("reload", "FileDialog", make_icon(icon_reload_png));
theme->set_icon("parent_folder", "FileDialog", make_icon(icon_parent_folder_png));
// Popup
Ref<StyleBoxTexture> style_pp = sb_expand(make_stylebox(popup_bg_png, 5, 5, 5, 5, 4, 4, 4, 4), 2, 2, 2, 2);
Ref<StyleBoxTexture> selected = make_stylebox(selection_png, 6, 6, 6, 6);
for (int i = 0; i < 4; i++) {
selected->set_expand_margin_size(Margin(i), 2 * scale);
}
theme->set_stylebox("panel", "PopupPanel", style_pp);
// PopupMenu
theme->set_stylebox("panel", "PopupMenu", make_stylebox(popup_bg_png, 4, 4, 4, 4, 10, 10, 10, 10));
theme->set_stylebox("panel_disabled", "PopupMenu", make_stylebox(popup_bg_disabled_png, 4, 4, 4, 4));
theme->set_stylebox("hover", "PopupMenu", selected);
theme->set_stylebox("separator", "PopupMenu", make_stylebox(vseparator_png, 3, 3, 3, 3));
theme->set_stylebox("labeled_separator_left", "PopupMenu", make_stylebox(vseparator_png, 0, 0, 0, 0));
theme->set_stylebox("labeled_separator_right", "PopupMenu", make_stylebox(vseparator_png, 0, 0, 0, 0));
theme->set_icon("checked", "PopupMenu", make_icon(checked_png));
theme->set_icon("unchecked", "PopupMenu", make_icon(unchecked_png));
theme->set_icon("radio_checked", "PopupMenu", make_icon(radio_checked_png));
theme->set_icon("radio_unchecked", "PopupMenu", make_icon(radio_unchecked_png));
theme->set_icon("submenu", "PopupMenu", make_icon(submenu_png));
theme->set_font("font", "PopupMenu", default_font);
theme->set_color("font_color", "PopupMenu", control_font_color);
theme->set_color("font_color_accel", "PopupMenu", Color(0.7, 0.7, 0.7, 0.8));
theme->set_color("font_color_disabled", "PopupMenu", Color(0.4, 0.4, 0.4, 0.8));
theme->set_color("font_color_hover", "PopupMenu", control_font_color);
theme->set_constant("hseparation", "PopupMenu", 4 * scale);
theme->set_constant("vseparation", "PopupMenu", 4 * scale);
// GraphNode
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png, 6, 24, 6, 5, 16, 24, 16, 5);
Ref<StyleBoxTexture> graphsbcomment = make_stylebox(graph_node_comment_png, 6, 24, 6, 5, 16, 24, 16, 5);
Ref<StyleBoxTexture> graphsbcommentselected = make_stylebox(graph_node_comment_focus_png, 6, 24, 6, 5, 16, 24, 16, 5);
Ref<StyleBoxTexture> graphsbselected = make_stylebox(graph_node_selected_png, 6, 24, 6, 5, 16, 24, 16, 5);
Ref<StyleBoxTexture> graphsbdefault = make_stylebox(graph_node_default_png, 4, 4, 4, 4, 6, 4, 4, 4);
Ref<StyleBoxTexture> graphsbdeffocus = make_stylebox(graph_node_default_focus_png, 4, 4, 4, 4, 6, 4, 4, 4);
Ref<StyleBoxTexture> graph_bpoint = make_stylebox(graph_node_breakpoint_png, 6, 24, 6, 5, 16, 24, 16, 5);
Ref<StyleBoxTexture> graph_position = make_stylebox(graph_node_position_png, 6, 24, 6, 5, 16, 24, 16, 5);
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
theme->set_stylebox("frame", "GraphNode", graphsb);
theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
theme->set_stylebox("defaultframe", "GraphNode", graphsbdefault);
theme->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus);
theme->set_stylebox("comment", "GraphNode", graphsbcomment);
theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
theme->set_stylebox("breakpoint", "GraphNode", graph_bpoint);
theme->set_stylebox("position", "GraphNode", graph_position);
theme->set_constant("separation", "GraphNode", 1 * scale);
theme->set_icon("port", "GraphNode", make_icon(graph_port_png));
theme->set_icon("close", "GraphNode", make_icon(graph_node_close_png));
theme->set_icon("resizer", "GraphNode", make_icon(window_resizer_png));
theme->set_font("title_font", "GraphNode", default_font);
theme->set_color("title_color", "GraphNode", Color(0, 0, 0, 1));
theme->set_constant("title_offset", "GraphNode", 20 * scale);
theme->set_constant("close_offset", "GraphNode", 18 * scale);
theme->set_constant("port_offset", "GraphNode", 3 * scale);
// Tree
Ref<StyleBoxTexture> tree_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 0, 8, 0);
Ref<StyleBoxTexture> tree_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 0, 8, 0);
theme->set_stylebox("bg", "Tree", make_stylebox(tree_bg_png, 4, 4, 4, 5));
theme->set_stylebox("bg_focus", "Tree", focus);
theme->set_stylebox("selected", "Tree", tree_selected_oof);
theme->set_stylebox("selected_focus", "Tree", tree_selected);
theme->set_stylebox("cursor", "Tree", focus);
theme->set_stylebox("cursor_unfocused", "Tree", focus);
theme->set_stylebox("button_pressed", "Tree", make_stylebox(button_pressed_png, 4, 4, 4, 4));
theme->set_stylebox("title_button_normal", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
theme->set_stylebox("title_button_pressed", "Tree", make_stylebox(tree_title_pressed_png, 4, 4, 4, 4));
theme->set_stylebox("title_button_hover", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
theme->set_stylebox("custom_button", "Tree", sb_button_normal);
theme->set_stylebox("custom_button_pressed", "Tree", sb_button_pressed);
theme->set_stylebox("custom_button_hover", "Tree", sb_button_hover);
theme->set_icon("checked", "Tree", make_icon(checked_png));
theme->set_icon("unchecked", "Tree", make_icon(unchecked_png));
theme->set_icon("updown", "Tree", make_icon(updown_png));
theme->set_icon("select_arrow", "Tree", make_icon(dropdown_png));
theme->set_icon("arrow", "Tree", make_icon(arrow_down_png));
theme->set_icon("arrow_collapsed", "Tree", make_icon(arrow_right_png));
theme->set_font("title_button_font", "Tree", default_font);
theme->set_font("font", "Tree", default_font);
theme->set_color("title_button_color", "Tree", control_font_color);
theme->set_color("font_color", "Tree", control_font_color_low);
theme->set_color("font_color_selected", "Tree", control_font_color_pressed);
theme->set_color("selection_color", "Tree", Color(0.1, 0.1, 1, 0.8));
theme->set_color("cursor_color", "Tree", Color(0, 0, 0));
theme->set_color("guide_color", "Tree", Color(0, 0, 0, 0.1));
theme->set_color("drop_position_color", "Tree", Color(1, 0.3, 0.2));
theme->set_color("relationship_line_color", "Tree", Color::html("464646"));
theme->set_color("custom_button_font_highlight", "Tree", control_font_color_hover);
theme->set_constant("hseparation", "Tree", 4 * scale);
theme->set_constant("vseparation", "Tree", 4 * scale);
theme->set_constant("guide_width", "Tree", 2 * scale);
theme->set_constant("item_margin", "Tree", 12 * scale);
theme->set_constant("button_margin", "Tree", 4 * scale);
theme->set_constant("draw_relationship_lines", "Tree", 0);
theme->set_constant("draw_guides", "Tree", 1);
theme->set_constant("scroll_border", "Tree", 4);
theme->set_constant("scroll_speed", "Tree", 12);
// ItemList
Ref<StyleBoxTexture> item_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 2, 8, 2);
Ref<StyleBoxTexture> item_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 2, 8, 2);
theme->set_stylebox("bg", "ItemList", make_stylebox(tree_bg_png, 4, 4, 4, 5));
theme->set_stylebox("bg_focus", "ItemList", focus);
theme->set_constant("hseparation", "ItemList", 4);
theme->set_constant("vseparation", "ItemList", 2);
theme->set_constant("icon_margin", "ItemList", 4);
theme->set_constant("line_separation", "ItemList", 2 * scale);
theme->set_font("font", "ItemList", default_font);
theme->set_color("font_color", "ItemList", control_font_color_lower);
theme->set_color("font_color_selected", "ItemList", control_font_color_pressed);
theme->set_color("guide_color", "ItemList", Color(0, 0, 0, 0.1));
theme->set_stylebox("selected", "ItemList", item_selected_oof);
theme->set_stylebox("selected_focus", "ItemList", item_selected);
theme->set_stylebox("cursor", "ItemList", focus);
theme->set_stylebox("cursor_unfocused", "ItemList", focus);
// TabContainer
Ref<StyleBoxTexture> tc_sb = sb_expand(make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 4, 4, 4, 4), 3, 3, 3, 3);
tc_sb->set_expand_margin_size(MARGIN_TOP, 2 * scale);
tc_sb->set_default_margin(MARGIN_TOP, 8 * scale);
theme->set_stylebox("tab_fg", "TabContainer", sb_expand(make_stylebox(tab_current_png, 4, 4, 4, 1, 16, 4, 16, 4), 2, 2, 2, 2));
theme->set_stylebox("tab_bg", "TabContainer", sb_expand(make_stylebox(tab_behind_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
theme->set_stylebox("panel", "TabContainer", tc_sb);
theme->set_icon("increment", "TabContainer", make_icon(scroll_button_right_png));
theme->set_icon("increment_highlight", "TabContainer", make_icon(scroll_button_right_hl_png));
theme->set_icon("decrement", "TabContainer", make_icon(scroll_button_left_png));
theme->set_icon("decrement_highlight", "TabContainer", make_icon(scroll_button_left_hl_png));
theme->set_icon("menu", "TabContainer", make_icon(tab_menu_png));
theme->set_icon("menu_highlight", "TabContainer", make_icon(tab_menu_hl_png));
theme->set_font("font", "TabContainer", default_font);
theme->set_color("font_color_fg", "TabContainer", control_font_color_hover);
theme->set_color("font_color_bg", "TabContainer", control_font_color_low);
theme->set_color("font_color_disabled", "TabContainer", control_font_color_disabled);
theme->set_constant("side_margin", "TabContainer", 8 * scale);
theme->set_constant("top_margin", "TabContainer", 24 * scale);
theme->set_constant("label_valign_fg", "TabContainer", 0 * scale);
theme->set_constant("label_valign_bg", "TabContainer", 2 * scale);
theme->set_constant("hseparation", "TabContainer", 4 * scale);
// Tabs
theme->set_stylebox("tab_fg", "Tabs", sb_expand(make_stylebox(tab_current_png, 4, 3, 4, 1, 16, 3, 16, 2), 2, 2, 2, 2));
theme->set_stylebox("tab_bg", "Tabs", sb_expand(make_stylebox(tab_behind_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
theme->set_stylebox("panel", "Tabs", tc_sb);
theme->set_stylebox("button_pressed", "Tabs", make_stylebox(button_pressed_png, 4, 4, 4, 4));
theme->set_stylebox("button", "Tabs", make_stylebox(button_normal_png, 4, 4, 4, 4));
theme->set_icon("increment", "Tabs", make_icon(scroll_button_right_png));
theme->set_icon("increment_highlight", "Tabs", make_icon(scroll_button_right_hl_png));
theme->set_icon("decrement", "Tabs", make_icon(scroll_button_left_png));
theme->set_icon("decrement_highlight", "Tabs", make_icon(scroll_button_left_hl_png));
theme->set_icon("close", "Tabs", make_icon(tab_close_png));
theme->set_font("font", "Tabs", default_font);
theme->set_color("font_color_fg", "Tabs", control_font_color_hover);
theme->set_color("font_color_bg", "Tabs", control_font_color_low);
theme->set_color("font_color_disabled", "Tabs", control_font_color_disabled);
theme->set_constant("top_margin", "Tabs", 24 * scale);
theme->set_constant("label_valign_fg", "Tabs", 0 * scale);
theme->set_constant("label_valign_bg", "Tabs", 2 * scale);
theme->set_constant("hseparation", "Tabs", 4 * scale);
// Separators
theme->set_stylebox("separator", "HSeparator", make_stylebox(vseparator_png, 3, 3, 3, 3));
theme->set_stylebox("separator", "VSeparator", make_stylebox(hseparator_png, 3, 3, 3, 3));
theme->set_icon("close", "Icons", make_icon(icon_close_png));
theme->set_font("normal", "Fonts", default_font);
theme->set_font("large", "Fonts", large_font);
theme->set_constant("separation", "HSeparator", 4 * scale);
theme->set_constant("separation", "VSeparator", 4 * scale);
// Dialogs
theme->set_constant("margin", "Dialogs", 8 * scale);
theme->set_constant("button_margin", "Dialogs", 32 * scale);
// FileDialog
theme->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// colorPicker
theme->set_constant("margin", "ColorPicker", 4 * scale);
theme->set_constant("sv_width", "ColorPicker", 256 * scale);
theme->set_constant("sv_height", "ColorPicker", 256 * scale);
theme->set_constant("h_width", "ColorPicker", 30 * scale);
theme->set_constant("label_width", "ColorPicker", 10 * scale);
theme->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png));
theme->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png));
theme->set_icon("color_hue", "ColorPicker", make_icon(color_picker_hue_png));
theme->set_icon("color_sample", "ColorPicker", make_icon(color_picker_sample_png));
theme->set_icon("preset_bg", "ColorPicker", make_icon(mini_checkerboard_png));
theme->set_icon("bg", "ColorPickerButton", make_icon(mini_checkerboard_png));
// TooltipPanel
Ref<StyleBoxTexture> style_tt = make_stylebox(tooltip_bg_png, 4, 4, 4, 4);
for (int i = 0; i < 4; i++)
style_tt->set_expand_margin_size((Margin)i, 4 * scale);
theme->set_stylebox("panel", "TooltipPanel", style_tt);
theme->set_font("font", "TooltipLabel", default_font);
theme->set_color("font_color", "TooltipLabel", Color(0, 0, 0));
theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0.1));
theme->set_constant("shadow_offset_x", "TooltipLabel", 1);
theme->set_constant("shadow_offset_y", "TooltipLabel", 1);
// RichTextLabel
theme->set_stylebox("focus", "RichTextLabel", focus);
theme->set_stylebox("normal", "RichTextLabel", make_empty_stylebox(0, 0, 0, 0));
theme->set_font("normal_font", "RichTextLabel", default_font);
theme->set_font("bold_font", "RichTextLabel", default_font);
theme->set_font("italics_font", "RichTextLabel", default_font);
theme->set_font("bold_italics_font", "RichTextLabel", default_font);
theme->set_font("mono_font", "RichTextLabel", default_font);
theme->set_color("default_color", "RichTextLabel", control_font_color);
theme->set_color("font_color_selected", "RichTextLabel", font_color_selection);
theme->set_color("selection_color", "RichTextLabel", Color(0.1, 0.1, 1, 0.8));
theme->set_color("font_color_shadow", "RichTextLabel", Color(0, 0, 0, 0));
theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * scale);
theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * scale);
theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * scale);
theme->set_constant("line_separation", "RichTextLabel", 1 * scale);
theme->set_constant("table_hseparation", "RichTextLabel", 3 * scale);
theme->set_constant("table_vseparation", "RichTextLabel", 3 * scale);
// Containers
theme->set_stylebox("bg", "VSplitContainer", make_stylebox(vsplit_bg_png, 1, 1, 1, 1));
theme->set_stylebox("bg", "HSplitContainer", make_stylebox(hsplit_bg_png, 1, 1, 1, 1));
theme->set_icon("grabber", "VSplitContainer", make_icon(vsplitter_png));
theme->set_icon("grabber", "HSplitContainer", make_icon(hsplitter_png));
theme->set_constant("separation", "HBoxContainer", 4 * scale);
theme->set_constant("separation", "VBoxContainer", 4 * scale);
theme->set_constant("margin_left", "MarginContainer", 0 * scale);
theme->set_constant("margin_top", "MarginContainer", 0 * scale);
theme->set_constant("margin_right", "MarginContainer", 0 * scale);
theme->set_constant("margin_bottom", "MarginContainer", 0 * scale);
theme->set_constant("hseparation", "GridContainer", 4 * scale);
theme->set_constant("vseparation", "GridContainer", 4 * scale);
theme->set_constant("separation", "HSplitContainer", 12 * scale);
theme->set_constant("separation", "VSplitContainer", 12 * scale);
theme->set_constant("autohide", "HSplitContainer", 1 * scale);
theme->set_constant("autohide", "VSplitContainer", 1 * scale);
// ReferenceRect
Ref<StyleBoxTexture> ttnc = make_stylebox(full_panel_bg_png, 8, 8, 8, 8);
ttnc->set_draw_center(false);
theme->set_stylebox("panelnc", "Panel", ttnc);
theme->set_stylebox("panelf", "Panel", tc_sb);
Ref<StyleBoxTexture> sb_pc = make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 7, 7, 7, 7);
theme->set_stylebox("panel", "PanelContainer", sb_pc);
theme->set_icon("minus", "GraphEdit", make_icon(icon_zoom_less_png));
theme->set_icon("reset", "GraphEdit", make_icon(icon_zoom_reset_png));
theme->set_icon("more", "GraphEdit", make_icon(icon_zoom_more_png));
theme->set_icon("snap", "GraphEdit", make_icon(icon_snap_grid_png));
theme->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5));
theme->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05));
theme->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2));
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
theme->set_icon("logo", "Icons", make_icon(logo_png));
// Visual Node Ports
theme->set_constant("port_grab_distance_horizontal", "GraphEdit", 48 * scale);
theme->set_constant("port_grab_distance_vertical", "GraphEdit", 6 * scale);
// Theme
default_icon = make_icon(error_icon_png);
default_style = make_stylebox(error_icon_png, 2, 2, 2, 2);
memdelete(tex_cache);
}
void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
Ref<Theme> t;
t.instance();
Ref<StyleBox> default_style;
Ref<Texture> default_icon;
Ref<Font> default_font;
if (p_font.is_valid()) {
default_font = p_font;
} else if (p_hidpi) {
default_font = make_font(_hidpi_font_height, _hidpi_font_ascent, _hidpi_font_charcount, &_hidpi_font_charrects[0][0], _hidpi_font_kerning_pair_count, &_hidpi_font_kerning_pairs[0][0], _hidpi_font_img_width, _hidpi_font_img_height, _hidpi_font_img_data);
} else {
default_font = make_font(_lodpi_font_height, _lodpi_font_ascent, _lodpi_font_charcount, &_lodpi_font_charrects[0][0], _lodpi_font_kerning_pair_count, &_lodpi_font_kerning_pairs[0][0], _lodpi_font_img_width, _lodpi_font_img_height, _lodpi_font_img_data);
}
Ref<Font> large_font = default_font;
fill_default_theme(t, default_font, large_font, default_icon, default_style, p_hidpi ? 2.0 : 1.0);
Theme::set_default(t);
Theme::set_default_icon(default_icon);
Theme::set_default_style(default_style);
Theme::set_default_font(default_font);
}
void clear_default_theme() {
Theme::set_default(Ref<Theme>());
Theme::set_default_icon(Ref<Texture>());
Theme::set_default_style(Ref<StyleBox>());
Theme::set_default_font(Ref<Font>());
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE401_Memory_Leak__new_array_struct_twoints_52a.cpp
Label Definition File: CWE401_Memory_Leak__new_array.label.xml
Template File: sources-sinks-52a.tmpl.cpp
*/
/*
* @description
* CWE: 401 Memory Leak
* BadSource: Allocate data using new[]
* GoodSource: Point data to a stack buffer
* Sinks:
* GoodSink: call delete[] on data
* BadSink : no deallocation of data
* Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
*
* */
#include "std_testcase.h"
namespace CWE401_Memory_Leak__new_array_struct_twoints_52
{
#ifndef OMITBAD
/* bad function declaration */
void bad_sink_b(struct _twoints * data);
void bad()
{
struct _twoints * data;
data = NULL;
/* POTENTIAL FLAW: Allocate memory on the heap */
data = new struct _twoints[100];
/* Initialize and make use of data */
data[0].a = 0;
data[0].b = 0;
printStructLine((twoints *)&data[0]);
bad_sink_b(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2B_sink_b(struct _twoints * data);
static void goodG2B()
{
struct _twoints * data;
data = NULL;
{
/* FIX: Use memory allocated on the stack */
struct _twoints data_goodbuf[100];
data = data_goodbuf;
/* Initialize and make use of data */
data[0].a = 0;
data[0].b = 0;
printStructLine((twoints *)&data[0]);
}
goodG2B_sink_b(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2G_sink_b(struct _twoints * data);
static void goodB2G()
{
struct _twoints * data;
data = NULL;
/* POTENTIAL FLAW: Allocate memory on the heap */
data = new struct _twoints[100];
/* Initialize and make use of data */
data[0].a = 0;
data[0].b = 0;
printStructLine((twoints *)&data[0]);
goodB2G_sink_b(data);
}
void good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
} // close namespace
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE401_Memory_Leak__new_array_struct_twoints_52; // so that we can use good and bad easily
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();
return a.exec();
}
|
; A297667: Number of chordless cycles in the n-Moebius ladder.
; Submitted by Jamie Morken(s3)
; 1,6,9,12,15,22,35,56,87,134,209,332,533,858,1381,2224,3587,5794,9367,15148,24499,39626,64101,103704,167785,271470,439233,710676,1149879,1860526,3010379,4870880,7881231,12752078,20633273,33385316,54018557,87403842,141422365,228826168
mov $2,$0
add $2,1
mov $4,$0
lpb $2
mov $0,$4
sub $2,1
sub $0,$2
mov $6,2
mov $7,0
mov $8,$0
lpb $6
mov $0,$8
sub $6,1
add $0,$6
trn $0,1
seq $0,301653 ; Expansion of x*(1 + 2*x)/((1 - x)*(1 + x)*(1 - x - x^2)).
seq $0,60762 ; Number of conjugacy classes (the same as the number of irreducible representations) in the dihedral group with 2n elements.
sub $0,2
mov $5,$6
mul $5,$0
add $7,$5
lpe
min $8,1
mul $8,$0
mov $0,$7
sub $0,$8
mul $0,2
add $0,1
add $3,$0
lpe
mov $0,$3
|
;--------------------USART Message Table---------------------
;
; NOTES : All messages should be stored in the
; following format :
;
; <Message Label> CODE
; <Message Label>
; GLOBAL <Message Label>
; DT "<Message Text>"
; DT 0
;
; Also, if the message crosses a page boundary, there may
; be problems ...
;
;------------------------------------------------------------
; REVISION HISTORY :
;
;------------------------------------------------------------
ERRORLEVEL 0
PROCESSOR PIC16C74A
LIST b=4
TITLE "PICRAT USART Messages"
SUBTITLE "Version 1.00"
include <p16c74a.inc>
include <vt100.inc>
;------------------------------------------------------------
USART_MSG_DATA UDATA
USART_hi_msg_tmp RES 1
USART_lo_msg_tmp RES 1
GLOBAL USART_hi_msg_tmp
GLOBAL USART_lo_msg_tmp
USART_MSG_TMP UDATA
tmpcnt RES 1
USART_message_table CODE
USART_message_table
GLOBAL USART_message_table
BANKSEL tmpcnt
movwf tmpcnt ;save offset
BANKSEL USART_hi_msg_tmp
movf USART_hi_msg_tmp,W ;High part of address
movwf PCLATH
BANKSEL USART_lo_msg_tmp ;low part of address
movf USART_lo_msg_tmp,W
BANKSEL tmpcnt
addwf tmpcnt,W ;plus offset
btfsc STATUS,C ;allowing for carry
incf PCLATH,F
movwf PCL
;------------------------------------------------------------
;
;Startup Splash Screen
;
;Startup_screen CODE
Startup_screen
GLOBAL Startup_screen
DT VT_setcol80,VT_setjumpscroll,VT_setnormalvideo
DT VT_clearscreen,VT_align
DT VT_clearscreen,VT_cursorhome
DT VT_dhtop,VT_bold
DT "PIC-Rat Micromouse Platform\n\r"
DT VT_dhbot
DT "PIC-Rat Micromouse Platform\n\r"
DT VT_normal,VT_shdw
DT "\n\rMark Dennehy\tTCD Vision Lab\t1997\n\r"
DT VT_normal,VT_shsw
DT 0
END
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.