repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
hoplik/DronAutoPilotSystem
Arduino_New_Sketches/AeroQuad.h
/* AeroQuad v3.0.1 - February 2012 www.AeroQuad.com Copyright (c) 2012 <NAME>. All rights reserved. An Open Source Arduino based multicopter. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /*********************************************** * Modified 21.11.2015 by HOPLIK SYSTEMS * * Welcome http://hoplik.ru/ * ***********************************************/ #ifndef _AQ_GLOBAL_HEADER_DEFINITION_H_ #define _AQ_GLOBAL_HEADER_DEFINITION_H_ #include <stdlib.h> #include <math.h> #include "Arduino.h" #include "pins_arduino.h" #include "GpsDataType.h" #include "AQMath.h" #include "Receiver.h" // Flight Software Version #define SOFTWARE_VERSION 3.2 #if defined CONFIG_BAUDRATE #define BAUD CONFIG_BAUDRATE #else #if defined WirelessTelemetry && !defined MavLink #define BAUD 111111 // use this to be compatible with USB and XBee connections #else #define BAUD 115200 #endif #endif /** * ESC calibration process global declaration */ byte calibrateESC = 0; int testCommand = 1000; ////////////////////////////////////////////////////// /** * Flight control global declaration */ #define RATE_FLIGHT_MODE 0 #define ATTITUDE_FLIGHT_MODE 1 byte previousFlightMode = ATTITUDE_FLIGHT_MODE; #define TASK_100HZ 1 #define TASK_50HZ 2 #define TASK_10HZ 10 #define TASK_1HZ 100 #define THROTTLE_ADJUST_TASK_SPEED TASK_50HZ byte flightMode = RATE_FLIGHT_MODE; unsigned long frameCounter = 0; // main loop executive frame counter int minArmedThrottle; // initial value configured by user float G_Dt = 0.002; int throttle = 1000; byte motorArmed = OFF; byte safetyCheck = OFF; byte maxLimit = OFF; byte minLimit = OFF; float filteredAccel[3] = {0.0,0.0,0.0}; boolean inFlight = false; // true when motor are armed and that the user pass one time the min throttle float rotationSpeedFactor = 1.0; // main loop time variable unsigned long previousTime = 0; unsigned long currentTime = 0; unsigned long deltaTime = 0; // sub loop time variable unsigned long oneHZpreviousTime = 0; unsigned long tenHZpreviousTime = 0; unsigned long lowPriorityTenHZpreviousTime = 0; unsigned long lowPriorityTenHZpreviousTime2 = 0; unsigned long fiftyHZpreviousTime = 0; unsigned long hundredHZpreviousTime = 0; ////////////////////////////////////////////////////// // Analog Reference Value // This value provided from Configurator // Use a DMM to measure the voltage between AREF and GND // Enter the measured voltage below to define your value for aref // If you don't have a DMM use the following: // AeroQuad Shield v1.7, aref = 3.0 // AeroQuad Shield v1.6 or below, aref = 2.8 float aref; // Read in from EEPROM ////////////////////////////////////////////////////// /** * Heading and heading hold global declaration section */ byte headingHoldConfig = 0; float headingHold = 0; // calculated adjustment for quad to go to heading (PID output) float heading = 0; // measured heading from yaw gyro (process variable) float relativeHeading = 0; // current heading the quad is set to (set point) byte headingHoldState = OFF; void processHeading(); ////////////////////////////////////////////////////// /** * Serial communication global declaration */ #define SERIAL_PRINT SERIAL_PORT.print #define SERIAL_PRINTLN SERIAL_PORT.println #define SERIAL_AVAILABLE SERIAL_PORT.available #define SERIAL_READ SERIAL_PORT.read #define SERIAL_FLUSH SERIAL_PORT.flush #define SERIAL_BEGIN SERIAL_PORT.begin /*Подключаем второй порт для связи нано с шилдом * temporary disabled #define SERIAL1_PRINT SERIAL1_PORT.print #define SERIAL1_PRINTLN SERIAL1_PORT.println #define SERIAL1_AVAILABLE SERIAL1_PORT.available #define SERIAL1_READ SERIAL1_PORT.read #define SERIAL1_FLUSH SERIAL1_PORT.flush #define SERIAL1_BEGIN SERIAL1_PORT.begin */ //HardwareSerial *binaryPort; void readSerialCommand(); void serialEvent(); void sendSerialTelemetry(); void printInt(int data); float readFloatSerial(); long readIntegerSerial(); void sendBinaryFloat(float); void sendBinaryuslong(unsigned long); void fastTelemetry(); void comma(); void reportVehicleState(); ////////////////////////////////////////////////////// /** * battery monitor and battery monitor throttle correction global declaration section */ #if defined (BattMonitor) #define BattMonitorAlarmVoltage 10.0 // required by battery monitor macro, this is overriden by readEEPROM() float batteryMonitorAlarmVoltage = 10.0; int batteryMonitorStartThrottle = 0; int batteryMonitorThrottleTarget = 1450; unsigned long batteryMonitorStartTime = 0; unsigned long batteryMonitorGoingDownTime = 60000; #if defined BattMonitorAutoDescent #define BATTERY_MONITOR_MAX_ALARM_COUNT 50 int batteryMonitorAlarmCounter = 0; int batteyMonitorThrottleCorrection = 0; #endif #endif ////////////////////////////////////////////////////// /** * Altitude control global declaration */ #if defined AltitudeHoldBaro || defined AltitudeHoldRangeFinder // special state that allows immediate turn off of Altitude hold if large throttle changesa are made at the TX byte altitudeHoldState = OFF; // ON, OFF or ALTPANIC int altitudeHoldBump = 90; int altitudeHoldPanicStickMovement = 250; int minThrottleAdjust = -50; int maxThrottleAdjust = 50; int altitudeHoldThrottle = 1000; boolean isAltitudeHoldInitialized = false; float velocityCompFilter1 = 1.0 / (1.0 + 0.3); float velocityCompFilter2 = 1 - velocityCompFilter1; boolean runtimaZBiasInitialized = false; float zVelocity = 0.0; float estimatedZVelocity = 0.0; float runtimeZBias = 0.0; float zDampeningThrottleCorrection = 0.0; #if defined AltitudeHoldBaro float baroAltitudeToHoldTarget = 0.0; #endif #if defined AltitudeHoldRangeFinder float sonarAltitudeToHoldTarget = 0.0; #endif #endif ////////////////////////////////////////////////////// /** * Auto landing feature variables */ #if defined (AutoLanding) #define BARO_AUTO_DESCENT_STATE 2 #define SONAR_AUTO_DESCENT_STATE 3 #define MOTOR_AUTO_DESCENT_STATE 4 byte autoLandingState = OFF; boolean isAutoLandingInitialized = false; int autoLandingThrottleCorrection = 0; #endif /** * GPS navigation global declaration */ #define MAX_WAYPOINTS 16 // needed for EEPROM adr offset declarations #if defined (UseGPS) #include <GpsAdapter.h> #define DEFAULT_HOME_ALTITUDE 5 // default home base altitude is equal to 5 meter GeodeticPosition homePosition = GPS_INVALID_POSITION; GeodeticPosition missionPositionToReach = GPS_INVALID_POSITION; // in case of no GPS navigator, indicate the home position into the OSD #if defined UseGPSNavigator byte navigationState = OFF; // ON, OFF or ALTPANIC byte positionHoldState = OFF; // ON, OFF or ALTPANIC int missionNbPoint = 0; int gpsRollAxisCorrection = 0; int gpsPitchAxisCorrection = 0; int gpsYawAxisCorrection = 0; boolean isPositionHoldInitialized = false; boolean isGpsNavigationInitialized = false; int waypointIndex = -1; float distanceToDestination = 99999999.0; GeodeticPosition waypoint[MAX_WAYPOINTS] = { GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION, GPS_INVALID_POSITION}; GeodeticPosition positionHoldPointToReach = GPS_INVALID_POSITION; void evaluateMissionPositionToReach(); void processGpsNavigation(); #endif #endif ////////////////////////////////////////////////////// /** * EEPROM global section */ typedef struct { float p; float i; float d; } t_NVR_PID; typedef struct { float slope; float offset; float smooth_factor; } t_NVR_Receiver; typedef struct { t_NVR_PID ROLL_PID_GAIN_ADR; t_NVR_PID LEVELROLL_PID_GAIN_ADR; t_NVR_PID YAW_PID_GAIN_ADR; t_NVR_PID PITCH_PID_GAIN_ADR; t_NVR_PID LEVELPITCH_PID_GAIN_ADR; t_NVR_PID HEADING_PID_GAIN_ADR; t_NVR_PID LEVEL_GYRO_ROLL_PID_GAIN_ADR; t_NVR_PID LEVEL_GYRO_PITCH_PID_GAIN_ADR; t_NVR_PID ALTITUDE_PID_GAIN_ADR; t_NVR_PID ZDAMP_PID_GAIN_ADR; t_NVR_PID GPSROLL_PID_GAIN_ADR; t_NVR_PID GPSPITCH_PID_GAIN_ADR; t_NVR_PID GPSYAW_PID_GAIN_ADR; t_NVR_Receiver RECEIVER_DATA[MAX_NB_CHANNEL]; float SOFTWARE_VERSION_ADR; float WINDUPGUARD_ADR; float XMITFACTOR_ADR; float MINARMEDTHROTTLE_ADR; float AREF_ADR; float FLIGHTMODE_ADR; float HEADINGHOLD_ADR; float ACCEL_1G_ADR; float ALTITUDE_MAX_THROTTLE_ADR; float ALTITUDE_MIN_THROTTLE_ADR; float ALTITUDE_SMOOTH_ADR; float ALTITUDE_WINDUP_ADR; float ALTITUDE_BUMP_ADR; float ALTITUDE_PANIC_ADR; // Gyro calibration float ROTATION_SPEED_FACTOR_ARD; // Accel Calibration float XAXIS_ACCEL_BIAS_ADR; float XAXIS_ACCEL_SCALE_FACTOR_ADR; float YAXIS_ACCEL_BIAS_ADR; float YAXIS_ACCEL_SCALE_FACTOR_ADR; float ZAXIS_ACCEL_BIAS_ADR; float ZAXIS_ACCEL_SCALE_FACTOR_ADR; // Mag Calibration float XAXIS_MAG_BIAS_ADR; float YAXIS_MAG_BIAS_ADR; float ZAXIS_MAG_BIAS_ADR; // Battery Monitor float BATT_ALARM_VOLTAGE_ADR; float BATT_THROTTLE_TARGET_ADR; float BATT_DOWN_TIME_ADR; // Range Finder float RANGE_FINDER_MAX_ADR; float RANGE_FINDER_MIN_ADR; // Camera Control float CAMERAMODE_ADR; float MCAMERAPITCH_ADR; float MCAMERAROLL_ADR; float MCAMERAYAW_ADR; float SERVOCENTERPITCH_ADR; float SERVOCENTERROLL_ADR; float SERVOCENTERYAW_ADR; float SERVOMINPITCH_ADR; float SERVOMINROLL_ADR; float SERVOMINYAW_ADR; float SERVOMAXPITCH_ADR; float SERVOMAXROLL_ADR; float SERVOMAXYAW_ADR; float SERVOTXCHANNELS_ADR; // GPS mission storing float GPS_MISSION_NB_POINT_ADR; GeodeticPosition WAYPOINT_ADR[MAX_WAYPOINTS]; } t_NVR_Data; void readEEPROM(); void initSensorsZeroFromEEPROM(); void storeSensorsZeroToEEPROM(); void initReceiverFromEEPROM(); float nvrReadFloat(int address); // defined in DataStorage.h void nvrWriteFloat(float value, int address); // defined in DataStorage.h long nvrReadLong(int address); // defined in DataStorage.h void nvrWriteLong(long value, int address); // defined in DataStorage.h void nvrReadPID(unsigned char IDPid, unsigned int IDEeprom); void nvrWritePID(unsigned char IDPid, unsigned int IDEeprom); #define GET_NVR_OFFSET(param) ((int)&(((t_NVR_Data*) 0)->param)) #define readFloat(addr) nvrReadFloat(GET_NVR_OFFSET(addr)) #define writeFloat(value, addr) nvrWriteFloat(value, GET_NVR_OFFSET(addr)) #define readLong(addr) nvrReadLong(GET_NVR_OFFSET(addr)) #define writeLong(value, addr) nvrWriteLong(value, GET_NVR_OFFSET(addr)) #define readPID(IDPid, addr) nvrReadPID(IDPid, GET_NVR_OFFSET(addr)) #define writePID(IDPid, addr) nvrWritePID(IDPid, GET_NVR_OFFSET(addr)) /** * Debug utility global declaration * Debug code should never be part of a release sofware * @see Kenny */ //#define DEBUG byte fastTransfer = OFF; // Used for troubleshooting //unsigned long fastTelemetryTime = 0; //byte testSignal = LOW; ////////////////////////////////////////////////////// /* OnBoardPilotSystem global declaration */ byte OnBoardPilotSystem = OFF; // Инициализация автопилота #endif // _AQ_GLOBAL_HEADER_DEFINITION_H_
hoplik/DronAutoPilotSystem
Arduino_New_Sketches/FlightCommandProcessor.h
<gh_stars>0 /* AeroQuad v3.0.1 - February 2012 www.AeroQuad.com Copyright (c) 2012 <NAME>. All rights reserved. An Open Source Arduino based multicopter. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /*********************************************** * Modified 22.02.2015 by HOPLIK SYSTEMS * * Welcome http://hoplik.ru/ * ***********************************************/ // FlightCommandProcessor is responsible for decoding transmitter stick combinations // for setting up AeroQuad modes such as motor arming and disarming #ifndef _AQ_FLIGHT_COMMAND_READER_ #define _AQ_FLIGHT_COMMAND_READER_ #if defined (AltitudeHoldBaro) || defined (AltitudeHoldRangeFinder) boolean isPositionHoldEnabledByUser() { #if defined (UseGPSNavigator) if ((receiverCommand[AUX1] < 1750) || (receiverCommand[AUX2] < 1750)) { return true; } return false; #else if (receiverCommand[AUX1] < 1750) { return true; } return false; #endif } #endif #if defined AltitudeHoldBaro || defined AltitudeHoldRangeFinder void processAltitudeHoldStateFromReceiverCommand() { if (isPositionHoldEnabledByUser()) { if (altitudeHoldState != ALTPANIC) { // check for special condition with manditory override of Altitude hold if (!isAltitudeHoldInitialized) { #if defined AltitudeHoldBaro baroAltitudeToHoldTarget = getBaroAltitude(); PID[BARO_ALTITUDE_HOLD_PID_IDX].integratedError = 0; PID[BARO_ALTITUDE_HOLD_PID_IDX].lastError = baroAltitudeToHoldTarget; #endif #if defined AltitudeHoldRangeFinder sonarAltitudeToHoldTarget = rangeFinderRange[ALTITUDE_RANGE_FINDER_INDEX]; PID[SONAR_ALTITUDE_HOLD_PID_IDX].integratedError = 0; PID[SONAR_ALTITUDE_HOLD_PID_IDX].lastError = sonarAltitudeToHoldTarget; #endif altitudeHoldThrottle = receiverCommand[THROTTLE]; isAltitudeHoldInitialized = true; } altitudeHoldState = ON; } } else { isAltitudeHoldInitialized = false; altitudeHoldState = OFF; } } #endif #if defined (AutoLanding) void processAutoLandingStateFromReceiverCommand() { if (receiverCommand[AUX3] < 1750) { if (altitudeHoldState != ALTPANIC ) { // check for special condition with manditory override of Altitude hold if (isAutoLandingInitialized) { autoLandingState = BARO_AUTO_DESCENT_STATE; #if defined AltitudeHoldBaro baroAltitudeToHoldTarget = getBaroAltitude(); PID[BARO_ALTITUDE_HOLD_PID_IDX].integratedError = 0; PID[BARO_ALTITUDE_HOLD_PID_IDX].lastError = baroAltitudeToHoldTarget; #endif #if defined AltitudeHoldRangeFinder sonarAltitudeToHoldTarget = rangeFinderRange[ALTITUDE_RANGE_FINDER_INDEX]; PID[SONAR_ALTITUDE_HOLD_PID_IDX].integratedError = 0; PID[SONAR_ALTITUDE_HOLD_PID_IDX].lastError = sonarAltitudeToHoldTarget; #endif altitudeHoldThrottle = receiverCommand[THROTTLE]; isAutoLandingInitialized = true; } altitudeHoldState = ON; } } else { autoLandingState = OFF; autoLandingThrottleCorrection = 0; isAutoLandingInitialized = false; #if defined (UseGPSNavigator) if ((receiverCommand[AUX1] > 1750) && (receiverCommand[AUX2] > 1750)) { altitudeHoldState = OFF; isAltitudeHoldInitialized = false; } #else if (receiverCommand[AUX1] > 1750) { altitudeHoldState = OFF; isAltitudeHoldInitialized = false; } #endif } } #endif #if defined (UseGPSNavigator) void processGpsNavigationStateFromReceiverCommand() { // Init home command if (motorArmed == OFF && receiverCommand[THROTTLE] < MINCHECK && receiverCommand[ZAXIS] < MINCHECK && receiverCommand[YAXIS] > MAXCHECK && receiverCommand[XAXIS] > MAXCHECK && haveAGpsLock()) { homePosition.latitude = currentPosition.latitude; homePosition.longitude = currentPosition.longitude; homePosition.altitude = DEFAULT_HOME_ALTITUDE; } if (receiverCommand[AUX2] < 1750) { // Enter in execute mission state, if none, go back home, override the position hold if (!isGpsNavigationInitialized) { gpsRollAxisCorrection = 0; gpsPitchAxisCorrection = 0; gpsYawAxisCorrection = 0; isGpsNavigationInitialized = true; } positionHoldState = OFF; // disable the position hold while navigating isPositionHoldInitialized = false; navigationState = ON; } else if (receiverCommand[AUX1] < 1250) { // Enter in position hold state if (!isPositionHoldInitialized) { gpsRollAxisCorrection = 0; gpsPitchAxisCorrection = 0; gpsYawAxisCorrection = 0; positionHoldPointToReach.latitude = currentPosition.latitude; positionHoldPointToReach.longitude = currentPosition.longitude; positionHoldPointToReach.altitude = getBaroAltitude(); isPositionHoldInitialized = true; } isGpsNavigationInitialized = false; // disable navigation navigationState = OFF; positionHoldState = ON; } else { // Navigation and position hold are disabled positionHoldState = OFF; isPositionHoldInitialized = false; navigationState = OFF; isGpsNavigationInitialized = false; gpsRollAxisCorrection = 0; gpsPitchAxisCorrection = 0; gpsYawAxisCorrection = 0; } } #endif void processZeroThrottleFunctionFromReceiverCommand() { // Disarm motors (left stick lower left corner) if (receiverCommand[ZAXIS] < MINCHECK && motorArmed == ON) { commandAllMotors(MINCOMMAND); motorArmed = OFF; inFlight = false; #ifdef OSD notifyOSD(OSD_CENTER|OSD_WARN, "MOTORS UNARMED"); #endif #if defined BattMonitorAutoDescent batteryMonitorAlarmCounter = 0; batteryMonitorStartThrottle = 0; batteyMonitorThrottleCorrection = 0.0; #endif } // Zero Gyro and Accel sensors (left stick lower left, right stick lower right corner) if ((receiverCommand[ZAXIS] < MINCHECK) && (receiverCommand[XAXIS] > MAXCHECK) && (receiverCommand[YAXIS] < MINCHECK)) { calibrateGyro(); computeAccelBias(); storeSensorsZeroToEEPROM(); calibrateKinematics(); zeroIntegralError(); pulseMotors(3); } // Arm motors (left stick lower right corner) if (receiverCommand[ZAXIS] > MAXCHECK && motorArmed == OFF && safetyCheck == ON) { #ifdef OSD_SYSTEM_MENU if (menuOwnsSticks) { return; } #endif for (byte motor = 0; motor < LASTMOTOR; motor++) { motorCommand[motor] = MINTHROTTLE; } motorArmed = ON; #ifdef OSD notifyOSD(OSD_CENTER|OSD_WARN, "!MOTORS ARMED!"); #endif zeroIntegralError(); } // Prevents accidental arming of motor output if no transmitter command received if (receiverCommand[ZAXIS] > MINCHECK) { safetyCheck = ON; } // Switch from transmitter commands to OnBoardPilotSystem // ГАЗ - ВНИЗ и ВПРАВО; ROLL - вниз и вправо - включение автопилота if ((receiverCommand[ZAXIS] > MAXCHECK) && (receiverCommand[XAXIS] > MAXCHECK) && (receiverCommand[YAXIS] < MINCHECK)) { OnBoardPilotSystem = ON; // Включили автопилот digitalWrite(LED_Red, HIGH); // Зажгли красный диод SERIAL_PRINTLN("SOBPS_ON"); // Отправили в порт подтверждение включения автопилота } // Switch from OnBoardPilotSystem to fransmitter commands // Газ - вниз и вправо; ROLL - вниз и влево - выключение автопилота if ((receiverCommand[ZAXIS] > MAXCHECK) && (receiverCommand[XAXIS] < MINCHECK) && (receiverCommand[YAXIS] < MINCHECK)) { OnBoardPilotSystem = OFF; // Выключили автопилот digitalWrite(LED_Red, LOW); // Погасили красный диод SERIAL_PRINTLN("SOBPS_OFF"); // Отправили в порт подтверждение отключения автопилота } } /** * readPilotCommands * * This function is responsible to read receiver * and process command from the users */ void readPilotCommands() { readReceiver(); if (receiverCommand[THROTTLE] < MINCHECK) { processZeroThrottleFunctionFromReceiverCommand(); } /* Подменяем данные приёмника на данные из порта, если включён автопилот */ if (OnBoardPilotSystem == ON) { for (int i = 0; i < LASTCHANNEL; i++) { receiverCommand[i] = PilotSystemCommand[i]; } } if (!inFlight) { if (motorArmed == ON && receiverCommand[THROTTLE] > minArmedThrottle) { inFlight = true; } } // Check Mode switch for Acro or Stable if (receiverCommand[MODE] > 1500) { flightMode = ATTITUDE_FLIGHT_MODE; } else { flightMode = RATE_FLIGHT_MODE; } if (previousFlightMode != flightMode) { zeroIntegralError(); previousFlightMode = flightMode; } #if defined AltitudeHoldBaro || defined AltitudeHoldRangeFinder processAltitudeHoldStateFromReceiverCommand(); #endif #if defined (AutoLanding) processAutoLandingStateFromReceiverCommand(); #endif #if defined (UseGPSNavigator) processGpsNavigationStateFromReceiverCommand(); #endif } #endif // _AQ_FLIGHT_COMMAND_READER_
hoplik/DronAutoPilotSystem
Arduino_New_Sketches/OnBoardPilotSystem.h
// OnBoardPilotSystem.h /*********************************** * HOPLIK SYSTEMS 24.02.2015 * * Welcome http://hoplik.ru/ * ***********************************/ /* Система подключения бортового автопилота. Функциязамены данных шести каналов с передатчика на данные из ком-порта. */ #ifndef _ONBOARDPILOTSYSTEM_h #define _ONBOARDPILOTSYSTEM_h #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include "RangeFinder.h" int PilotSystemCommand[10] = { 1500, 1500, 1500, 1000, 2000, 2000, 0, 0, 0, 0 }; // Массив данных для подмены String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete #endif
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/src/generated/serializer/CatalogVersionsSerializer.h
<gh_stars>10-100 /* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <olp/core/generated/serializer/SerializerWrapper.h> #include <olp/dataservice/read/model/CatalogVersion.h> #include <rapidjson/document.h> namespace olp { namespace serializer { inline void to_json(const dataservice::read::model::CatalogVersion& x, rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator) { value.SetObject(); serialize("hrn", x.GetHrn(), value, allocator); serialize("version", x.GetVersion(), value, allocator); } template <> inline void to_json<dataservice::read::model::CatalogVersion>( const std::vector<dataservice::read::model::CatalogVersion>& x, rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator) { value.SetObject(); rapidjson::Value array_value; array_value.SetArray(); for (auto itr = x.begin(); itr != x.end(); ++itr) { rapidjson::Value item_value; to_json(*itr, item_value, allocator); array_value.PushBack(std::move(item_value), allocator); } value.AddMember("dependencies", std::move(array_value), allocator); } } // namespace serializer } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/include/olp/core/thread/Continuation.h
<filename>olp-cpp-sdk-core/include/olp/core/thread/Continuation.h /* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <deque> #include <functional> #include <memory> #include <olp/core/client/ApiError.h> #include <olp/core/client/ApiResponse.h> #include <olp/core/client/TaskContext.h> #include <olp/core/thread/ExecutionContext.h> #include <olp/core/thread/TypeHelpers.h> namespace olp { namespace thread { class TaskScheduler; namespace internal { /** * @brief Provides mechanisms to create a chain of tasks and start, cancel, * and finalize an execution. * * @note It is a private implementation class for internal use only and not * bound to any API stability promises. Do not use it directly. */ class CORE_API ContinuationImpl final { public: /// An alias for the function that returns an error as a callback. using FailedCallback = std::function<void(client::ApiError)>; /// The return value type of the `Continuation` task. using OutResultType = std::unique_ptr<UntypedSmartPointer>; /// The type of `ContinuationType`. using TaskType = std::function<OutResultType(void*)>; /// The generic callback type. using CallbackType = std::function<void(void*)>; /// An internal type of tasks in `Continuation`. using AsyncTaskType = std::function<void(void*, CallbackType)>; /// An alias for the processing tasks finalization type. using FinalCallbackType = std::function<void(void*, bool)>; /// An alias for a pair of task continuation chain types. using ContinuationTask = std::pair<AsyncTaskType, TaskType>; /// The default constructor of `ContinuationImpl`. ContinuationImpl() = default; /** * @brief Creates the `ContinuationImpl` instance. * * @param task_scheduler The `TaskScheduler` instance. * @param context The `ExecutionContext` instance. * @param task The `ContinuationTask` instance. It represents * a task that you want to add to the continuation chain. */ ContinuationImpl(std::shared_ptr<TaskScheduler> task_scheduler, ExecutionContext context, ContinuationTask task); /** * @brief Adds the next asynchronous task * to the `ContinuationImpl` instance. * * @param task The `ContinuationTask` instance. It represents * a task that you want to add to the continuation chain. * * @return The `ContinuationImpl` instance. */ ContinuationImpl Then(ContinuationTask task); /** * @brief Starts the execution of the task continuation chain. * * @param callback Handles the finalization of the task chain. */ void Run(FinalCallbackType callback); /** * @brief Gets the `ExecutionContext` object. * * @return The `ExecutionContext` instance. */ const ExecutionContext& GetExecutionContext() const; /** * @brief Checks whether the `CancellationContext` instance is cancelled. * * @return True if the `CancellationContext` instance is cancelled; false * otherwise. */ bool Cancelled() const; /** * @brief Sets a callback on calling `SetError`. * * @param callback Handles the execution finalization of the continuation * chain. */ void SetFailedCallback(FailedCallback callback); /** * @brief Clears the continuation chain tasks. */ void Clear(); private: std::shared_ptr<thread::TaskScheduler> task_scheduler_; std::deque<ContinuationTask> tasks_; ExecutionContext execution_context_; /** * @brief Checks whether it is allowed to do the changes to the task chain. * * Use it to skip the methods of the `Continuation` object. */ bool change_allowed{true}; }; } // namespace internal /// A generic template for `Continuation`. template <typename ResultType> class CORE_API Continuation final { /// The response type alias of the template class type. using Response = client::ApiResponse<ResultType, client::ApiError>; /// An alias for the finalization callback. using FinallyCallbackType = std::function<void(Response)>; /// An alias for `ContinuationImplType::ContinuationImpl`. using ContinuationImplType = internal::ContinuationImpl; /// An alias for `ContinuationImplType::OutResultType`. using OutResultType = ContinuationImplType::OutResultType; /// An alias for `ContinuationImplType::TaskType`. using TaskType = ContinuationImplType::TaskType; /// An alias for `ContinuationImplType::CallbackType`. using CallbackType = ContinuationImplType::CallbackType; /// An alias for the continuation chain first task. using ContinuationTaskType = std::function<void(ExecutionContext, std::function<void(ResultType)>)>; public: /// The default constructor of `Continuation<ResultType>`. Continuation() = default; /** * @brief Creates the `Continuation` instance. * * @param task_scheduler The `TaskScheduler` instance. * @param context The `ExecutionContext` instance. * @param task The continuation task's callback. It contains the execution * context and returns a value for the next task. */ Continuation(std::shared_ptr<thread::TaskScheduler> scheduler, ExecutionContext context, ContinuationTaskType task); /** * @brief Creates the `Continuation` instance. * * @param continuation The `ContinuationImpl` instance. */ Continuation(ContinuationImplType continuation); /** * @brief Adds the next asynchronous task * to the `ContinuationImpl` instance. * * @param task The `ContinuationTask` instance. It represents * a task that you want to add to the continuation chain. */ template <typename Callable> Continuation<internal::DeducedType<Callable>> Then(Callable task); /// Starts the execution of the task continuation chain. void Run(); /** * @brief Provides a token to cancel the task. * * @return The `CancellationToken` instance. */ client::CancellationToken CancelToken(); /** * @brief Adds the next asynchronous task * to the `ContinuationImpl` instance. * * @param execution_func A task that you want to add to the continuation * chain. */ template <typename NewType> Continuation<internal::RemoveRefAndConst<NewType>> Then( std::function<void(ExecutionContext, ResultType, std::function<void(NewType)>)> execution_func); /** * @brief Handles the finalization of the `Continuation` instance * and sets a callback for it. * * @param finally_callback The callback that handles successful and * unsuccessful results. * * @return The `Continuation` instance. */ Continuation& Finally(FinallyCallbackType finally_callback); private: FinallyCallbackType finally_callback_; ContinuationImplType impl_; }; /** * @brief A template for `Continuation` of the void type. * * It has the same interface as the generic version. */ template <> class CORE_API Continuation<void> final { public: /// Do not create the deleted `Continuation` constructor as an instance. Continuation() = delete; /** * @brief Adds the next asynchronous task * to the `ContinuationImpl` instance. * * @param task The `ContinuationTask` instance. It represents * a task that you want to add to the continuation chain. * * @return The `Continuation` instance. */ template <typename Callable> Continuation<internal::AsyncResultType<Callable>> Then(Callable task); private: /// An alias for `internal::ContinuationImpl::CallbackType`. using CallbackType = internal::ContinuationImpl::CallbackType; /// An alias for `internal::ContinuationImpl`. using ContinuationImplType = internal::ContinuationImpl; /// An alias for `ContinuationImplType::OutResultType`. using OutResultType = ContinuationImplType::OutResultType; /// An alias for `ContinuationImplType::TaskType`. using TaskType = ContinuationImplType::TaskType; template <typename ResultType> friend class Continuation; /** * @brief Creates the `ContinuationImplType` instance. * * @param context The `ExecutionContext` instance. * @param task The continuation task's callback. It contains the execution * context and returns a value for the next task. */ template <typename NewType> static ContinuationImplType::ContinuationTask ToAsyncTask( ExecutionContext context, std::function<void(ExecutionContext, std::function<void(NewType)>)> task); ContinuationImplType impl_; }; } // namespace thread } // namespace olp #include "Continuation.inl"
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-write/src/CatalogSettings.h
/* * Copyright (C) 2020-2021 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <string> #include <olp/core/cache/KeyValueCache.h> #include <olp/core/client/ApiError.h> #include <olp/core/client/ApiResponse.h> #include <olp/core/client/CancellationContext.h> #include <olp/core/client/HRN.h> #include <olp/core/client/OlpClientSettings.h> namespace olp { namespace dataservice { namespace write { namespace model { class Catalog; } class CatalogSettings { public: using BillingTag = boost::optional<std::string>; struct LayerSettings { std::string content_type; std::string content_encoding; }; using LayerSettingsResult = client::ApiResponse<LayerSettings, client::ApiError>; CatalogSettings(client::HRN catalog, client::OlpClientSettings settings); LayerSettingsResult GetLayerSettings(client::CancellationContext context, BillingTag billing_tag, const std::string& layer_id) const; private: LayerSettingsResult GetLayerSettingsFromModel( const model::Catalog& catalog, const std::string& layer_id) const; client::HRN catalog_; std::shared_ptr<cache::KeyValueCache> cache_; client::OlpClientSettings settings_; }; } // namespace write } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/src/cache/ProtectedKeyList.h
/* * Copyright (C) 2020 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <set> #include <string> #include <olp/core/cache/KeyValueCache.h> namespace olp { namespace cache { class ProtectedKeyList { public: using ProtectedKeyChanged = std::function<void(const std::string&)>; ProtectedKeyList(); ~ProtectedKeyList() = default; bool Protect(const KeyValueCache::KeyListType& keys, const ProtectedKeyChanged& change_key_to_protected); bool Release(const KeyValueCache::KeyListType& keys); bool Deserialize(KeyValueCache::ValueTypePtr value); KeyValueCache::ValueTypePtr Serialize(); bool IsProtected(const std::string& key) const; // Size calculated on last Serialize/Deserialize call. This size should mach // data size written on disk std::uint64_t Size() const; bool IsDirty() const; std::uint64_t Count() const; private: // custom comparator needed to reduce duplicates for keys, which are already // protected by prefix struct CustomCompare { bool operator()(const std::string& lhs, const std::string& rhs) const { if (rhs.length() < lhs.length()) { if (std::equal(rhs.begin(), rhs.end(), lhs.begin())) { return false; } } else if (lhs.length() < rhs.length()) { if (std::equal(lhs.begin(), lhs.end(), rhs.begin())) { return false; } } return lhs < rhs; } }; std::set<std::string, CustomCompare> protected_data_; std::uint64_t size_written_; bool dirty_; }; } // namespace cache } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-authentication/src/TokenEndpointImpl.h
<gh_stars>10-100 /* * Copyright (C) 2021 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <olp/authentication/AuthenticationClient.h> #include <olp/authentication/AuthenticationCredentials.h> #include <olp/authentication/AuthenticationSettings.h> #include <olp/authentication/Settings.h> #include <olp/authentication/SignInResult.h> #include <olp/authentication/Types.h> #include <olp/core/client/CancellationContext.h> #include <olp/core/client/OlpClient.h> #include "TokenRequest.h" namespace olp { namespace authentication { /// @copydoc TokenEndpoint class TokenEndpointImpl { public: /// Defines the callback that is invoked when the response on /// `TokenRequest` is returned. using RequestTokenCallback = Callback<TokenResult>; /// @copydoc TokenEndpoint::TokenEndpoint() explicit TokenEndpointImpl(Settings settings); /// @copydoc TokenEndpoint::RequestToken(const TokenRequest&, const /// RequestTokenCallback&) client::CancellationToken RequestToken(const TokenRequest& token_request, const RequestTokenCallback& callback); /// @copydoc TokenEndpoint::RequestToken(client::CancellationToken&, const /// TokenRequest&) std::future<TokenResponse> RequestToken( client::CancellationToken& cancel_token, const TokenRequest& token_request); /// @copydoc TokenEndpoint::RequestToken(client::CancellationContext&, const /// TokenRequest&) TokenResponse RequestToken( client::CancellationContext& context, const TokenRequest& token_request = TokenRequest()) const; private: class RequestTimer { public: RequestTimer(); explicit RequestTimer(std::time_t server_time); std::time_t GetRequestTime() const; private: std::chrono::steady_clock::time_point timer_start_; std::time_t time_; }; static SignInResult ParseAuthResponse(int status, std::stringstream& auth_response); Response<SignInResult> SignInClient(client::CancellationContext& context, const TokenRequest& token_request) const; client::HttpResponse CallAuth(const client::OlpClient& client, const std::string& endpoint, client::CancellationContext& context, client::OlpClient::RequestBodyType body, std::time_t timestamp) const; RequestTimer CreateRequestTimer(const client::OlpClient& client, client::CancellationContext& context) const; const AuthenticationCredentials credentials_; const AuthenticationSettings settings_; AuthenticationClient auth_client_; }; } // namespace authentication } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/include/olp/core/thread/ExecutionContext.h
<gh_stars>10-100 /* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <utility> #include <olp/core/client/ApiError.h> #include <olp/core/client/CancellationContext.h> namespace olp { namespace thread { /// Handles the cancellation and final mechanisms. class CORE_API ExecutionContext final { using CancelFuncType = std::function<void()>; using ExecuteFuncType = std::function<client::CancellationToken()>; using FailedCallback = std::function<void(client::ApiError)>; public: /// A default contructor, initializes the `ExecutionContextImpl` instance. ExecutionContext(); /** * @brief Checks whether `CancellationContext` is cancelled. * * @return True if `CancellationContext` is cancelled; false otherwise. */ bool Cancelled() const; /// @copydoc CancellationContext::CancelOperation() void CancelOperation(); /// @copydoc CancellationContext::ExecuteOrCancelled() void ExecuteOrCancelled(const ExecuteFuncType& execute_fn, const CancelFuncType& cancel_fn = nullptr); /** * @brief Sets the error that is returned in the `Finally` * method of the execution. * * It immediately finishes the task execution and provides an error * via the `SetFailedCallback` callback of `ExecutionContext`. * * @param error The `ApiError` instance containing the error information. */ void SetError(client::ApiError error); /** * @brief Sets a callback for `SetError`. * * @param callback Handles the finalization of the execution * in case of an error. */ void SetFailedCallback(FailedCallback callback); /** * @brief Gets the `CancellationContext` object associated * with this `ExecutionContext` instance. * * The caller can use it to cancel the ongoing operation. * * @return The `CancellationContext` instance. */ const client::CancellationContext& GetContext() const; private: class ExecutionContextImpl; std::shared_ptr<ExecutionContextImpl> impl_; }; } // namespace thread } // namespace olp
heremaps/here-olp-edge-sdk-cpp
tests/common/mocks/NetworkMock.h
<filename>tests/common/mocks/NetworkMock.h<gh_stars>10-100 /* * Copyright (C) 2019-2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <chrono> #include <future> #include <gmock/gmock.h> #include <olp/core/http/Network.h> using NetworkCallback = std::function<olp::http::SendOutcome( olp::http::NetworkRequest, olp::http::Network::Payload, olp::http::Network::Callback, olp::http::Network::HeaderCallback, olp::http::Network::DataCallback)>; using CancelCallback = std::function<void(olp::http::RequestId)>; class NetworkMock : public olp::http::Network { public: NetworkMock(); ~NetworkMock() override; MOCK_METHOD(olp::http::SendOutcome, Send, (olp::http::NetworkRequest request, olp::http::Network::Payload payload, olp::http::Network::Callback callback, olp::http::Network::HeaderCallback header_callback, olp::http::Network::DataCallback data_callback), (override)); MOCK_METHOD(void, Cancel, (olp::http::RequestId id), (override)); }; /** * @brief Data Structure which is used by network mock to fill response's body * on network request. */ struct MockedResponseInformation { int status; /// HTTP status code for response. const char* data; /// Body of HTTP response. olp::http::Headers headers; MockedResponseInformation(int status, const char* data, olp::http::Headers&& headers = {}) : status(status), data(data), headers(std::move(headers)) {} }; /** * @brief Helper function creates actions that can be provided to the * NetworkMock instance. * * @param pre_signal - promise that will notify the test that it has reached * network code. * @param wait_for_signal - promise that test should set to let network mock * know that it is time to check requets for cancellation. Test needs to cancel * request before setting this promise. * @param response_information - Data that network mock should return in * response if request wasn't cancelled. * @param post_signal - optional promise that network mock will set after * request is finished. * * @return Triple: RequestId; Action for method Send(); Action for method * Cancel(); */ std::tuple<olp::http::RequestId, NetworkCallback, CancelCallback> GenerateNetworkMockActions(std::shared_ptr<std::promise<void>> pre_signal, std::shared_ptr<std::promise<void>> wait_for_signal, MockedResponseInformation response_information, std::shared_ptr<std::promise<void>> post_signal = std::make_shared<std::promise<void>>()); /// /// NetworkMock Actions /// /** * @brief Helper function creates Network::Send mock function that returns a * specified response, body, headers after specified delay from a different * thread. * * @param response Network response. * @param response_body Response payload. * @param headers Response headers (optional). * @param delay Response delay (optional). * * @return A function that mimics Network::Send method. */ NetworkCallback ReturnHttpResponse( olp::http::NetworkResponse response, const std::string& response_body, const olp::http::Headers& headers = {}, std::chrono::nanoseconds delay = std::chrono::milliseconds(50), olp::http::RequestId request_id = 5); inline olp::http::NetworkResponse GetResponse(int status, int bytes_downloaded = 0, int bytes_uploaded = 0) { return olp::http::NetworkResponse() .WithStatus(status) .WithBytesDownloaded(bytes_downloaded) .WithBytesUploaded(bytes_uploaded); }
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/src/repositories/PartitionsRepository.h
/* * Copyright (C) 2019-2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <string> #include <vector> #include <olp/core/client/ApiLookupClient.h> #include <olp/core/client/CancellationContext.h> #include <olp/core/client/CancellationToken.h> #include <olp/core/client/HRN.h> #include <olp/core/client/OlpClientSettings.h> #include "ExtendedApiResponse.h" #include "QuadTreeIndex.h" #include "generated/api/QueryApi.h" #include "generated/model/Index.h" #include "olp/dataservice/read/DataRequest.h" #include "olp/dataservice/read/PartitionsRequest.h" #include "olp/dataservice/read/Types.h" #include "NamedMutex.h" #include "PartitionsCacheRepository.h" namespace olp { namespace dataservice { namespace read { class TileRequest; namespace repository { /// The partition metadata response type. using PartitionResponse = Response<model::Partition, client::NetworkStatistics>; using QuadTreeIndexResponse = Response<QuadTreeIndex, client::NetworkStatistics>; class PartitionsRepository { public: PartitionsRepository(client::HRN catalog, std::string layer, client::OlpClientSettings settings, client::ApiLookupClient client, NamedMutexStorage storage = NamedMutexStorage()); PartitionsResponse GetVersionedPartitions( const read::PartitionsRequest& request, std::int64_t version, client::CancellationContext context); PartitionsResponse GetVolatilePartitions( const read::PartitionsRequest& request, client::CancellationContext context); QueryApi::PartitionsExtendedResponse GetVersionedPartitionsExtendedResponse( const read::PartitionsRequest& request, std::int64_t version, client::CancellationContext context, bool fail_on_cache_error = false); PartitionsResponse GetPartitionById(const DataRequest& request, boost::optional<int64_t> version, client::CancellationContext context); static model::Partition PartitionFromSubQuad(const model::SubQuad& sub_quad, const std::string& partition); PartitionResponse GetAggregatedTile(TileRequest request, boost::optional<int64_t> version, client::CancellationContext context); PartitionResponse GetTile(const TileRequest& request, boost::optional<int64_t> version, client::CancellationContext context, boost::optional<std::vector<std::string>> additional_fields = boost::none); private: QuadTreeIndexResponse GetQuadTreeIndexForTile( const TileRequest& request, boost::optional<int64_t> version, client::CancellationContext context, boost::optional<std::vector<std::string>> additional_fields = boost::none); PartitionsResponse GetPartitions( const read::PartitionsRequest& request, boost::optional<std::int64_t> version, client::CancellationContext context, boost::optional<time_t> expiry = boost::none); QueryApi::PartitionsExtendedResponse GetPartitionsExtendedResponse( const read::PartitionsRequest& request, boost::optional<std::int64_t> version, client::CancellationContext context, boost::optional<time_t> expiry = boost::none, bool fail_on_cache_error = false); const client::HRN catalog_; const std::string layer_id_; client::OlpClientSettings settings_; client::ApiLookupClient lookup_client_; PartitionsCacheRepository cache_; NamedMutexStorage storage_; }; } // namespace repository } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/VersionsResponse.h
/* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <utility> #include <vector> #include <olp/dataservice/read/DataServiceReadApi.h> #include <olp/dataservice/read/model/VersionsResponseEntry.h> namespace olp { namespace dataservice { namespace read { namespace model { /// Represents a result of the compatible versions request. class DATASERVICE_READ_API VersionsResponse final { public: using VersionsResponseEntries = std::vector<VersionsResponseEntry>; /** * @brief Sets the information on the compatible versions. * * It contains the version numbers and dependencies for the requested catalog. * * @param entries The information on the compatible versions. */ void SetVersionResponseEntries(VersionsResponseEntries entries) { entries_ = std::move(entries); } /** * @brief Gets the information on the compatible versions. * * It contains the version numbers and dependencies for the requested catalog. * * @return The information on the compatible versions. */ const VersionsResponseEntries& GetVersionResponseEntries() const { return entries_; } private: VersionsResponseEntries entries_; }; } // namespace model } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/src/TaskSink.h
/* * Copyright (C) 2020-2021 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <boost/optional.hpp> #include <olp/core/client/CancellationToken.h> #include <olp/core/client/PendingRequests.h> #include <olp/core/client/TaskContext.h> #include <olp/core/thread/TaskScheduler.h> namespace olp { namespace dataservice { namespace read { class TaskSink { public: explicit TaskSink(std::shared_ptr<thread::TaskScheduler> task_scheduler); TaskSink(const TaskSink&) = delete; TaskSink& operator=(const TaskSink&) = delete; ~TaskSink(); void CancelTasks(); client::CancellationToken AddTask( std::function<void(client::CancellationContext)> func, uint32_t priority, client::CancellationContext context); template <typename Function, typename Callback, typename... Args> client::CancellationToken AddTask(Function task, Callback callback, uint32_t priority, Args&&... args) { auto context = client::TaskContext::Create( std::move(task), std::move(callback), std::forward<Args>(args)...); AddTaskImpl(context, priority); return context.CancelToken(); } template <typename Function, typename Callback, typename... Args> boost::optional<client::CancellationToken> AddTaskChecked(Function task, Callback callback, uint32_t priority, Args&&... args) { auto context = client::TaskContext::Create( std::move(task), std::move(callback), std::forward<Args>(args)...); if (!AddTaskImpl(context, priority)) { return boost::none; } return context.CancelToken(); } protected: bool AddTaskImpl(client::TaskContext task, uint32_t priority); bool ScheduleTask(client::TaskContext task, uint32_t priority); const std::shared_ptr<thread::TaskScheduler> task_scheduler_; const std::shared_ptr<client::PendingRequests> pending_requests_; std::mutex mutex_; bool closed_; }; } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/include/olp/core/thread/TaskContinuation.h
/* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <deque> #include <functional> #include <memory> #include <olp/core/client/ApiError.h> #include <olp/core/client/ApiResponse.h> #include <olp/core/client/TaskContext.h> #include <olp/core/thread/Continuation.h> #include <olp/core/thread/ExecutionContext.h> #include <olp/core/thread/TypeHelpers.h> namespace olp { namespace thread { class TaskScheduler; /// Creates a chain of tasks for an asynchronous execution. class CORE_API TaskContinuation final { public: /** * @brief Creates the `TaskContinuation` instance. * * @param scheduler The `TaskScheduler` instance. */ explicit TaskContinuation(std::shared_ptr<thread::TaskScheduler> scheduler); /** * @brief Initializes the `Continuation` object. * * It creates the `Continuation` instance with a template callback * as a parameter, which is the first task in the task continuation chain. * * @param task A task you want to add to the continuation chain. */ template <typename Callable> Continuation<internal::AsyncResultType<Callable>> Then(Callable task); private: std::shared_ptr<thread::TaskScheduler> task_scheduler_; ExecutionContext execution_context_; }; } // namespace thread } // namespace olp #include "TaskContinuation.inl"
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-authentication/src/ResponseFromJsonBuilder.h
/* * Copyright (C) 2020-2021 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <olp/core/logging/Log.h> #include <boost/core/typeinfo.hpp> namespace olp { namespace authentication { namespace detail { struct Identity { template <typename T> T&& operator()(T&& t) const { return std::forward<T>(t); } }; } // namespace detail template <typename ResponseType> class ResponseFromJsonBuilder { using JsonValue = rapidjson::Document::ValueType; public: template <typename TargetType> class BuilderHelper { // -fno-rtti friendly way to get classname const std::string kTargetTypeName = boost::core::demangled_name(BOOST_CORE_TYPEID(TargetType)); const std::string kLogTag = "ResponseFromJsonBuilder"; public: explicit BuilderHelper(const JsonValue& json_value) : json_{json_value} {} template <typename ArgType, typename Projection = detail::Identity> BuilderHelper& Value(const char* name, void (TargetType::*set_fn)(ArgType), Projection projection = {}) { using CompatibleType = decltype(GetCompatibleType<ArgType>()); fields_.emplace(name, [=](TargetType& target_obj, const JsonValue& value) { if (value.Is<CompatibleType>()) { (target_obj.*set_fn)(projection(value.Get<CompatibleType>())); } else { OLP_SDK_LOG_WARNING_F(kLogTag, "Wrong type, response=%s, field=%s", kTargetTypeName.c_str(), name); } }); return *this; } template <typename ArrayType> BuilderHelper& Array(const char* name, void (TargetType::*set_fn)(ArrayType)) { using CompatibleType = decltype(GetCompatibleType<typename ArrayType::value_type>()); fields_.emplace(name, [=](TargetType& target_obj, const JsonValue& value) { if (value.IsArray()) { const auto& array = value.GetArray(); ArrayType array_result; array_result.reserve(array.Size()); for (const auto& element : array) { if (element.Is<CompatibleType>()) { array_result.push_back(element.Get<CompatibleType>()); } } (target_obj.*set_fn)(std::move(array_result)); } else { OLP_SDK_LOG_WARNING_F(kLogTag, "Wrong type, response=%s, field=%s", kTargetTypeName.c_str(), name); } }); return *this; } TargetType Finish() { TargetType result; auto it = json_.MemberBegin(); auto it_end = json_.MemberEnd(); for (; it != it_end; ++it) { auto find_it = fields_.find(std::string{it->name.GetString()}); if (find_it != fields_.end()) { find_it->second(result, it->value); // erasing already processed value fields_.erase(find_it); continue; } OLP_SDK_LOG_WARNING_F(kLogTag, "Unexpected value, response=%s, field=%s", kTargetTypeName.c_str(), it->name.GetString()); } // in the ideal scenario all fields should be processed for (const auto& field : fields_) { OLP_SDK_LOG_WARNING_F(kLogTag, "Absent value, response=%s, field=%s", kTargetTypeName.c_str(), field.first.c_str()); } return result; } private: template <typename T, typename = typename std::enable_if< std::is_integral<T>::value && !std::is_enum<T>::value && !std::is_same<T, long>::value>::type> T GetCompatibleType(); template <typename T, typename = typename std::enable_if<!std::is_integral<T>::value || std::is_enum<T>::value>::type> const char* GetCompatibleType(); template <typename T, typename = typename std::enable_if< std::is_same<T, long>::value>::type> int64_t GetCompatibleType(); using Fields = std::unordered_map<std::string, std::function<void(TargetType&, const JsonValue&)>>; const JsonValue& json_; Fields fields_; }; template <typename JsonType> static BuilderHelper<ResponseType> Build(const JsonType& json) { return BuilderHelper<ResponseType>{json}; } }; } // namespace authentication } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-authentication/include/olp/authentication/TokenProvider.h
<reponame>heremaps/here-olp-edge-sdk-cpp<gh_stars>10-100 /* * Copyright (C) 2019-2021 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <chrono> #include <memory> #include <string> #include <utility> #include <olp/authentication/AuthenticationCredentials.h> #include <olp/authentication/ErrorResponse.h> #include <olp/authentication/Settings.h> #include <olp/authentication/Types.h> #include <olp/core/client/CancellationContext.h> #include <olp/core/client/OauthToken.h> #include <olp/core/http/HttpStatusCode.h> namespace olp { namespace authentication { static constexpr auto kDefaultMinimumValidity = 300ll; static constexpr auto kDefaultMinimumValiditySeconds = std::chrono::seconds(kDefaultMinimumValidity); static constexpr auto kForceRefresh = std::chrono::seconds(0); namespace internal { class TokenProviderPrivate; /// An implementation of `TokenProvider`. /// @note This is a private implementation class for internal use only, and not /// bound to any API stability promises. Please do not use directly. class AUTHENTICATION_API TokenProviderImpl { public: /** * @brief Creates the `TokenProviderImpl` instance. * * @param settings The `Settings` object that is used to customize * the `TokenEndpoint` instance. * @param minimum_validity Sets the minimum validity period of * the token in seconds. */ TokenProviderImpl(Settings settings, std::chrono::seconds minimum_validity); /// @copydoc TokenProvider::operator()() std::string operator()() const; /// @copydoc TokenProvider::operator()(client::CancellationContext&) client::OauthTokenResponse operator()( client::CancellationContext& context) const; /// @copydoc TokenProvider::GetErrorResponse() ErrorResponse GetErrorResponse() const; /// @copydoc TokenProvider::GetHttpStatusCode() int GetHttpStatusCode() const; /// @copydoc TokenProvider::GetResponse()(client::CancellationContext&) TokenResponse GetResponse(client::CancellationContext& context) const; /// @copydoc TokenProvider::IsTokenResponseOK() bool IsTokenResponseOK() const; private: std::shared_ptr<TokenProviderPrivate> impl_; }; } // namespace internal /** * @brief Provides the authentication tokens if the HERE platform * user credentials are valid. * * @tparam MinimumValidity The minimum token validity time (in seconds). * To use the default `MinimumValidity` value, use the `TokenProviderDefault` * typedef. * * @see `TokenProviderDefault` */ template <uint64_t MinimumValidity> class TokenProvider { public: /** * @brief Creates the `TokenProvider` instance with the `settings` parameter. * * @param settings The settings that can be used to configure * the `TokenEndpoint` instance. */ explicit TokenProvider(Settings settings) : impl_(std::make_shared<internal::TokenProviderImpl>( std::move(settings), std::chrono::seconds(MinimumValidity))) {} /// A default copy constructor. TokenProvider(const TokenProvider& other) = default; /// A default move constructor. TokenProvider(TokenProvider&& other) noexcept = default; /// A default copy assignment operator. TokenProvider& operator=(const TokenProvider& other) = default; /// A default move assignment operator. TokenProvider& operator=(TokenProvider&& other) noexcept = default; /** * @brief Casts the `TokenProvider` instance to the `bool` type. * * Returns true if the previous token request was successful. * * @returns True if the previous token request was successful; false * otherwise. */ operator bool() const { return impl_->IsTokenResponseOK(); } /** * @brief Casts the `TokenProvider` instance to the `std::string` type. * * Returns the access token string if the response is successful. Otherwise, * returns an empty string. * * @returns The access token string if the response is successful; an empty * string otherwise. * * @deprecated Will be removed by 10.2022. Use the operator with * `CancellationContext` instead. */ OLP_SDK_DEPRECATED( "Will be removed by 10.2022. Use the operator with `CancellationContext` " "instead.") std::string operator()() const { return impl_->operator()(); } /** * @brief Returns the access token or an error. * * @param context Used to cancel the pending token request. * * @returns An `OauthTokenResponse` if the response is successful; an * `ApiError` otherwise. */ client::OauthTokenResponse operator()( client::CancellationContext& context) const { return impl_->operator()(context); } /** * @brief Allows the `olp::client::ApiError` object associated * with the last request to be accessed if the token request is unsuccessful. * * @returns An error if the last token request failed. */ ErrorResponse GetErrorResponse() const { return impl_->GetErrorResponse(); } /** * @brief Gets the HTTP status code of the last request. * * @returns The HTTP code of the last token request if it was successful. * Otherwise, returns the HTTP 503 Service Unavailable server error. */ int GetHttpStatusCode() const { return impl_->GetHttpStatusCode(); } private: std::shared_ptr<internal::TokenProviderImpl> impl_; }; /// Provides the authentication tokens using the default minimum token /// validity. using TokenProviderDefault = TokenProvider<kDefaultMinimumValidity>; } // namespace authentication } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/src/CatalogClientImpl.h
/* * Copyright (C) 2019-2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <future> #include <memory> #include <olp/core/client/ApiLookupClient.h> #include <olp/core/client/CancellationToken.h> #include <olp/core/client/HRN.h> #include <olp/core/client/OlpClientSettings.h> #include <olp/dataservice/read/CatalogRequest.h> #include <olp/dataservice/read/CatalogVersionRequest.h> #include <olp/dataservice/read/CompatibleVersionsRequest.h> #include <olp/dataservice/read/Types.h> #include <olp/dataservice/read/VersionsRequest.h> #include "TaskSink.h" namespace olp { namespace client { class OlpClient; struct OlpClientSettings; class PendingRequests; } // namespace client namespace dataservice { namespace read { namespace repository { class CatalogRepository; } // namespace repository class CatalogClientImpl final { public: CatalogClientImpl(client::HRN catalog, client::OlpClientSettings settings); bool CancelPendingRequests(); client::CancellationToken GetCatalog(CatalogRequest request, CatalogResponseCallback callback); client::CancellableFuture<CatalogResponse> GetCatalog(CatalogRequest request); client::CancellationToken GetLatestVersion(CatalogVersionRequest request, CatalogVersionCallback callback); client::CancellableFuture<CatalogVersionResponse> GetLatestVersion( CatalogVersionRequest request); client::CancellationToken ListVersions(VersionsRequest request, VersionsResponseCallback callback); client::CancellableFuture<VersionsResponse> ListVersions( VersionsRequest request); client::CancellationToken GetCompatibleVersions( CompatibleVersionsRequest request, CompatibleVersionsCallback callback); client::CancellableFuture<CompatibleVersionsResponse> GetCompatibleVersions( CompatibleVersionsRequest request); private: client::HRN catalog_; client::OlpClientSettings settings_; client::ApiLookupClient lookup_client_; TaskSink task_sink_; }; } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/model/VersionsResponseEntry.h
/* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <utility> #include <vector> #include <olp/dataservice/read/DataServiceReadApi.h> #include <olp/dataservice/read/model/CatalogVersion.h> namespace olp { namespace dataservice { namespace read { namespace model { /// Represents dependencies for the given catalog version. class DATASERVICE_READ_API VersionsResponseEntry { public: using CatalogVersions = std::vector<CatalogVersion>; /** * @brief Sets the information on the dependencies. * * @param catalog_versions The information of the dependencies. */ void SetCatalogVersions(CatalogVersions catalog_versions) { catalog_versions_ = std::move(catalog_versions); } /** * @brief Gets the information on the compatible versions. * * @return The information on the compatible versions. */ const CatalogVersions& GetCatalogVersions() const { return catalog_versions_; } /** * @brief Gets the version of the catalog. * * @return The version of the catalog. */ int64_t GetVersion() const { return version_; } /** * @brief Sets the version of the catalog. * * @param version The version of the catalog. */ void SetVersion(int64_t version) { version_ = version; } private: int64_t version_{0}; CatalogVersions catalog_versions_; }; } // namespace model } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/CompatibleVersionsRequest.h
/* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <olp/dataservice/read/DataServiceReadApi.h> #include <olp/dataservice/read/model/CatalogVersion.h> #include <utility> #include <vector> namespace olp { namespace dataservice { namespace read { /** * @brief Contains fields required to request compatible versions for * the given catalog. */ class DATASERVICE_READ_API CompatibleVersionsRequest final { public: using Dependencies = std::vector<model::CatalogVersion>; /** * @brief Gets the dependencies for the catalog versions compatibility check. * * @return The dependencies for the catalog versions compatibility check. */ inline const Dependencies& GetDependencies() const { return dependencies_; } /** * @brief Sets the dependencies to check the catalog versions for * compatibility. * * @param dependencies The dependencies for the catalog versions * compatibility check. * * @return A reference to the updated `CompatibleVersionsRequest` instance. */ inline CompatibleVersionsRequest& WithDependencies( Dependencies dependencies) { dependencies_ = std::move(dependencies); return *this; } /** * @brief Gets the maximum amount of versions available in the response. * * @return The maximum amount of versions available in the response. */ inline int32_t GetLimit() const { return limit_; } /** * @brief Sets the maximum amount of versions available in the * response. * * @param limit The maximum amount of versions available in the * response. The default limit is 1. * * @return A reference to the updated `CompatibleVersionsRequest` instance. */ inline CompatibleVersionsRequest& WithLimit(int32_t limit) { limit_ = limit; return *this; } private: Dependencies dependencies_; int32_t limit_{1}; }; } // namespace read } // namespace dataservice } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/include/olp/core/thread/TypeHelpers.h
/* * Copyright (C) 2022 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <functional> #include <type_traits> #include <vector> #include <olp/core/client/ApiError.h> #include <olp/core/porting/make_unique.h> namespace olp { namespace thread { namespace internal { /// A helper class removes type qualifiers and provides a type. template <typename Type> struct RemoveRefAndConstImpl { using type = typename std::remove_cv<typename std::remove_reference<Type>::type>::type; }; /// A template for a type without type qualifiers template <typename Type> using RemoveRefAndConst = typename RemoveRefAndConstImpl<Type>::type; /// Helper class which provides a type only /// if `Type` and std::vector<void> name the same /// type (taking into account const/volatile qualifications). template <typename Type> struct ReduceVoidVector { using type = typename std::conditional<std::is_same<Type, std::vector<void>>::value, void, Type>::type; }; /// A class for wrapping a type with std::function. template <typename Type> struct TypeToFunctionInputImpl { using type = std::function<void(Type)>; }; /// A class for wrapping a void type with std::function. template <> struct TypeToFunctionInputImpl<void> { using type = std::function<void()>; }; template <typename Type> /// An alias for a std::function wrapper around the `Type`. using TypeToFunctionInput = typename TypeToFunctionInputImpl<Type>::type; template <typename Class, typename ExecutionContext, typename Arg> /// A const function pointer with two parameters used to declare a type. Arg SecondArgType(void (Class::*)(ExecutionContext, Arg) const); template <typename Class, typename ExecutionContext, typename Arg> /// A function pointer with two parameters used to declare a type. Arg SecondArgType(void (Class::*)(ExecutionContext, Arg)); template <typename Class, typename Some, typename ExecutionContext, typename Arg> /// A const function pointer with three parameters used to declare a type. Arg ThirdArgType(void (Class::*)(Some, ExecutionContext, Arg) const); template <typename Class, typename Some, typename ExecutionContext, typename Arg> /// A function pointer with three parameters used to declare a type. Arg ThirdArgType(void (Class::*)(Some, ExecutionContext, Arg)); /// A function declaration with std::function<void> parameter. void FuncArgType(std::function<void()>); /// A template function declaration with std::function<Arg> parameter. template <typename Arg> Arg FuncArgType(std::function<void(Arg)>); template <typename Callable> /// Declares the type of a callable with two parameters. struct AsyncResultTypeImpl { using FirstArgType = RemoveRefAndConst<decltype(SecondArgType(&Callable::operator()))>; using type = RemoveRefAndConst<decltype(FuncArgType(FirstArgType()))>; }; template <typename Callable> /// An alias for the `Type` from callable object with two parameters. using AsyncResultType = typename AsyncResultTypeImpl<Callable>::type; template <typename Callable> /// Declares the type of a callable with three parameters. struct DeducedTypeImpl { using ThirdArgTypeParam = RemoveRefAndConst<decltype(ThirdArgType(&Callable::operator()))>; using type = RemoveRefAndConst<decltype(FuncArgType(ThirdArgTypeParam()))>; }; template <typename Callable> /// An alias for the `Type` from callable object with three parameters. using DeducedType = typename DeducedTypeImpl<Callable>::type; /// An interface for untyped pointer which allows /// to convert any data type to a void pointer. struct UntypedSmartPointer { virtual void* Get() const = 0; virtual ~UntypedSmartPointer() = default; }; /// An implementation of `UntypedSmartPointer` interface. template <typename SmartPointer> struct TypedSmartPointer : UntypedSmartPointer { /// A move contructor. explicit TypedSmartPointer(SmartPointer&& pointer) : pointer_(std::move(pointer)) {} /// Method converts data to a void pointer. void* Get() const override { return static_cast<void*>(pointer_.get()); } SmartPointer pointer_; }; /// A function wraps a void pointer with a unique pointer. template <typename SmartPointer> inline std::unique_ptr<UntypedSmartPointer> MakeUntypedUnique( SmartPointer&& ptr) { return std::make_unique<TypedSmartPointer<SmartPointer>>(std::move(ptr)); } } // namespace internal } // namespace thread } // namespace olp
heremaps/here-olp-edge-sdk-cpp
olp-cpp-sdk-core/include/olp/core/logging/Format.h
/* * Copyright (C) 2019 HERE Europe B.V. * * 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. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #pragma once #include <olp/core/CoreApi.h> #include <chrono> #include <cstdarg> #include <string> #include <vector> #if (defined(__GNUC__) || defined(__clang__)) #define CHECK_PRINTF_FORMAT_STRING(format_string_pos, first_to_check) \ __attribute__((format(printf, (format_string_pos), (first_to_check)))) #else #define CHECK_PRINTF_FORMAT_STRING(format_string_pos, first_to_check) #endif namespace olp { namespace logging { /** * @brief A typedef for a time point from the system clock. */ using TimePoint = std::chrono::time_point<std::chrono::system_clock>; /** * @brief Formats a string using a printf-style format string. * * @param formatStr The format string. * * @return The formatted string. */ CORE_API std::string format(const char* formatStr, ...) CHECK_PRINTF_FORMAT_STRING(1, 2); /** * @brief Formats a string using a printf-style format string with an already * created `va_list` object. * * @param formatStr The format string. * @param args The `va_list` object that contains the arguments. * * @return The formatted string. */ CORE_API std::string formatv(const char* formatStr, va_list args); /** * @brief Creates a string for a timestamp using local time with the default * format string. * * The default format string is `%Y-%m-%d %H:%M:%S`. * * @param timestamp The timestamp to format as seconds from epoch. * * @return The formatted string. */ CORE_API std::string formatLocalTime(const TimePoint& timestamp); /** * @brief Creates a string for a timestamp using local time. * * @param timestamp The timestamp to format as seconds from epoch. * @param formatStr The format string to use, conforming to `strftime`. * * @return The formatted string. */ CORE_API std::string formatLocalTime(const TimePoint& timestamp, const char* formatStr); /** * @brief Creates a string for a timestamp using the UTC time standard with the * default format string. * * The default format string is `%Y-%m-%d %H:%M:%S`. * * @param timestamp The timestamp to format as seconds from epoch. * * @return The formatted string. */ CORE_API std::string formatUtcTime(const TimePoint& timestamp); /** * @brief Creates a string for a timestamp using the UTC time standard. * * @param timestamp The timestamp to format as seconds from epoch. * @param formatStr The format string to use, conforming to `strftime`. * * @return The formatted string. */ CORE_API std::string formatUtcTime(const TimePoint& timestamp, const char* formatStr); /** * @brief Attempts to format a string to a buffer before falling back * to a dynamically allocated string. * * This can be used to avoid allocating `std::string` for smaller strings. */ class CORE_API FormatBuffer { public: FormatBuffer() = default; /** * @brief Formats a string using a printf-style format string. * * @param formatStr The format string. * * @return The formatted string. */ const char* format(const char* formatStr, ...) CHECK_PRINTF_FORMAT_STRING(2, 3); /** * @brief Formats a string using a printf-style format string with an already * created `va_list`. * * @param formatStr The format string. * @param args The va_list that contains the arguments. * * @return The formatted string. */ const char* formatv(const char* formatStr, va_list args); /** * @brief Creates a string for a timestamp using local time with the default * format string. * * The default format string is `%Y-%m-%d %H:%M:%S`. * * @param timestamp The timestamp to format as seconds from epoch. * * @return The formatted string. */ const char* formatLocalTime(const TimePoint& timestamp); /** * @brief Creates a string for a timestamp using local time. * * @param timestamp The timestamp to format as seconds from epoch. * @param formatStr The format string to use, conforming to strftime. * * @return The formatted string. */ const char* formatLocalTime(const TimePoint& timestamp, const char* formatStr); /** * @brief Creates a string for a timestamp using the UTC time standard with * the default format string. * * The default format string is `%Y-%m-%d %H:%M:%S`. * * @param timestamp The timestamp to format as seconds from epoch. * * @return The formatted string. */ const char* formatUtcTime(const TimePoint& timestamp); /** * @brief Creates a string for a timestamp using the UTC time standard. * * @param timestamp The timestamp to format as seconds from epoch. * @param formatStr The format string to use, conforming to strftime. * * @return The formatted string. */ const char* formatUtcTime(const TimePoint& timestamp, const char* formatStr); private: friend std::string logging::formatv(const char* formatStr, va_list args); const char* formatTm(const struct tm& timestampTm, const char* formatStr); static const unsigned int bufferSize = 256; char m_buffer[bufferSize]{}; std::vector<char> m_auxBuffer; }; } // namespace logging } // namespace olp
InTeach/react-native-spotlight
example/example/ios/Build/Products/Release-iphonesimulator/example.app/Frameworks/XCTest.framework/Headers/XCAbstractTest.h
// // Copyright (c) 2013-2015 Apple Inc. All rights reserved. // // Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved. // // Use of this source code is governed by the following license: // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // (1) Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // (2) Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY 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 Sente SA 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. // // Note: this license is equivalent to the FreeBSD license. // // This notice may not be removed from this file. #import <XCTest/XCTestDefines.h> NS_ASSUME_NONNULL_BEGIN @class XCTestRun; /*! * @class XCTest * * An abstract base class for testing. XCTestCase and XCTestSuite extend XCTest to provide * for creating, managing, and executing tests. Most developers will not need to subclass * XCTest directly. */ @interface XCTest : NSObject { #ifndef __OBJC2__ @private id _internal; #endif } /*! * @property testCaseCount * Number of test cases. Must be overridden by subclasses. */ @property (readonly) NSUInteger testCaseCount; /*! * @property name * Test's name. Must be overridden by subclasses. */ @property (readonly, copy, nullable) NSString *name; /*! * @property testRunClass * The XCTestRun subclass that will be instantiated when the test is run to hold * the test's results. Must be overridden by subclasses. */ @property (readonly, nullable) Class testRunClass; /*! * @property testRun * The test run object that executed the test, an instance of testRunClass. If the test has not yet been run, this will be nil. */ #if XCT_NULLABLE_AVAILABLE @property (readonly, nullable) XCTestRun *testRun; #else @property (readonly) XCTestRun *testRun; #endif /*! * @method -performTest: * The method through which tests are executed. Must be overridden by subclasses. */ - (void)performTest:(XCTestRun *)run; /*! * @method -run * Deprecated: use -runTest instead. */ - (XCTestRun *)run DEPRECATED_ATTRIBUTE; /*! * @method -runTest * Creates an instance of the testRunClass and passes it as a parameter to -performTest:. */ - (void)runTest; /*! * @method -setUp * Setup method called before the invocation of each test method in the class. */ - (void)setUp; /*! * @method -tearDown * Teardown method called after the invocation of each test method in the class. */ - (void)tearDown; @end NS_ASSUME_NONNULL_END
InTeach/react-native-spotlight
example/example/ios/Build/Products/Release-iphonesimulator/example.app/Frameworks/XCTest.framework/Headers/XCUIElementTypeQueryProvider.h
// // Copyright (c) 2015 Apple Inc. All rights reserved. // #import <XCTest/XCTestDefines.h> #if XCT_UI_TESTING_AVAILABLE NS_ASSUME_NONNULL_BEGIN @class XCUIElementQuery; @protocol XCUIElementTypeQueryProvider @property (readonly, copy) XCUIElementQuery *groups; @property (readonly, copy) XCUIElementQuery *windows; @property (readonly, copy) XCUIElementQuery *sheets; @property (readonly, copy) XCUIElementQuery *drawers; @property (readonly, copy) XCUIElementQuery *alerts; @property (readonly, copy) XCUIElementQuery *dialogs; @property (readonly, copy) XCUIElementQuery *buttons; @property (readonly, copy) XCUIElementQuery *radioButtons; @property (readonly, copy) XCUIElementQuery *radioGroups; @property (readonly, copy) XCUIElementQuery *checkBoxes; @property (readonly, copy) XCUIElementQuery *disclosureTriangles; @property (readonly, copy) XCUIElementQuery *popUpButtons; @property (readonly, copy) XCUIElementQuery *comboBoxes; @property (readonly, copy) XCUIElementQuery *menuButtons; @property (readonly, copy) XCUIElementQuery *toolbarButtons; @property (readonly, copy) XCUIElementQuery *popovers; @property (readonly, copy) XCUIElementQuery *keyboards; @property (readonly, copy) XCUIElementQuery *keys; @property (readonly, copy) XCUIElementQuery *navigationBars; @property (readonly, copy) XCUIElementQuery *tabBars; @property (readonly, copy) XCUIElementQuery *tabGroups; @property (readonly, copy) XCUIElementQuery *toolbars; @property (readonly, copy) XCUIElementQuery *statusBars; @property (readonly, copy) XCUIElementQuery *tables; @property (readonly, copy) XCUIElementQuery *tableRows; @property (readonly, copy) XCUIElementQuery *tableColumns; @property (readonly, copy) XCUIElementQuery *outlines; @property (readonly, copy) XCUIElementQuery *outlineRows; @property (readonly, copy) XCUIElementQuery *browsers; @property (readonly, copy) XCUIElementQuery *collectionViews; @property (readonly, copy) XCUIElementQuery *sliders; @property (readonly, copy) XCUIElementQuery *pageIndicators; @property (readonly, copy) XCUIElementQuery *progressIndicators; @property (readonly, copy) XCUIElementQuery *activityIndicators; @property (readonly, copy) XCUIElementQuery *segmentedControls; @property (readonly, copy) XCUIElementQuery *pickers; @property (readonly, copy) XCUIElementQuery *pickerWheels; @property (readonly, copy) XCUIElementQuery *switches; @property (readonly, copy) XCUIElementQuery *toggles; @property (readonly, copy) XCUIElementQuery *links; @property (readonly, copy) XCUIElementQuery *images; @property (readonly, copy) XCUIElementQuery *icons; @property (readonly, copy) XCUIElementQuery *searchFields; @property (readonly, copy) XCUIElementQuery *scrollViews; @property (readonly, copy) XCUIElementQuery *scrollBars; @property (readonly, copy) XCUIElementQuery *staticTexts; @property (readonly, copy) XCUIElementQuery *textFields; @property (readonly, copy) XCUIElementQuery *secureTextFields; @property (readonly, copy) XCUIElementQuery *datePickers; @property (readonly, copy) XCUIElementQuery *textViews; @property (readonly, copy) XCUIElementQuery *menus; @property (readonly, copy) XCUIElementQuery *menuItems; @property (readonly, copy) XCUIElementQuery *menuBars; @property (readonly, copy) XCUIElementQuery *menuBarItems; @property (readonly, copy) XCUIElementQuery *maps; @property (readonly, copy) XCUIElementQuery *webViews; @property (readonly, copy) XCUIElementQuery *steppers; @property (readonly, copy) XCUIElementQuery *incrementArrows; @property (readonly, copy) XCUIElementQuery *decrementArrows; @property (readonly, copy) XCUIElementQuery *tabs; @property (readonly, copy) XCUIElementQuery *timelines; @property (readonly, copy) XCUIElementQuery *ratingIndicators; @property (readonly, copy) XCUIElementQuery *valueIndicators; @property (readonly, copy) XCUIElementQuery *splitGroups; @property (readonly, copy) XCUIElementQuery *splitters; @property (readonly, copy) XCUIElementQuery *relevanceIndicators; @property (readonly, copy) XCUIElementQuery *colorWells; @property (readonly, copy) XCUIElementQuery *helpTags; @property (readonly, copy) XCUIElementQuery *mattes; @property (readonly, copy) XCUIElementQuery *dockItems; @property (readonly, copy) XCUIElementQuery *rulers; @property (readonly, copy) XCUIElementQuery *rulerMarkers; @property (readonly, copy) XCUIElementQuery *grids; @property (readonly, copy) XCUIElementQuery *levelIndicators; @property (readonly, copy) XCUIElementQuery *cells; @property (readonly, copy) XCUIElementQuery *layoutAreas; @property (readonly, copy) XCUIElementQuery *layoutItems; @property (readonly, copy) XCUIElementQuery *handles; @property (readonly, copy) XCUIElementQuery *otherElements; @end NS_ASSUME_NONNULL_END #endif
InTeach/react-native-spotlight
ios/RCTSpotlightSearch/RCTSpotlightSearch/RCTSpotlightSearch.h
// // RCTSpotlightSearch.h // RCTSpotlightSearch // // Created by James (Home) on 21/06/2016. // Copyright © 2016 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <React/RCTBridgeModule.h> @interface RCTSpotlightSearch : NSObject <RCTBridgeModule> + (void)handleContinueUserActivity:(NSUserActivity *)userActivity; //+ (void)setInitialSearch:(NSString *)search; @end
joho/sorbet
main/lsp/TimeTravelingGlobalState.h
#ifndef RUBY_TYPER_LSP_TIMETRAVELINGGLOBALSTATE_H #define RUBY_TYPER_LSP_TIMETRAVELINGGLOBALSTATE_H #include "common/common.h" #include "common/concurrency/WorkerPool.h" #include "common/kvstore/KeyValueStore.h" #include "core/NameHash.h" #include "core/core.h" #include "main/lsp/LSPConfiguration.h" #include "main/lsp/json_types.h" #include <deque> namespace sorbet::realmain::lsp { /** * A class that encloses a global state and allows one to 'time-travel' it between versions. * It also time-travels an array of file hashes corresponding to the files in the time-traveled global state. * Updates cannot be re-ordered, so updates that are undone are assumed to eventually become re-applied. * Progressing past `index` isn't supported. Actual naming/resolving/typechecking should be done on deep copies */ class TimeTravelingGlobalState final { private: // Contains file updates and their respective hash updates. struct GlobalStateUpdate { std::vector<std::shared_ptr<core::File>> fileUpdates; std::vector<core::FileHash> hashUpdates; }; /** * An undo/redo log entry for message with internal id `messageId`. * Applying the updates to initialGS will apply or undo the edit with that messageId, depending on if it is in the * undo or redo log. */ struct TimeTravelUpdate { u4 version = 0; bool hasNewFiles; GlobalStateUpdate update; GlobalStateUpdate undoUpdate; }; const LSPConfiguration config; std::shared_ptr<spdlog::logger> logger; WorkerPool &workers; std::unique_ptr<KeyValueStore> kvstore; // always null for now. std::unique_ptr<core::GlobalState> gs; // Indicates the current version of `gs`. May be a version that comes before `latestVersion` if `gs` has traveled // back in time. u4 activeVersion = 0; // Indicates the version number of the latest file update encountered. It has been committed to the `log`. u4 latestVersion = 0; // Get all updates that fall within the range (start, end), exclusive of endpoints. std::vector<TimeTravelUpdate *> updatesBetweenExclusive(u4 start, u4 end); // Log of applied updates, from earliest to latest. // We frequently delete from the back to prune history, so we use a deque rather than a vector. std::deque<TimeTravelUpdate> log; // Contains file hashes for the current version of global state. std::vector<core::FileHash> globalStateHashes; // Internal function: Applies given update (or undoes it) and appropriately updates `activeVersion`. std::vector<core::FileRef> applyUpdate(TimeTravelUpdate &update, bool undo); std::vector<core::FileHash> computeStateHashes(const std::vector<std::shared_ptr<core::File>> &files) const; public: TimeTravelingGlobalState(const LSPConfiguration &config, const std::shared_ptr<spdlog::logger> &logger, WorkerPool &workers, std::unique_ptr<core::GlobalState> gs, u4 initialVersion); /** * Travels GlobalState forwards and backwards in time. No-op if version == current version. */ void travel(u4 version); /** * Indicates that TTGS operations will happen on a new thread. Used to work around error queue ENFORCEs. */ void switchToNewThread(); const core::GlobalState &getGlobalState() const; const std::vector<core::FileHash> &getGlobalStateHashes() const; /** * Prunes entries in the time travel log that fall before version. * Note: Supports a version ID that wraps around. */ void pruneBefore(u4 version); /** * Applies the given update to GlobalState, appends a corresponding entry to the undo log, and indexes the update. * Mutates update to include file hashes and indexes. */ void commitEdits(LSPFileUpdates &update); /** * Indexes all workspace files from file system and hashes them. * This runs code that is not considered performance critical and this is expected to be slow. */ std::vector<ast::ParsedFile> indexFromFileSystem(); /** * Returns `true` if the given changes can run on the fast path relative to the provided version of global state. * Only requires `updatedFileHashes` and `updatedFiles`. * * TODO(jvilk): Return reason and track slow path stats. */ bool canTakeFastPath(u4 fromVersion, const LSPFileUpdates &updates); /** * Get a combined LSPFileUpdates containing edits from [fromId, toId] (inclusive). */ LSPFileUpdates getCombinedUpdates(u4 fromId, u4 toId); /** * Returns true if `a` comes before `b`. */ bool comesBefore(u4 a, u4 b) const; }; } // namespace sorbet::realmain::lsp #endif // RUBY_TYPER_LSP_TIMETRAVELINGGLOBALSTATE_H
Lazauya/cuberite
src/Blocks/BlockBed.h
// BlockBed.h #pragma once #include "BlockEntity.h" #include "Mixins.h" #include "ChunkInterface.h" class cEntity; class cPlayer; class cWorldInterface; class cBlockBedHandler : public cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01> { using super = cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01>; public: cBlockBedHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } // Overrides: virtual void OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) override; virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override; virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, const sSetBlock & a_BlockChange) override; static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData) { switch (a_MetaData) { case 0: return Vector3i( 0, 0, 1); case 1: return Vector3i(-1, 0, 0); case 2: return Vector3i( 0, 0, -1); case 3: return Vector3i( 1, 0, 0); } return Vector3i(); } static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, Vector3i a_BedPosition, bool a_IsOccupied) { auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition); if (a_IsOccupied) { Meta |= 0x04; // Where 0x4 = occupied bit } else { Meta &= 0x0b; // Clear the "occupied" bit of the bed's block } a_ChunkInterface.SetBlockMeta(a_BedPosition, Meta); } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 28; } } ;
Lazauya/cuberite
src/Blocks/BlockBrewingStand.h
#pragma once #include "../BlockEntities/BrewingstandEntity.h" #include "Mixins.h" class cBlockBrewingStandHandler : public cBlockEntityHandler { using super = cBlockEntityHandler; public: cBlockBrewingStandHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { cItems res(cItem(E_ITEM_BREWING_STAND, 1)); // We have to drop the item form of a brewing stand if (a_BlockEntity != nullptr) { auto be = static_cast<cBrewingstandEntity *>(a_BlockEntity); res.AddItemGrid(be->GetContents()); } return res; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 6; } } ;
Lazauya/cuberite
src/Blocks/BlockFenceGate.h
#pragma once #include "BlockHandler.h" #include "Mixins.h" #include "../EffectID.h" class cBlockFenceGateHandler : public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>> { using super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x02, 0x03, 0x00, 0x01>>; public: cBlockFenceGateHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}); NIBBLETYPE NewMetaData = YawToMetaData(a_Player.GetYaw()); OldMetaData ^= 4; // Toggle the gate if ((OldMetaData & 1) == (NewMetaData & 1)) { // Standing in front of the gate - apply new direction a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (OldMetaData & 4) | (NewMetaData & 3)); } else { // Standing aside - use last direction a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData); } a_Player.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_FENCE_GATE_OPEN, {a_BlockX, a_BlockY, a_BlockZ}, 0, a_Player.GetClientHandle()); return true; } virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); } virtual bool IsUseable(void) override { return true; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); switch (m_BlockType) { case E_BLOCK_OAK_FENCE_GATE: return 13; case E_BLOCK_SPRUCE_FENCE_GATE: return 34; case E_BLOCK_BIRCH_FENCE_GATE: return 2; case E_BLOCK_JUNGLE_FENCE_GATE: return 10; case E_BLOCK_DARK_OAK_FENCE_GATE: return 26; case E_BLOCK_ACACIA_FENCE_GATE: return 15; default: { ASSERT(!"Unhandled blocktype in fence gate handler!"); return 0; } } } } ;
Lazauya/cuberite
src/Entities/FallingBlock.h
#pragma once #include "Entity.h" // tolua_begin class cFallingBlock : public cEntity { // tolua_end using super = cEntity; public: // tolua_export CLASS_PROTODEF(cFallingBlock) /** Creates a new falling block. a_Position is expected in world coords */ cFallingBlock(Vector3d a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_begin BLOCKTYPE GetBlockType(void) const { return m_BlockType; } NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; } // tolua_end // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; private: BLOCKTYPE m_BlockType; NIBBLETYPE m_BlockMeta; } ; // tolua_export
Lazauya/cuberite
src/Blocks/BlockObserver.h
#pragma once #include "BlockHandler.h" #include "Mixins.h" class cBlockObserverHandler: public cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>> { using super = cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>>; public: cBlockObserverHandler(BLOCKTYPE a_BlockType) : super(a_BlockType) { } };
Lazauya/cuberite
src/Blocks/BlockComparator.h
#pragma once #include "BlockHandler.h" #include "BlockRedstoneRepeater.h" #include "Mixins.h" class cBlockComparatorHandler : public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> { using super = cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>; public: cBlockComparatorHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}); Meta ^= 0x04; // Toggle 3rd (addition / subtraction) bit with XOR a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); return true; } virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { UNUSED(a_ChunkInterface); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); } virtual bool IsUseable(void) override { return true; } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { return cItem(E_ITEM_COMPARATOR, 1, 0); } inline static bool IsInSubtractionMode(NIBBLETYPE a_Meta) { return ((a_Meta & 0x4) == 0x4); } inline static bool IsOn(NIBBLETYPE a_Meta) { return ((a_Meta & 0x8) == 0x8); } inline static Vector3i GetSideCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta, bool a_bInverse) { if (!a_bInverse) { switch (a_Meta) { case 0x0: a_Position.x++; break; case 0x1: a_Position.z--; break; case 0x2: a_Position.x--; break; case 0x3: a_Position.z++; break; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of comparator!"); break; } } } else { switch (a_Meta) { case 0x0: a_Position.x--; break; case 0x1: a_Position.z++; break; case 0x2: a_Position.x++; break; case 0x3: a_Position.z--; break; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of comparator!"); break; } } } return a_Position; } inline static Vector3i GetRearCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta) { switch (a_Meta) { case 0x0: a_Position.z++; break; case 0x1: a_Position.x--; break; case 0x2: a_Position.z--; break; case 0x3: a_Position.x++; break; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of comparator!"); break; } } return a_Position; } inline static Vector3i GetFrontCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta) { switch (a_Meta) { case 0x0: a_Position.z--; break; case 0x1: a_Position.x++; break; case 0x2: a_Position.z++; break; case 0x3: a_Position.x--; break; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of comparator!"); break; } } return a_Position; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 11; } } ;
Lazauya/cuberite
src/Blocks/BlockRedstoneRepeater.h
<filename>src/Blocks/BlockRedstoneRepeater.h #pragma once #include "BlockHandler.h" #include "Mixins.h" #include "ChunkInterface.h" #include "BlockSlab.h" #include "../Chunk.h" class cBlockRedstoneRepeaterHandler: public cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03> { using super = cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>; public: cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_ChunkInterface.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}) + 0x04) & 0x0f)); return true; } virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override { UNUSED(a_ChunkInterface); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); } virtual bool IsUseable(void) override { return true; } virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { if (a_RelY <= 0) { return false; } BLOCKTYPE BelowBlock; NIBBLETYPE BelowBlockMeta; a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY - 1, a_RelZ, BelowBlock, BelowBlockMeta); if (cBlockInfo::FullyOccupiesVoxel(BelowBlock)) { return true; } else if (cBlockSlabHandler::IsAnySlabType(BelowBlock)) { // Check if the slab is turned up side down if ((BelowBlockMeta & 0x08) == 0x08) { return true; } } return false; } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { return cItem(E_ITEM_REDSTONE_REPEATER, 1, 0); } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 11; } inline static Vector3i GetRearCoordinateOffset(NIBBLETYPE a_Meta) { switch (a_Meta & 0x3) // We only want the direction (bottom) bits { case 0x0: return {0, 0, 1}; case 0x1: return {-1, 0, 0}; case 0x2: return {0, 0, -1}; case 0x3: return {1, 0, 0}; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of repeater!"); return {0, 0, 0}; } } } inline static Vector3i GetFrontCoordinateOffset(NIBBLETYPE a_Meta) { switch (a_Meta & 0x3) // We only want the direction (bottom) bits { case 0x0: return {0, 0, -1}; case 0x1: return {1, 0, 0}; case 0x2: return {0, 0, 1}; case 0x3: return {-1, 0, 0}; default: { LOGWARNING("%s: Unknown metadata: %d", __FUNCTION__, a_Meta); ASSERT(!"Unknown metadata while determining orientation of repeater!"); return {0, 0, 0}; } } } } ;
Lazauya/cuberite
src/Blocks/BlockFurnace.h
<gh_stars>0 #pragma once #include "../Blocks/BlockPiston.h" #include "../BlockEntities/FurnaceEntity.h" #include "Mixins.h" class cBlockFurnaceHandler : public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05> { using super = cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05>; public: cBlockFurnaceHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { cItems res(cItem(E_BLOCK_FURNACE, 1)); // We can't drop a lit furnace if (a_BlockEntity != nullptr) { auto be = static_cast<cFurnaceEntity *>(a_BlockEntity); res.AddItemGrid(be->GetContents()); } return res; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 11; } } ;
Lazauya/cuberite
src/Blocks/BlockAnvil.h
#pragma once #include "BlockHandler.h" #include "Mixins.h" #include "../Entities/Player.h" #include "../UI/AnvilWindow.h" class cBlockAnvilHandler : public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> { public: using super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>; cBlockAnvilHandler(BLOCKTYPE a_BlockType) : super(a_BlockType) { } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { return cItem(m_BlockType, 1, a_BlockMeta >> 2); } virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ); a_Player.OpenWindow(*Window); return true; } virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) { return false; } a_BlockMeta = a_BlockMeta | static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage << 2); return true; } virtual bool IsUseable() override { return true; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 6; } } ;
Lazauya/cuberite
src/Mobs/ZombieVillager.h
<reponame>Lazauya/cuberite<filename>src/Mobs/ZombieVillager.h #pragma once #include "AggressiveMonster.h" #include "Villager.h" class cZombieVillager : public cAggressiveMonster { typedef cAggressiveMonster super; public: cZombieVillager(cVillager::eVillagerType a_Profession); CLASS_PROTODEF(cZombieVillager) virtual void GetDrops (cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void OnRightClicked (cPlayer & a_Player) override; virtual bool IsUndead (void) override { return true; } int ConversionTime (void) const { return m_ConversionTime; } cVillager::eVillagerType GetProfession (void) const { return m_Profession; } private: int m_ConversionTime; cVillager::eVillagerType m_Profession; } ;
Lazauya/cuberite
src/Blocks/BlockHopper.h
// BlockHopper.h // Declares the cBlockHopperHandler class representing the handler for the Hopper block #include "Mixins.h" class cBlockHopperHandler : public cPitchYawRotator<cContainerEntityHandler<cBlockEntityHandler>> { using super = cPitchYawRotator<cContainerEntityHandler<cBlockEntityHandler>>; public: cBlockHopperHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { a_BlockType = m_BlockType; // Convert the blockface into meta: switch (a_BlockFace) { case BLOCK_FACE_BOTTOM: a_BlockMeta = E_META_HOPPER_FACING_YM; break; case BLOCK_FACE_TOP: a_BlockMeta = E_META_HOPPER_FACING_YM; break; case BLOCK_FACE_EAST: a_BlockMeta = E_META_HOPPER_FACING_XM; break; case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break; case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break; case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break; case BLOCK_FACE_NONE: a_BlockMeta = E_META_HOPPER_UNATTACHED; break; } return true; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 11; } } ;
Lazauya/cuberite
src/Blocks/BlockDropSpenser.h
// BlockDropSpenser.h // Declares the cBlockDropSpenserHandler class representing the BlockHandler for Dropper and Dispenser blocks #pragma once #include "../Blocks/BlockPiston.h" #include "../BlockEntities/DropSpenserEntity.h" #include "Mixins.h" class cBlockDropSpenserHandler : public cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00> { using super = cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>; public: cBlockDropSpenserHandler(BLOCKTYPE a_BlockType): super(a_BlockType) { } virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { cItems res(cItem(m_BlockType, 1)); if (a_BlockEntity != nullptr) { auto be = static_cast<cDropSpenserEntity *>(a_BlockEntity); res.AddItemGrid(be->GetContents()); } return res; } virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 11; } } ;
jarubank/imu_calib
include/imu_calib/accel_calib.h
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2015, <NAME> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the copyright holder 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. *********************************************************************/ /** * \file accel_calib.h * \author <NAME> <<EMAIL>> * * Class for calculating and applying accelerometer calibration parameters */ #include <Eigen/Dense> #include <string> namespace imu_calib { class AccelCalib { public: enum Orientation { XPOS = 0, XNEG, YPOS, YNEG, ZPOS, ZNEG }; AccelCalib(); AccelCalib(std::string calib_file); // status bool calibReady(); // file I/O bool loadCalib(std::string calib_file); bool saveCalib(std::string calib_file); // calibration procedure void beginCalib(int measurements, double reference_acceleration); bool addMeasurement(Orientation orientation, double ax, double ay, double az); bool computeCalib(); // calibration application void applyCalib(double raw[3], double corrected[3]); void applyCalib(double raw_x, double raw_y, double raw_z, double *corr_x, double *corr_y, double *corr_z); protected: static const int reference_index_[6]; static const int reference_sign_[6]; bool calib_ready_; Eigen::Matrix3d SM_; //!< combined scale and misalignment parameters Eigen::Vector3d bias_; //!< scaled and rotated bias parameters double reference_acceleration_; //!< expected acceleration measurement (e.g. 1.0 for unit of g's, 9.80665 for unit of m/s^2) bool calib_initialized_; int orientation_count_[6]; Eigen::MatrixXd meas_; //!< least squares measurements matrix Eigen::VectorXd ref_; //!< least squares expected measurements vector int num_measurements_; //!< number of measurements expected for this calibration int measurements_received_; //!< number of measurements received for this calibration }; } // namespace accel_calib
jingjiey/picoCTF
ansible/roles/pico-shell/files/no_aslr_wrapper.c
#include <stdlib.h> #include <sys/personality.h> int main(int argc, char *argv[], char *envp[]) { personality(ADDR_NO_RANDOMIZE); argv[0] = BINARY_PATH; execve(argv[0], argv, envp); }
jingjiey/picoCTF
problems/testing/compiled_sources_url/mybinary.c
<filename>problems/testing/compiled_sources_url/mybinary.c #include <stdio.h> #include <stdlib.h> char input_buf[1024]; char *secret = "test\n"; void be_nice_to_people(){ gid_t gid = getegid(); setresgid(gid, gid, gid); } int main(){ be_nice_to_people(); puts("Welcome to my echo server!"); fflush(stdout); while(fgets(input_buf, 1024, stdin) > 0){ if (!strcmp(input_buf, secret)){ puts("You found the secret input! Have a shell:"); fflush(stdout); system("/bin/sh"); } printf("%s", input_buf); fflush(stdout); } }
vldud/nginx_http_recaptcha_module
ngx_http_recaptcha_module.c
<reponame>vldud/nginx_http_recaptcha_module #include <ngx_config.h> #include <ngx_core.h> #include <ngx_http.h> typedef struct { ngx_uint_t body_index; } ngx_http_recaptcha_conf_t; static ngx_int_t ngx_http_recaptcha_form_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static char * ngx_http_add_form_variable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static void *ngx_http_recaptcha_create_conf(ngx_conf_t *cf); static char *ngx_http_recaptcha_merge_conf(ngx_conf_t *cf, void *parent, void *child); static ngx_command_t ngx_http_recaptcha_commands[] = { { ngx_string("recaptcha_challenge_name"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_http_add_form_variable, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL }, { ngx_string("recaptcha_response_name"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, ngx_http_add_form_variable, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL }, ngx_null_command }; static ngx_http_module_t ngx_http_recaptcha_module_ctx = { NULL, /* preconfiguration */ NULL, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ ngx_http_recaptcha_create_conf, /* create location configuration */ ngx_http_recaptcha_merge_conf /* merge location configuration */ }; ngx_module_t ngx_http_recaptcha_module = { NGX_MODULE_V1, &ngx_http_recaptcha_module_ctx, /* module context */ ngx_http_recaptcha_commands, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING }; static ngx_int_t ngx_http_recaptcha_form_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { u_char *head, *value, *last; ngx_str_t *name; ngx_http_recaptcha_conf_t *rcf; ngx_http_variable_value_t *vv; rcf = ngx_http_get_module_loc_conf(r, ngx_http_recaptcha_module); vv = ngx_http_get_indexed_variable(r, rcf->body_index); if (vv == NULL || vv->not_found || vv->len == 0) { goto not_found; } name = (ngx_str_t *) data; if (name == NULL) { goto not_found; } ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "request_body: \"%*s\", param name = \"%V\"", vv->len, vv->data, name); head = ngx_strnstr((u_char *)vv->data, (char *)name->data, (size_t)vv->len); if (head == NULL) { goto not_found; } value = head + name->len; if (*value != '=') { goto not_found; } value++; last = value; while (last < (vv->data + vv->len)) { if (*last == '&' || *last == CR || *last == LF) { break; } last++; } v->data = value; v->len = last - value; v->valid = 1; v->no_cacheable = 0; v->not_found = 0; return NGX_OK; not_found: v->not_found = 1; return NGX_OK; } static char * ngx_http_add_form_variable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value, *str; ngx_http_variable_t *var; value = cf->args->elts; str = ngx_palloc(cf->pool, sizeof(ngx_str_t)); if (str == NULL) { return NGX_CONF_ERROR; } *str = value[1]; if (str->data[0] == '$') { str->data++; str->len--; } var = ngx_http_add_variable(cf, str, 0); if (var == NULL) { return NGX_CONF_ERROR; } var->get_handler = ngx_http_recaptcha_form_variable; var->data = (uintptr_t) str; return NGX_CONF_OK; } static void * ngx_http_recaptcha_create_conf(ngx_conf_t *cf) { ngx_http_recaptcha_conf_t *conf; conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_recaptcha_conf_t)); if (conf == NULL) { return NULL; } /* * set by ngx_pcalloc(): * * conf->body_index = 0; */ conf->body_index = NGX_CONF_UNSET; return conf; } static char * ngx_http_recaptcha_merge_conf(ngx_conf_t *cf, void *parent, void *child) { ngx_str_t body = ngx_string("request_body"); ngx_http_recaptcha_conf_t *conf = child; conf->body_index = ngx_http_get_variable_index(cf, &body); if (conf->body_index == (ngx_uint_t) NGX_ERROR) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
rondiamond/Reduxion-iOS
Sample app/Reduxion-iOS sample app/Reduxion_iOS.h
<filename>Sample app/Reduxion-iOS sample app/Reduxion_iOS.h // // Reduxion_iOS.h // Reduxion-iOS // // Created by <NAME> on 8/25/18. // Copyright © 2018 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for Reduxion_iOS. FOUNDATION_EXPORT double Reduxion_iOSVersionNumber; //! Project version string for Reduxion_iOS. FOUNDATION_EXPORT const unsigned char Reduxion_iOSVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <Reduxion_iOS/PublicHeader.h>
DSarceno/2022LabSimu201900109
SegundoParcial/problema1.c
<gh_stars>0 // mié 27 abr 2022 22:31:14 CST // problema1.c // <NAME> (<EMAIL>) // Fit de la recta que mejor se aproxime a un conjunto de datos. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema1.o problema1.c // gcc -o problema1.x problema1.o -lm // Librerias #include <stdio.h> #include <math.h> #include <stdlib.h> // 0. Prototipado de funciones y declaracion de variables #define n 10 float suma_prod(float x[], float y[]); float suma(float x[]); // 1. funcion main int main(){ // 5. vectores de datos y variables importantes float x[n] = {1,2,3,4,5,6,7,8,9,10}; float y[n] = {20.20,20.90,20.60,21.30,21.75,22.05,23.62,22.95,23.80,24.00}; float m, b; // pendiente e intercepto float r; // coeficiente de correlacion // 6. Calculo de la pendiente y el intercepto con las funciones ya dadas. m = ((n*suma_prod(x,y)) - (suma(x)*suma(y)))/((n*suma_prod(x,x)) - (suma(x)*suma(x))); b = (suma(y) - (m*suma(x)))/(n); printf("%f x + %f \n",m,b); // 7. Cálculo del coeficiente de correlación r, e impresión de r**2 r = ((n*suma_prod(x,y)) - (suma(x)*suma(y)))/sqrt(((n*suma_prod(x,x))-(suma(x)*suma(x)))*((n*suma_prod(y,y))-(suma(y)*suma(y)))); printf("r = %f \n", r); printf("r^2 = %f \n", r*r); // 8. Encontrando el tiempo que se toma en llegar al tope de precio, 30 /* Para ello despejamos la funcion f(x) = mx + b para x que es el tiempo y reemplazamos los 30 de precio tope */ puts("El tiempo que le toma al combustible alcanzar su precio límite es de: "); printf("%f semanas.\n", (30 - b)/m); // 9. Escribimos el archivo de datos y generamos la gráfica FILE* f; if ((f= fopen("data.dat","wt"))==NULL){ puts("Error de escritura"); return 1; } // END IF for (int i = 0; i < n; i++){ fprintf(f,"%f\t%f\n",x[i],y[i]); } // END FOR fclose(f); // 10. plot system("gnuplot combustible.gp"); return 0; } /* FUNCIONES */ float suma(float x[]){ float result = 0; for (int i = 0; i < n; i++){ result += x[i]; } // END FOR return result; } // END suma float suma_prod(float x[], float y[]){ float result = 0; for (int i = 0; i < n; i++){ result += x[i]*y[i]; } // END FOR return result; } // END suma_prod //
DSarceno/2022LabSimu201900109
Laboratorio4/problema5.c
// jue 21 abr 2022 18:28:36 CST // problema5.c // <NAME> (<EMAIL>) // Función factorial recursiva // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema5.o problema5.c // gcc -o problema5.x problema5.o // Librerias #include <stdio.h> // 0. prototipado de funciones y definicion de variables unsigned long long int factorial(int n); // 1. funcion main int main(){ // 2. definicion de variables int n; // 3. ingreso y validacion del dato ingresado por el usuario puts("Ingrese un número entero positivo."); scanf("%d", &n); //4. utilizacion de la funcion recursiva printf("El factorial del número ingresado es: %lld\n", factorial(n)); return 0; } // END MAIN /* FUNCIONES */ unsigned long long int factorial(int n){ if (n == 1 || n == 0){ return 1; } else { return n*factorial(n-1); } // END IF } // FUNCION FACTORIAL // END PROGRAM
DSarceno/2022LabSimu201900109
Laboratorio4/problema1.c
// mié 20 abr 2022 15:52:22 CST // problema1.c // <NAME> (<EMAIL>) // Este programa crea y muestra una lista de 10 elementos de numeros pares // y solicita al usuario en que orden desea que se ordene // (ascendente/descendente). Para el ordenamiento se utiliza el algoritmo // merge-sort. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema1.o problema1.c // gcc -o problema1.x problema1.o // Librerias #include <stdio.h> #include <stdlib.h> #include <time.h> // 0. Prototipado de funciones void mergeSort(int main_array[], int start, int final); void merge(int array[], int start, int half, int final); void reverse(int array[], int length); void printArrays(int array[], int length); void shuffle(int array[], int length); #define l 10 // 1. Función main int main(){ // 1.1. Definimos la "seed" como el tiempo, para el generador de numeros srand(time(0)); // 2. Se crea un arreglo de números pares del 2 al 20 int numeros[l]; // 2.1. se ingresan los datos en la lista for (int i = 0; i < l; i++){ numeros[i] = 2*i + 2; } // 3. Se aleatoriza el arreglo printArrays(numeros, l); shuffle(numeros, l); printArrays(numeros, l); // 4. Interaccion con el usuario y ordenamiento del arreglo char input; int control = 0; while(control == 0){ puts("Ingrese como desea ver los números."); puts("'A' para verlos de forma ascendente."); puts("'D' para verlos de forma descendente."); scanf("%s",&input); if (input == 65){ control = 1; puts("WUUU FORMA ASCENDENTE"); //printArrays(numeros, l); mergeSort(numeros, 0, l); printArrays(numeros, l); } else if (input == 68){ control = 1; puts("WUUU FORMA DESCENDENTE"); //printArrays(numeros, l); mergeSort(numeros, 0, l); reverse(numeros, l); printArrays(numeros, l); } else { puts("Ingrese un valor válido."); } // END IF } // END WHILE return 0; } // END MAIN /* FUNCIONES UTILIZADAS */ void mergeSort(int main_array[], int start, int final){ int half; half = (start + final)/2; if (start < final){ mergeSort(main_array, start, half); mergeSort(main_array, half + 1, final); merge(main_array, start, half, final); } // END IF } // END MERGESORT void merge(int array[], int start, int half, int final){ int aux[final + 1],i,j,k,t; k = 0; // movimiento por la lista auxiliar i = start; // movimiento por la sublista izquierda j = half + 1; // movimiento por la sublista derecha // ciclo para empezar a unir los arrays while(i <= half && j <= final){ k++; if (array[i] < array[j]){ aux[k] = array[i]; i++; } else { aux[k] = array[j]; j++; } // END IF } // END WHILE // para los elementos sobrantes de alguna de las sublistas for (t = i; t <= half; t++){ k++; aux[k] = array[t]; } // END FOR for (t = j; t <= final; t++){ k++; aux[k] = array[t]; } // END FOR // regresar todo al vector original for (t = 1; t <= k; t++){ array[start + t - 1] = aux[t]; } // END FOR } // END MERGE void reverse(int array[], int length){ int aux[length]; // Navegando el array del final hacia el inicio, y aux en forma contraria for (int i = length - 1; i >= 0; i--){ aux[length - i - 1] = array[i]; } // END FOR // regresando todo al vector original for (int j = 0; j < length; j++){ array[j] = aux[j]; } // END FOR } // END INVERSE void printArrays(int array[], int length){ // impresion printf("("); for (int i = 0; i < length; i++){ if (i != length - 1){ printf("%d, ",array[i]); } else { printf("%d)\n", array[i]); } // END IF } // END FOR } // END printArrays void shuffle(int array[], int length){ int random_position, step; for (int k = 0; k < length; k++){ // Generamos una posicion random random_position = rand() % length; // intercambiar el actual elemento con el de la poiscion aleatoria step = array[k]; array[k] = array[random_position]; array[random_position] = step; } // END FOR } // END SHUFFLE //adf
DSarceno/2022LabSimu201900109
Laboratorio4/problema2.c
// jue 21 abr 2022 18:28:27 CST // problema2.c // <NAME> (<EMAIL>) // Ordenamiento de números dados por un usuario. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema2.o problema2.c // gcc -o problema2.x problema2.o // Librerias #include <stdio.h> // 0. Prototipado de funcion y definicion de variables #define l 5 void mergeSort(int main_array[], int start, int final); void merge(int array[], int start, int half, int final); void printArrays(int array[], int length); // 1. funcion main int main(){ // 3. declaracion de variables int vector[5]; // 4. ingreso de datos puts("Ingrese 5 numeros enteros."); for (int i = 0; i < l; i++){ scanf("%d", &vector[i]); } // 5. Ordenamiento del array puts("Array ordenado."); mergeSort(vector, 0, l); printArrays(vector, l); return 0; } // END MAIN /* FUNCITON */ void mergeSort(int main_array[], int start, int final){ int half; half = (start + final)/2; if (start < final){ mergeSort(main_array, start, half); mergeSort(main_array, half + 1, final); merge(main_array, start, half, final); } // END IF } // END MERGESORT void merge(int array[], int start, int half, int final){ int aux[final + 1],i,j,k,t; k = 0; // movimiento por la lista auxiliar i = start; // movimiento por la sublista izquierda j = half + 1; // movimiento por la sublista derecha // ciclo para empezar a unir los arrays while(i <= half && j <= final){ k++; if (array[i] < array[j]){ aux[k] = array[i]; i++; } else { aux[k] = array[j]; j++; } // END IF } // END WHILE // para los elementos sobrantes de alguna de las sublistas for (t = i; t <= half; t++){ k++; aux[k] = array[t]; } // END FOR for (t = j; t <= final; t++){ k++; aux[k] = array[t]; } // END FOR // regresar todo al vector original for (t = 1; t <= k; t++){ array[start + t - 1] = aux[t]; } // END FOR } // END MERGE void printArrays(int array[], int length){ // impresion printf("("); for (int i = 0; i < length; i++){ if (i != length - 1){ printf("%d, ",array[i]); } else { printf("%d)\n", array[i]); } // END IF } // END FOR } // END printArrays // END PROGRAM
DSarceno/2022LabSimu201900109
EXAMENFINAL/problema1.c
<reponame>DSarceno/2022LabSimu201900109 // lun 16 may 2022 07:55:08 CST // problema1.c // <NAME> (<EMAIL>) // Simulación de diversos cohetes. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema1.o problema1.c // gcc -o problema1.x problema1.o -lm // Librerias #include <stdio.h> #include <math.h> #include <stdlib.h> // 0.1. Definicion de constantes generales #define G 6.693E-11 #define Rt 6.378E6 #define Mt 5.9736E24 #define R 287.06 // constante del gas ideal #define L 6.5E-3 // constante termica de la atm #define g 9.81 #define To 288.15 #define Po 101325 // 0.2. Prototipado de funciones float masa_cohete(float m0, float tsfc, float Eo, float mfo, float t); float masa_f(float tsfc, float Eo, float mfo, float t); float gravedad(float y); float fuerza_a(float y, float cd, float a, float v); float densidad(float y); float empuje(float mf, float Eo); float ed(float y, float v, float t, float m0, float tsfc, float Eo, float mfo, float cd, float a); // funcion de la ecuacion diferencial void euler(float h, float m0, float tsfc, float Eo, float mfo, float cd, float a, float *tc, float *tf, float *hm); // 1. main int main(){ /* Se hara una declaración de las mismas variables para cada cohete. */ // 2. declaracion de variables float Eo, tsfc, cd, a, m0, mfo, tc, tf, hm; /* <NAME> */ // 3. constantes Eo = 3E7; tsfc = 3.248E-4; cd = 61.27; a = 201.06; m0 = 1.1E5; mfo = 1.5E6; // valuamos el metodo de euler euler(0.1, m0, tsfc, Eo, mfo, cd, a, &tc, &tf, &hm); // impresion de los datos solicitados puts("Cohete <NAME>"); printf("Empuje: %f\nTSFC: %.6f\nCD: %f\nSeccion Transversal: %f\nMasa del Propulsor: %f\nMasa inicial del Combulstible: %f\n", Eo, tsfc, cd, a, m0, mfo); printf("La altura maxima alcanzada es h_max = %f m\n", hm); printf("El combustible se agota en t = %f min\n", tc/60); printf("El cohete cae al suelo en t = %f min\n", tf/60); // generamos las graficas system("gnuplot ahmun.gp"); /* <NAME> */ // 3. constantes Eo = 2.7E7; tsfc = 2.248E-4; cd = 61.27; a = 201.06; m0 = 1.1E5; mfo = 1.5E6; // valuamos el metodo de euler euler(0.1, m0, tsfc, Eo, mfo, cd, a, &tc, &tf, &hm); // impresion de los datos solicitados puts(""); puts("<NAME>"); printf("Empuje: %f\nTSFC: %.6f\nCD: %f\nSeccion Transversal: %f\nMasa del Propulsor: %f\nMasa inicial del Combulstible: %f\n", Eo, tsfc, cd, a, m0, mfo); printf("La altura maxima alcanzada es h_max = %f m\n", hm); printf("El combustible se agota en t = %f min\n", tc/60); printf("El cohete cae al suelo en t = %f min\n", tf/60); // generamos las graficas system("gnuplot ahaukin.gp"); /* CHAC */ // 3. constantes Eo = 2.5E7; tsfc = 2.248E-4; cd = 70.25; a = 215.00; m0 = 1.8E5; mfo = 2.1E6; // valuamos el metodo de euler euler(0.1, m0, tsfc, Eo, mfo, cd, a, &tc, &tf, &hm); // impresion de los datos solicitados puts(""); puts("<NAME>"); printf("Empuje: %f\nTSFC: %.6f\nCD: %f\nSeccion Transversal: %f\nMasa del Propulsor: %f\nMasa inicial del Combulstible: %f\n", Eo, tsfc, cd, a, m0, mfo); printf("La altura maxima alcanzada es h_max = %f m\n", hm); printf("El combustible se agota en t = %f min\n", tc/60); printf("El cohete cae al suelo en t = %f min\n", tf/60); // generamos las graficas system("gnuplot chac.gp"); return 0; } // END main /* FUNCIONES */ // MASA COHETE float masa_cohete(float m0, float tsfc, float Eo, float mfo, float t){ float res; if (round(masa_f(tsfc, Eo, mfo, t)) == 0){ return m0; } else{ res = m0 + masa_f(tsfc, Eo, mfo, t); // Incluye la variación de la masa del combustible return res; } // END IF } // END masa_cohete // MASA COMBISTIBLE float masa_f(float tsfc, float Eo, float mfo, float t){ float res; res = -(tsfc*Eo*t) + mfo; return res; } // END masa_f // GRAVEDAD float gravedad(float y){ float res; res = (G*Mt)/pow(Rt + y,2); return res; } // END gravedad // FUERZA A float fuerza_a(float y, float cd, float a, float v){ float res; res = 0.5*densidad(y)*cd*a*v*abs(v); return res; } // END fuerza_a // DENSIDAD float densidad(float y){ float res; if (y < To/L){ res = (Po/(R*To))*pow(1 - (L*y)/To, g/(R*L)); return res; } else{ return 0; } // END IF } // END densidad // EMPUJE float empuje(float mf, float Eo){ if (round(mf) == 0){ return 0; } else{ return Eo; } // END IF } // END empuje // ECUACION DIFERENCIAL float ed(float y, float v, float t, float m0, float tsfc, float Eo, float mfo, float cd, float a){ // d2y/dt2 = ed(...) float res; res = (empuje(masa_f(tsfc, Eo, mfo, t), Eo) - fuerza_a(y, cd, a, v) - (masa_cohete(m0, tsfc, Eo, mfo, t)*gravedad(y)) )/masa_cohete(m0, tsfc, Eo, mfo, t); return res; } // END ed // RUNGE KUTTA void euler(float h, float m0, float tsfc, float Eo, float mfo, float cd, float a, float *tc, float *tf, float *hm){ // condiciones iniciales float y = 0.09, v = 0, t = 0; // altura inicial 201900109 -> 0.09m // mismo archivo para todos los cohetes, pero se formatea en cada ejecucion de esta funcion FILE* f; if ((f= fopen("data.dat","wt"))==NULL){ puts("Error de escritura"); } // END IF // iteraciones while (y > 0.01){ fprintf(f,"%.2f\t%.2f\t%.2f\n",t,y,v); // paso t += h; // calculamos la Velocidad v = ed(y, v, t, m0, tsfc, Eo, mfo, cd, a)*t; // calculamos la altura y = v*t + 0.5*ed(y, v, t, m0, tsfc, Eo, mfo, cd, a)*pow(t,2); if (round(masa_f(tsfc, Eo, mfo, t)) == 0){ *tc = t; } else if(round(v) == 0){ *hm = y; } // END IF } fclose(f); *tf = t; } // END rungeKutta //
DSarceno/2022LabSimu201900109
Laboratorio4/problema3.c
// jue 21 abr 2022 17:01:06 CST // problema3.c // <NAME> (<EMAIL>) // Este problema recibe dos vectores en R3 al usuario y calcula // algunas operaciones con dichos vectores. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema3.o problema3.c // gcc -o problema3.x problema3.o -lm // Librerias #include <stdio.h> #include <math.h> // 0. Prototipado de funciones y declaracion de variables //double sqrt(double x); void printArrays(float array[], int length); void suma_vectorial(float array1[], float array2[], float result[]); float magnitud(float array[]); float producto_interno(float array1[], float array2[]); void producto_vectorial(float array1[], float array2[], float result[]); // 1. Main function int main(){ // 2. declaracion de variables generales float vec1[3], vec2[3]; float resvec[3]; // 3. Ingreso de los vectores por parte del usuario puts("Ingrese dos vectores en R3 en la forma x1,x2,x3."); scanf("%f,%f,%f",&vec1[0],&vec1[1],&vec1[2]); scanf("%f,%f,%f",&vec2[0],&vec2[1],&vec2[2]); // 4. Realizando las diferente operaciones // 4.1. Suma de vectores suma_vectorial(vec1,vec2,resvec); puts("Suma de vectores."); printArrays(resvec, 3); // 4.2. magnitud de cada vector printf("Magnitud de cada vector. V1 = %f, V2 = %f\n", magnitud(vec1), magnitud(vec2)); // 4.3. vector product producto_vectorial(vec1,vec2,resvec); puts("Producto vectorial entre ambos vectores."); printArrays(resvec, 3); // 4.4. inner product printf("Producto interno entre ambos vectores: %f\n",producto_interno(vec1,vec2)); return 0; } // END MAIN /* FUNCIONES */ float producto_interno(float array1[], float array2[]){ float result = 0; for (int i = 0; i < 3; i++){ result += array1[i]*array2[i]; } // END FOR return result; } // END PRODUCTO_INTERNO void producto_vectorial(float array1[], float array2[], float result[]){ // componentes del vector resultante result[0] = (array1[1]*array2[2] - array1[2]*array2[1]); result[1] = -(array1[0]*array2[2] - array1[2]*array2[0]); result[2] = (array1[0]*array2[1] - array1[1]*array2[0]); } // END PRODUCTO_VECTORIAL void printArrays(float array[], int length){ // impresion printf("("); for (int i = 0; i < length; i++){ if (i != length - 1){ printf("%f, ",array[i]); } else { printf("%f)\n", array[i]); } // END IF } // END FOR } // END printArrays void suma_vectorial(float array1[], float array2[], float result[]){ for (int i = 0; i < 3; i++){ result[i] = array1[i]+array2[i]; } // END FOR } // END SUMA_VECTORIAL float magnitud(float array[]){ //double sqrt(double x); float norm = 0; for (int i = 0; i < 3; i++){ norm += pow(array[i],2); } // END FOR return sqrt(norm); } // END SUMA_VECTORIAL // adñlfja
DSarceno/2022LabSimu201900109
SegundoParcial/problema2.c
// jue 28 abr 2022 23:17:08 CST // problema2.c // <NAME> (<EMAIL>) // Resumen // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema2.o problema2.c // gcc -o problema2.x problema2.o -lm // Librerias #include <stdio.h> #include <stdlib.h> #include <math.h> // 0. Prototipado de funciones y definicion de Variables float f(float x); void biseccion(float inflim, float suplim, int iteraciones, int *fail, float *raiz, float tolerancia); // 1. funcion main int main(){ // 2. variables utiles float x_inicial, x_final, tolerancia, raiz; int iteraciones, fail; // 3. ingreso de variables por parte del usuario puts("Límite inferior de la raíz."); scanf("%f",&x_inicial); puts("Límite superior de la raíz."); scanf("%f",&x_final); puts("Número máximo de iteraciones."); scanf("%d",&iteraciones); puts("Tolerancia aceptada."); scanf("%f",&tolerancia); // 4. Llamada a las funciones // puts("inflim \t\t f(inflim) \t\t suplim \t\t f(suplim) \t\t p \t\t f(p)"); biseccion(x_inicial, x_final, iteraciones, &fail, &raiz, tolerancia); // 5. Vemos si el método dio resultado en el número de iteraciones Dado if (fail == iteraciones){ printf("No se pudo encontrar la raíz en %d iteraciones.\n", fail); } else { printf("El valor de la raíz es: %f\n", raiz); } // END IF //6. se crea un archivo con el punto dado y se genera el plot FILE* f; if ((f= fopen("point.dat","wt"))==NULL){ puts("Error de escritura"); return 1; } // END IF fprintf(f,"%f\t%f\n",raiz,0.0); fclose(f); // 6.1. plot system("gnuplot raiz.gp"); return 0; } // END Main float f(float x){ return (2 - exp(x) + cos(exp(x) - 2)); } // END f void biseccion(float inflim, float suplim, int iteraciones, int *fail, float *raiz, float tolerancia){ // punto medio del intervalo float p; int i; p = (inflim + suplim)/2; // definicion del punto medio // printf("%f \t %f \t %f \t %f \t %f \t %f\n", inflim, f(inflim), suplim, f(suplim), p, f(p)); for (i = 0; i < iteraciones; i++){ p = (inflim + suplim)/2; // se vuelve a definir para que este dentreo del ciclo if (f(inflim)*f(p) > 0){ // deteccion de la variación de signo inflim = p; } else { suplim = p; } // END IF // printf("%f \t %f \t %f \t %f \t %f \t %f\n", inflim, f(inflim), suplim, f(suplim), p, f(p)); if (fabs(inflim - suplim) < tolerancia){ break; } // se llego a la tolerancia } // END FOR *raiz = p; *fail = i; } // END biseccion //
DSarceno/2022LabSimu201900109
Laboratorio4/problema4.c
// jue 21 abr 2022 18:28:43 CST // problema4.c // <NAME> (<EMAIL>) // Prorama que implementa diferentes operaciones con matrices. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema4.o problema4.c // gcc -o problema4.x problema4.o -lm // Librerias #include <stdio.h> #include <math.h> // 0. prototipado de funciones (m filas y n columnas) #define fila 3 #define col 3 void prod_escalar(float array[][col], int m, int n, float result[][col], float c); void suma(float array1[][col], float array2[][col], int m, int n, float result[][col]); void resta(float array1[][col], float array2[][col], int m, int n, float result[][col]); void prod_matrices(float array1[][col], float array2[][col], int m, int n, float result[][col]); float determinante(float array[][col]); //float cofactor(float array[][col], int n, int file, int column); void transpuesta(float array[][col], int m, int n, float result[][col]); void mCofactores(float array[][col], float result[][col]); void redGauss(float array[][col], float result[][col]); void redGaussJordan(float array[][col], float result[][col]); // 1. main int main(){ // 2. definiendo las variables a utilizar float matA[fila][col], matB[fila][col], result[fila][col], aux[fila][col]; float c; // 3. ingreso de las matrices y la constante puts("Ingrese la primera matriz por filas en el siguiente formato: x,y,z"); for (int i = 0; i < fila; i++){ scanf("%f,%f,%f", &matA[i][0], &matA[i][1], &matA[i][2]); } puts("Ingrese la primera matriz por filas en el siguiente formato: x,y,z"); for (int j = 0; j < fila; j++){ scanf("%f,%f,%f", &matB[j][0], &matB[j][1], &matB[j][2]); } puts("Ingrese el valor de la constante."); scanf("%f",&c); puts(""); // 4. calculo de los respectvos incisos // a) prod_escalar(matA, fila, col, result, c); puts("a) Matriz por una constante."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // b) suma(matA, matB, fila, col, result); puts("b) matA + matB."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // c) resta(matA, matB, fila, col, result); puts("c) matA - matB."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // d) prod_matrices(matA, matB, fila, col, result); puts("d) matA * matB."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // e) puts("e) det(matA)."); printf("%f\n", determinante(matA)); puts(""); // f) transpuesta(matB, fila, col, result); puts("f) transpuesta de matB."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // g) mCofactores(matA, result); transpuesta(result, fila, col, aux); prod_escalar(aux, fila, col, result, 1/determinante(matA)); puts("g) inversa de matA."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // h) redGauss(matA, result); puts("h) reduccion gauss de matA."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); // i) redGauss(matB, result); puts("i) reduccion gauss-jordan de matB."); for (int i = 0; i < fila; i++){ printf("%f,%f,%f\n", result[i][0], result[i][1], result[i][2]); } puts(""); return 0; } // END MAIN /* FUNCIONES */ void prod_escalar(float array[][col], int m, int n, float result[][col], float c){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ result[i][j] = c*array[i][j]; } // END FOR } // END FOR } // END prod_escalar void suma(float array1[][col], float array2[][col], int m, int n, float result[][col]){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ result[i][j] = array1[i][j] + array2[i][j]; } // END FOR } // END FOR } // END suma void resta(float array1[][col], float array2[][col], int m, int n, float result[][col]){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ result[i][j] = array1[i][j] - array2[i][j]; } // END FOR } // END FOR } // END suma void prod_matrices(float array1[][col], float array2[][col], int m, int n, float result[][col]){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ result[i][j] = 0; } // END FOR } // END FOR for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ for (int k = 0; k < n; k++){ result[i][j] += array1[i][k] * array2[k][j]; } // END FOR } // END FOR } // END FOR } // END prod_matrices // REGLA DE SARRUS float determinante(float array[][col]){ float det = 0; int i = 0, j = 0; for (int x = 0; x < 3; x++){ i = (1 + x) % 3; j = (2 + x) % 3; det += array[0][x]*(array[1][i]*array[2][j] - array[1][j]*array[2][i]); } // END FOR return det; } // END determinante void transpuesta(float array[][col], int m, int n, float result[][col]){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ result[j][i] = array[i][j]; } // END FOR } // END FOR } // END transpuesta void mCofactores(float array[][col], float result[][col]){ // manualmente result[0][0] = array[1][1]*array[2][2] - array[1][2]*array[2][1]; result[0][1] = -(array[1][0]*array[2][2] - array[1][2]*array[2][0]); result[0][2] = array[1][0]*array[2][1] - array[1][1]*array[2][0]; result[1][0] = -(array[0][1]*array[2][2] - array[0][2]*array[2][1]); result[1][1] = array[0][0]*array[2][2] - array[0][2]*array[2][0]; result[1][2] = -(array[0][0]*array[2][1] - array[0][1]*array[2][0]); result[2][0] = array[0][1]*array[1][2] - array[0][2]*array[1][1]; result[2][1] = -(array[0][0]*array[1][2] - array[0][2]*array[1][0]); result[2][2] = array[0][0]*array[1][1] - array[0][1]*array[1][0]; } // END inversa void redGauss(float array[][col], float result[][col]){ result = array; for(int i=0;i<=2;i++){ for(int j=3;j>=0;j--){ result[i][j] = result[i][j]/result[i][i]; } // END FOR for(int k=i+1;k<=2;k++){ for(int j=3;j>=0;j--){ result[k][j] = result[k][j] - result[k][i]*result[i][j]; } // END FOR } // END FOR } // END FOR } // END redGauss void redGaussJordan(float array[][col], float result[][col]){ result = array; for(int i=0;i<=2;i++){ for(int j=3;j>=0;j--){ result[i][j] = result[i][j]/result[i][i]; } for(int k=i+1;k<=2;k++){ for(int j=3;j>=0;j--){ result[k][j] = result[k][j] - result[k][i]*result[i][j]; } } for (int k=0; k<=i-1;k++){ for(int j=3;j>=0;j--){ result[k][j] = result[k][j] - result[k][i]*result[i][j]; } } } } // END redGaussJordan // END PROGRAM
DSarceno/2022LabSimu201900109
Practicas/Practica3/ejercicio_docker/haber.c
<reponame>DSarceno/2022LabSimu201900109 // Wed Mar 2 02:29:38 UTC 2022 // haber.c // <NAME> (<EMAIL>) // Resumen // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o haber.o haber.c // gcc -o haber.x haber.o // Librerias // #include <stdio.h>
DSarceno/2022LabSimu201900109
Laboratorio4/mergeSort.c
<gh_stars>0 // mié 20 abr 2022 18:30:27 CST // mergeSort.c // <NAME> (<EMAIL>) // Funciones del algoritmo MERGE SORT // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o mergeSort.o mergeSort.c // gcc -o mergeSort.x mergeSort.o // Librerias #include <stdio.h> void mergeSort(int main_array[], int start, int final); void merge(int array[], int start, int half, int final); int main(){ int lista[20] = {8,9,3,4,5,2,7,2,6,3,4,6,8,2,3,7,1,9,3,8}; int length = sizeof(lista)/sizeof(lista[0]); mergeSort(lista,0,length); for (int i = 0; i < length; i++){ printf("%d \n",lista[i]); } return 0; } void mergeSort(int main_array[], int start, int final){ int half; half = (start + final)/2; if (start < final){ mergeSort(main_array, start, half); mergeSort(main_array, half + 1, final); merge(main_array, start, half, final); } // END IF } // END MERGESORT void merge(int array[], int start, int half, int final){ int aux[final + 1],i,j,k,t; k = 0; // movimiento por la lista auxiliar i = start; // movimiento por la sublista izquierda j = half + 1; // movimiento por la sublista derecha // ciclo para empezar a unir los arrays while(i <= half && j <= final){ k++; if (array[i] < array[j]){ aux[k] = array[i]; i++; } else { aux[k] = array[j]; j++; } // END IF } // END WHILE // para los elementos sobrantes de alguna de las sublistas for (t = i; t <= half; t++){ k++; aux[k] = array[t]; } // END FOR for (t = j; t <= final; t++){ k++; aux[k] = array[t]; } // END FOR // regresar todo al vector original for (t = 1; t <= k; t++){ array[start + t - 1] = aux[t]; } // END FOR } // END MERGE // asdfads
DSarceno/2022LabSimu201900109
Laboratorio4/pruebas.c
// vie 22 abr 2022 17:12:18 CST // pruebas.c // <NAME> (<EMAIL>) // Resumen // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o pruebas.o pruebas.c // gcc -o pruebas.x pruebas.o //Librerias #include <stdio.h> #include <math.h> /* POR METODO DE COFACTORES float determinante(float array[][col], int orden){ float det = 0; for (int i = 0; i < orden; i++){ det += array[0][i]*cofactor(array, orden, 0, i); } // END FOR return det; } // END determinante float cofactor(float array[][col], int orden, int file, int column){ int nuevo_orden = orden - 1; float subarray[nuevo_orden][nuevo_orden]; int x = 0, y = 0; for (int i = 0; i < orden; i++){ for (int j = 0; j < orden; j++){ if (i != file && j != column){ subarray[x][y] = array[i][j]; y++; } // END IF } // END FOR x++; } // END FOR // pow(-1, file + column)* return pow(-1, file + column)*determinante(subarray, nuevo_orden); } // END cofactor */
DSarceno/2022LabSimu201900109
Practicas/Practica3/ejercicio_docker/ej2.c
<filename>Practicas/Practica3/ejercicio_docker/ej2.c /* Autor: <NAME> Compilador: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 Compilado: gcc -Wall -pedantic -std=c11 -c -o ej2.o ej2.c gcc -o ej2.x ej2.o Fecha: Wed Mar 2 02:47:08 UTC 2022 Librerias: stdio, (otras) Resumen: (ingrese) Entrada: (ingrese) Salida: (Ingrese) */ // Librerias #include <stdio.h>
DSarceno/2022LabSimu201900109
Laboratorio4/problema6.c
// jue 21 abr 2022 18:10:47 CST // problema6.c // <NAME> (<EMAIL>) // Calculo de diversas sumatorias con limite superior ingresado por el usuario. // Codificado del texto: UTF8 // Compiladores probados: GNU gcc (Ubuntu 20.04 Linux) 9.3.0 // Instruciones de Compilacion: no requiere nada mas // gcc -Wall -pedantic -std=c11 -c -o problema6.o problema6.c // gcc -o problema6.x problema6.o -lm // Librerias #include <stdio.h> #include <math.h> // 0. Prototipado de funciones float a(int n); float b(int n); float c(int n); float d(int n); // 1. funcion main int main(){ // 2. ingreso del limite superior int n; puts("Ingrese un número entero positivo."); scanf("%d", &n); printf("Inciso a) %.2f \n", a(n)); printf("Inciso b) %.2f \n", b(n)); printf("Inciso c) %.2f \n", c(n)); printf("Inciso d) %.2f \n", d(n)); } /* FUNCIONES */ float a(int n){ float sum1 = 0; for (int i = 1; i <= n; i++){ sum1 += pow(i,2)*(i - 3); } return sum1; } //END a float b(int n){ float sum2 = 0; for (int i = 2; i <= n; i++){ sum2 += 3/(i - 1); } return sum2; } // END b float c(int n){ float sum3 = 0; for (int i = 1; i <= n; i++){ sum3 += (1/sqrt(5))*pow(((1 + sqrt(5))/2),i) - (1/sqrt(5))*pow(((1 - sqrt(5))/2),i); } return sum3; } // END c float d(int n){ float sum4 = 0; for (int i = 2; i <= n; i++){ sum4 += 0.1*(3*pow(2,i - 2) + 4); } return sum4; } // END d //END PROGRAM lab4Problema6
Mitron57/Setters
cpp/Platform.Setters/Setter[TResult, TDecision].h
namespace Platform::Setters { template <typename ...> class Setter; template <typename TResult, typename TDecision> class Setter<TResult, TDecision> : public SetterBase<TResult> { private: TDecision _trueValue = 0; private: TDecision _falseValue = 0; public: Setter(TDecision trueValue, TDecision falseValue, TResult defaultValue) { _trueValue = trueValue; _falseValue = falseValue; } public: Setter(TDecision trueValue, TDecision falseValue) : Setter(trueValue, falseValue, 0) { } public: Setter(TResult defaultValue) { } public: Setter() { } public: TDecision SetAndReturnTrue(TResult value) { TResult _result = value; return _trueValue; } public: TDecision SetAndReturnFalse(TResult value) { TResult _result = value; return _falseValue; } public: TDecision SetFirstAndReturnTrue(Platform::Interfaces::IList<TResult> auto list) { TResult _result = list[0]; return _trueValue; } public: TDecision SetFirstAndReturnFalse(Platform::Interfaces::IList<TResult> auto list) { TResult _result = list[0]; return _falseValue; } }; }
kakkun61/haskell-invokes-rust
main.c
<gh_stars>1-10 // This is not necessary for the FFI from Haskell to Rust. void hello_rust(void); int main (void) { hello_rust(); return 0; }
lazear/lass
assembler.c
<reponame>lazear/lass<gh_stars>10-100 /* GNU nano 2.7.0 File: LICENSE MIT License Copyright (c) 2016 <NAME> 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 <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <assert.h> #include <ctype.h> #include <limits.h> // for linux systems - file IO #include <unistd.h> #include "opcodes.h" #include "elf.h" uint32_t program_length = 0; uint32_t current_position = 0; uint32_t num_symbols = 0; uint32_t unr_symbols = 0; uint8_t *output; uint8_t *elf_output; uint32_t elf_offset = 0; int find_symbol(char *label); void make_elf() { printf("Making elf header\n"); elf_offset = sizeof(elf32_ehdr) + sizeof(elf32_phdr); elf32_ehdr *e = malloc(sizeof(elf32_ehdr)); e->e_ident[0] = ELF_MAGIC; e->e_ident[1] = 0x00010101; e->e_ident[2] = 0; e->e_ident[3] = 0; e->e_type = ET_EXEC; e->e_machine = 3; e->e_version = 1; e->e_entry = find_symbol("main"); e->e_phoff = sizeof(elf32_ehdr); e->e_shoff = 0; e->e_flags = 0; e->e_ehsize = sizeof(elf32_ehdr); e->e_phentsize = sizeof(elf32_phdr) * 1; e->e_phnum = 1; e->e_shentsize = 0; e->e_shnum = 0; e->e_shstrndx = 0; elf32_phdr *p = malloc(sizeof(elf32_phdr)); p->p_type = 1; p->p_offset = 0; p->p_vaddr = 0; p->p_paddr = 0; p->p_filesz = program_length + elf_offset; printf("p_filesz: %d bytes\n", p->p_filesz); p->p_memsz = p->p_filesz; p->p_flags = 0x5; p->p_align = 0x1000; elf_output = malloc(elf_offset); memcpy(elf_output, e, sizeof(elf32_ehdr)); memcpy(elf_output + sizeof(elf32_ehdr), p, sizeof(elf32_phdr)); } void add_symbol(char *label) { printf("%08x %s:\n", current_position, label); for (int i = 0; i < 32 && i < strlen(label); i++) { symtab[num_symbols].name[i] = label[i]; } for (int i = 0; i < unr_symbols; i++) { if (strncmp(label, unresolved[i].name, strlen(unresolved[i].name)) == 0) { /* Added a previously unresolved symbol, so we need to go back and replace the dummy value with the real label position */ int dummy = unresolved[i].position; for (int i = dummy; i < dummy + 4; i += 2) { uint16_t word = (output[i + 1] << 8 | output[i]); if (word == dummy) { output[i] = current_position & 0xFF; output[i + 1] = (current_position >> 8) & 0xFF; } } } } symtab[num_symbols++].position = current_position; } int find_symbol(char *label) { for (int i = 0; i < num_symbols; i++) if (strcmp(symtab[i].name, label) == 0) return symtab[i].position + elf_offset; if (strncmp(label, "$$", 2) == 0) return 0; if (strcmp(label, "$") == 0) return current_position + elf_offset; unresolved[unr_symbols].position = current_position; for (int i = 0; i < 32 && i < strlen(label); i++) unresolved[unr_symbols].name[i] = label[i]; unr_symbols++; return current_position; } /* functions to output in little-endian */ void write_byte(uint32_t x) { output[current_position++] = x & 0xFF; } void write_word(uint32_t x) { output[current_position++] = x & 0xFF; output[current_position++] = (x >> 8) & 0xFF; } void write_dword(uint32_t x) { output[current_position++] = x & 0xFF; output[current_position++] = (x >> 8) & 0xFF; output[current_position++] = (x >> 16) & 0xFF; output[current_position++] = (x >> 24) & 0xFF; } #ifndef __MATH__ double log2(double s) { double i = 0; while (s /= 2) i++; return i; } #endif long long lass_atoi(char *s) { long long num = 0; int sign = 1; int base = 10; char *d = strpbrk(s, "x"); if (d != NULL) { base = 16; s = d + 1; } if (s[0] == '-') sign = -1; for (int i = 0; i < strlen(s) && s[i] != '\0'; i++) { if (isdigit(s[i])) num = num * base + (s[i] - '0'); else if (ishex(s[i])) num = num * base + (tolower(s[i]) - 'a') + 10; } return sign * num; } isa *find_instruction(char *s, int op1, int op2) { for (int i = 0; i < sizeof(x86) / sizeof(isa); i++) { if (strcmp(x86[i].name, s) == 0) { if (op1 & sreg) { if ((x86[i].op1 == op1) && ((x86[i].op2 == op2) || (x86[i].op2 == none))) return &x86[i]; } else { if (((x86[i].op1 & op1) == x86[i].op1) && ((x86[i].op2 == op2) || (x86[i].op2 == none))) return &x86[i]; if ((x86[i].op1 == none) && (x86[i].op2 == none)) return &x86[i]; } } } /* Second loop - if we have an imm8 or rel8, but there is no designated imm8/rel8 function, use the 32 bit version. This simply saves some output space, and copies the format that NASM uses */ for (int i = 0; i < sizeof(x86) / sizeof(isa); i++) if (strcmp(x86[i].name, s) == 0) if (((x86[i].op1 & op1) == x86[i].op1) && ((x86[i].op2 & ((op2 & (imm8 | rel8)) ? 0x6C0 : op2)) || (x86[i].op2 == none))) return &x86[i]; return NULL; } /* classify() returns the size of operands and immediates */ int classify(char *s) { if (isdigit(*s)) { long long num = lass_atoi(s); if (abs(num) > UCHAR_MAX) return imm32; else return imm8; } for (int i = 0; i < sizeof(registers) / sizeof(syntax); i++) if (strcmp(registers[i].name, s) == 0) return registers[i].code | r32; for (int i = 0; i < sizeof(half) / sizeof(syntax); i++) if (strcmp(half[i].name, s) == 0) return half[i].code | r8; for (int i = 0; i < sizeof(segments) / sizeof(syntax); i++) if (strcmp(segments[i].name, s) == 0) { return segments[i].code | sreg; } return -1; } typedef struct __instruction_s { int prefix; int operand; int modrm; int sib; int disp; } instruction_s; instruction_s *calc_sib(char *line, int op1) { int scale = -1; int index = -1; int base = -1; char *plus = strchr(line, '+'); char *minus = strchr(line, '-'); char *star = strchr(line, '*'); int c = 0; int disp = 0; int mod = 0; instruction_s *ret = malloc(sizeof(instruction_s)); memset(ret, 0, sizeof(instruction_s)); /* We haven't been provided the first operand by parse_line. This should mean that the displacement IS the first operand: mov [eax+8], ebx etc, etc */ if (op1 == 0) { char *op = strchr(line, ','); if (op != NULL) { printf("%s\n", op); while (*op == ' ' || *op == ',') op++; op1 = classify(op); if (op1 & (imm8 | imm32)) disp = lass_atoi(op); } } /* No multiplication symbol, so we assume that no SIB byte is required */ if (star == NULL) { scale = 0; char *pch = strtok(line, " [+-],"); while (pch) { if (isdigit(*pch)) { disp = lass_atoi(pch); } else { if (c == 0) index = classify(pch) & ~(rm32 | rm8); if (c == 1) base = classify(pch); c++; } pch = strtok(NULL, " [+-],*"); } if (disp) { disp *= (minus) ? -1 : 1; if (disp > UCHAR_MAX) ret->modrm = MODRM(MOD_FOUR, (op1 & ~(r8 | r32)), index); else ret->modrm = MODRM(MOD_ONE, (op1 & ~(r8 | r32)), index); ret->disp = disp; } else { ret->modrm = MODRM((index == EBP) ? MOD_ONE : MOD_ZERO, (op1 & ~(r8 | r32)), index); ret->disp = 0; } return ret; } /* We need to calculate an SIB byte MOD = 00b, 01b, 10b and R/M = 100b */ char *pch = strtok(line, " [+],*"); int n; while (pch) { if (isdigit(*pch)) { n = lass_atoi(pch); if ((plus < star) && (pch < plus)) { disp = n; } if ((plus<star) && (pch> plus)) { scale = n; } } else { if (c == 0) index = classify(pch); if (c == 1) base = classify(pch); c++; } pch = strtok(NULL, " [+],*"); } /* R/M bits equals 4 always. Mod is determined by SIB addressing mode: 00 = [reg32 + eax*n] 01 = [disp + reg8 + eax*n] 10 = [disp + reg32 + eax*n] 00 = [disp + eax*n], base field = 101 */ if (index && base) { if (index & r32) mod = 2; else mod = 1; index &= ~(r8 | r32); base &= ~(r8 | r32); } if (base == -1) { base = 5; mod = 0; } scale = log2(scale); ret->modrm = MODRM(mod, op1, 4); ret->sib = MODRM(scale, index, base); ret->disp = disp; return ret; } void parse_line(char *line, int pass_no) { if (pass_no > 1) printf("%08x %-20s\n", current_position, line); char *displacement = NULL; char *disp = strpbrk(line, "["); if (disp) displacement = strdup(disp); // split line by spaces and commas char *pch = strtok(line, " ,\t"); // store instruction char *inst; uint64_t syn[2] = {0, 0}; // number of items in line int count = 0; // store value of immediates int immediate = 0; int imm = 0; // default to MOD 11b int mode = MOD_REG; int m = -1; int rev = 0; int sib = 0; if (*pch == 'd') { char next = *(pch + 1); pch = strtok(NULL, ", '\""); while (pch) { switch(next) { case 'b': { if (isdigit(*pch)) { write_byte(lass_atoi(pch)); } else { while(*pch) write_byte(*pch++); } break; } case 'w': write_word(lass_atoi(pch)); break; case 'd': write_dword(lass_atoi(pch)); break; default: printf("Unrecognized symbol d%c\n", next); return; } pch = strtok(NULL, ", '\""); } return; } while (pch && *pch != ';') { if (pch == disp && disp) { // Do something instruction_s *a = calc_sib(displacement, syn[0]); m = a->modrm; sib = a->sib; immediate = a->disp; mode = (m >> 6); imm = 1; syn[1] |= (r32); if (syn[0] == 0) { syn[0] = ((m >> 3) & 0x7) | r32; rev = 1; } break; } if (count == 0) { inst = strdup(pch); } else { int n = classify(pch); if (n & (imm8 | imm32)) { imm = 1; immediate = lass_atoi(pch); } // label maybe? if (n == -1) { immediate = find_symbol(pch); imm = 1; n = rel8; } syn[count - 1] = n; } count++; // get next token pch = strtok(NULL, " ,\t"); } isa *instruction = find_instruction(inst, syn[0], syn[1]); int start = current_position; if (instruction) { int o = instruction->primary; // Get any prefixes taken care of if (instruction->secondary) write_byte(instruction->secondary); if (instruction->prefix) write_byte(0x0F); // Two operands if (syn[1]) { if ((syn[0] & (r32 | r8 | sreg)) && (syn[1] & (r32 | r8 | sreg))) m = (m == -1) ? MODRM(mode, syn[0] &= ~(r32 | r8 | sreg), syn[1] &= ~(r32 | r8 | sreg)) : m; else if ((syn[0] & (r32 | r8)) && (syn[1] & (imm8 | imm32 | rel8 | rel32))) m = (m == -1) ? MODRM(mode, instruction->extension, syn[0] &= ~(r32 | r8)) : m; if ((syn[0] & (imm8 | imm32 | rel8 | rel32))) m = MODRM(mode, instruction->extension, 0); // switch d flag if (rev) o ^= 0x2; // Macro value for alternate encodings if (instruction->extension == 0xDEAD) write_byte(((o & ~0x7) | (syn[0] & ~(r32 | r8)))); else write_word(m << 8 | o); } else { // One operand? if (instruction->extension == 0xDEAD && m == -1) { write_byte(((o & ~0x7) | (syn[0] & ~(r32 | r8 | sreg)))); } else { if (!syn[0]) write_byte(o); // Immediate, relative, none or ss/fs/gs/etc else if (syn[0] & 0x6C0 || (syn[0] & sreg)) write_byte(o); else if (syn[0] != none) { m = (m == -1) ? MODRM(mode, instruction->extension, syn[0] & ~(r32 | r8 | sreg)) : m; write_word(m << 8 | o); } } } /* If there's an SIB byte, write it now */ if (sib) { write_byte(sib); } if (imm) { int sw = (instruction->op2 == none) ? instruction->op1 : instruction->op2; switch (sw) { case imm8: write_byte(immediate & 0xFF); break; case imm32: write_dword(immediate); break; case rel8: // Calculate relative offset write_byte(immediate - current_position - (current_position - start) - elf_offset); break; case rel32: write_dword(immediate - current_position - (current_position - start) - elf_offset); break; default: // SIB/Displacement if (mode == 1) write_byte(immediate); else write_dword(immediate); } } } else { printf("instruction: %s not recognized?\n", inst); } } void pass(char *buffer, int sz, int pass_no) { char **lines = malloc(sz); *lines = buffer; void* start = lines; for (int i = 0; i < sz; i++) { if (buffer[i] == '\n') { buffer[i] = '\0'; char *new = buffer + i + 1; if (*new) *(lines++) = new; } } for (lines = start; *lines; lines++) { if (**lines != ';' && **lines) { // Remove comment-only lines if (strchr(*lines, ':')) { char *c = strchr(*lines, ':'); *c = '\0'; // remove the semi colon add_symbol(*lines); } else parse_line(*lines, pass_no); } } free(start); } int main(int argc, char *argv[]) { if (argc < 2) { printf("usage: lass input.s\n"); return -1; } char *fname = argv[1]; int fp = open(fname, O_RDWR, 0444); assert(fp); // seek to end of file so that we can calculate size int sz = lseek(fp, 0, SEEK_END); if (sz < 1) return -1; // Seek back to beginning lseek(fp, 0, SEEK_SET); // Allocate file buffer and read into it char *buffer = malloc(sz); output = malloc(sz); pread(fp, buffer, sz, 0); // First pass, generate labels printf("lass: read %d bytes from %s\n", sz, fname); printf("First pass, finding labels:\n"); pass(buffer, sz, 1); // Second pass program_length = current_position; current_position = 0; if (strcmp("elf", argv[2]) == 0) make_elf(); pread(fp, buffer, sz, 0); pass(buffer, sz, 2); FILE *fd = fopen("output", "wb"); assert(fd); fwrite(elf_output, 1, elf_offset, fd); fwrite(output, 1, current_position, fd); fflush(fd); free(buffer); printf("Wrote %d bytes to %s\n", current_position, "output"); return 0; }
lazear/lass
elf.h
/* elf.h =============================================================================== MIT License Copyright (c) 2007-2016 <NAME> 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 <stdint.h> #define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian /* e_type definitions */ #define ET_NONE 0 #define ET_REL 1 // Relocatable file #define ET_EXEC 2 // Executable #define ET_DYN 3 // Shared object file #define ET_CORE 4 // Core file #define EM_386 3 // Intel x86 typedef struct { uint32_t e_ident[4]; /* Magic number and other info */ uint16_t e_type; /* Object file type */ uint16_t e_machine; /* Architecture */ uint32_t e_version; /* Object file version */ uint32_t e_entry; /* Entry point virtual address */ uint32_t e_phoff; /* Program header table file offset */ uint32_t e_shoff; /* Section header table file offset */ uint32_t e_flags; /* Processor-specific flags */ uint16_t e_ehsize; /* ELF header size in bytes */ uint16_t e_phentsize; /* Program header table entry size */ uint16_t e_phnum; /* Program header table entry count */ uint16_t e_shentsize; /* Section header table entry size */ uint16_t e_shnum; /* Section header table entry count */ uint16_t e_shstrndx; /* Section header string table index */ } elf32_ehdr; #define SHT_NULL 0 /* inactive */ #define SHT_PROGBITS 1 /* Program defined */ #define SHT_SYMTAB 2 /* Symbol table */ #define SHT_STRTAB 3 /* String table */ #define SHT_RELA 4 /* Relocation entries Elf32_Rela */ #define SHT_HASH 5 #define SHT_DYNAMIC 6 #define SHT_NOTE 7 #define SHT_NOBITS 8 /* .bss */ #define SHT_REL 9 /* Relocation entries Elf32_Rel */ #define SHT_SHLIB 10 #define SHT_DYNSYM 11 #define SHF_WRITE 1 /* Writable data */ #define SHF_ALLOC 2 /* Allocated memory */ #define SHF_EXEC 4 /* Executable instr */ typedef struct { uint32_t sh_name; /* Index into section header str table */ uint32_t sh_type; /* Section header type */ uint32_t sh_flags; uint32_t sh_addr; /* Address the section should appear at */ uint32_t sh_offset; /* Offset from first byte in file */ uint32_t sh_size; uint32_t sh_link; uint32_t sh_info; uint32_t sh_addralign; /* Address alignment constraints */ uint32_t sh_entsize; } elf32_shdr; typedef struct { uint32_t p_type; uint32_t p_offset; /* offset from beginning of file */ uint32_t p_vaddr; uint32_t p_paddr; uint32_t p_filesz; /* bytes of segment in file */ uint32_t p_memsz; /* bytes of segment in memory */ uint32_t p_flags; uint32_t p_align; } elf32_phdr; // table index 0 is reserved typedef struct { uint16_t st_name; uint32_t st_value; uint16_t st_size; uint8_t st_info; uint8_t st_other; uint16_t st_shndx; } elf32_sym; #define STB_LOCAL 0 #define STB_GLOBAL 1 #define STT_NOTYPE 0 #define STT_OBJECT 1 #define STT_FUNC 2 #define STT_SECTION 3 #define STT_FILE 4
ufosky/USRuntimeHelper
USRuntimeHelper/USRuntimeHelper.h
<gh_stars>1-10 // // USRuntimeHelper.h // USRuntimeHelper // // Created by <NAME> on 9/25/14. // Copyright (c) 2014 ufosky.<EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> void US_invokeInstanceMethod(id obj, NSString *selectorName, NSArray *arguments, void *returnValue); void US_invokeClassMethod(Class cls, NSString *selectorName, NSArray *arguments, void *returnValue); void US_invokeClassMethodByName(NSString *className, NSString *selectorName, NSArray *arguments, void *returnValue); void US_swizzleInstanceMethod(Class c, SEL orig, SEL new); void US_swizzleClassMethod(Class c, SEL orig, SEL new); void US_replaceClassMethod(Class c, SEL sel, SEL backup, IMP imp); void US_replaceClassMethodByName(Class c, NSString *selName, NSString *backupName, IMP imp); void US_replaceInstanceMethod(Class c, SEL sel, SEL backup, IMP imp); void US_replaceInstanceMethodByName(Class c, NSString *selName, NSString *backupName, IMP imp);
jehung/universal_portfolio
universal_portfolio/rrl_trading/04_cython_cppwraper/tradingrrl_.h
<gh_stars>10-100 #ifndef TRADINGRRL_H #define TRADINGRRL_H #include <fstream> #include <string> #include <sstream> #include <vector> #include <iostream> #include <math.h> #include <ctime> using namespace std; namespace tradingrrl{ class cppTradingRRL{ public: int T; int M; int init_t; double mu; double sigma; double rho; int n_epoch; int progress_period; double q_threshold; vector<string> all_t; vector<double> all_p; vector<string> t; vector<double> p; vector<double> r; vector< vector<double> > x; vector<double> F; vector<double> R; vector<double> w; vector<double> w_opt; vector<double> epoch_S; vector<double> sumR; vector<double> sumR2; double A; double B; double S; double S_opt; double dSdA; double dSdB; double dAdR; vector<double> dBdR; vector<double> dRdF; vector<double> dRdFp; vector<double> dFpdw; vector<double> dFdw; vector<double> dSdw; private: vector<string> split(string& input, char delimiter); public: // Constructor cppTradingRRL(int T, int M, int init_t, double mu, double sigma, double rho, int n_epoch); // Destructor ~cppTradingRRL(); // Menber functions void load_csv(string fname); int quant(double f, double threshold); double sign(double f); void set_t_p_r(); void set_x_F(); void calc_R(); void calc_sumR(); void calc_dSdw(); void update_w(); void fit(); void save_weight(); void load_weight(); }; } #endif
jehung/universal_portfolio
universal_portfolio/rrl_trading/02_cython/tradingrrl.c
/* Generated by Cython 0.25.2 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_25_2" #include <stddef.h> #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef HAVE_LONG_LONG #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && 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_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #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 #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_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 #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_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 #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 #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast #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))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_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 #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_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 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !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 #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if 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 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #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) #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #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; \ } #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__tradingrrl #define __PYX_HAVE_API__tradingrrl #include <string.h> #include <stdio.h> #include <stdlib.h> #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #ifdef PYREX_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_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include <cstdlib> #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_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)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static 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[] = { "tradingrrl.pyx", "__init__.pxd", "type.pxd", }; /* 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; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* "tradingrrl.pyx":10 * cimport cython * * ctypedef np.float64_t DOUBLE_t # <<<<<<<<<<<<<< * ctypedef np.int_t INT_t * */ typedef __pyx_t_5numpy_float64_t __pyx_t_10tradingrrl_DOUBLE_t; /* "tradingrrl.pyx":11 * * ctypedef np.float64_t DOUBLE_t * ctypedef np.int_t INT_t # <<<<<<<<<<<<<< * * import time */ typedef __pyx_t_5numpy_int_t __pyx_t_10tradingrrl_INT_t; /* 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_obj_10tradingrrl_TradingRRL; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* "tradingrrl.pyx":19 * import matplotlib.pyplot as plt * * cdef class TradingRRL(object): # <<<<<<<<<<<<<< * cdef public int T * cdef public int M */ struct __pyx_obj_10tradingrrl_TradingRRL { PyObject_HEAD int T; int M; int init_t; double mu; double sigma; double rho; PyArrayObject *all_t; PyArrayObject *all_p; PyArrayObject *t; PyArrayObject *p; PyArrayObject *r; PyArrayObject *x; PyArrayObject *F; PyArrayObject *R; PyArrayObject *w; PyArrayObject *w_opt; PyArrayObject *epoch_S; int n_epoch; int progress_period; double q_threshold; PyArrayObject *sumR; PyArrayObject *sumR2; double A; double B; double S; double S_opt; double dSdA; double dSdB; double dAdR; PyArrayObject *dBdR; PyArrayObject *dRdF; PyArrayObject *dRdFp; PyArrayObject *dFpdw; PyArrayObject *dFdw; PyArrayObject *dSdw; }; /* --- 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) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* 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); /* 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); /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* 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 /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* 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 CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* 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 /* 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 #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 /* 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); /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* SliceObject.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** py_start, PyObject** py_stop, PyObject** py_slice, int has_cstart, int has_cstop, int wraparound); /* BufferFormatCheck.proto */ static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); 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); // PROTO /* BufferFallbackError.proto */ static void __Pyx_RaiseBufferFallbackError(void); #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0) /* SetItemInt.proto */ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #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); #else #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(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 /* None.proto */ static CYTHON_INLINE int __Pyx_mod_int(int, int); /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif /* 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); /* 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 /* 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 /* 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 /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* 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); /* 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; #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 /* None.proto */ static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* Print.proto */ static int __Pyx_Print(PyObject*, PyObject *, int); #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 static PyObject* __pyx_print = 0; static PyObject* __pyx_print_kwargs = 0; #endif /* 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 /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* PrintOne.proto */ static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* PyIdentifierFromString.proto */ #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif /* ModuleImport.proto */ static PyObject *__Pyx_ImportModule(const char *name); /* TypeImport.proto */ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'tradingrrl' */ static PyTypeObject *__pyx_ptype_10tradingrrl_TradingRRL = 0; static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t = { "DOUBLE_t", NULL, sizeof(__pyx_t_10tradingrrl_DOUBLE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "tradingrrl" int __pyx_module_is_main_tradingrrl = 0; /* Implementation of 'tradingrrl' */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_xrange; static PyObject *__pyx_builtin_max; static PyObject *__pyx_builtin_min; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_RuntimeError; static PyObject *__pyx_builtin_ImportError; static const char __pyx_k_C[] = "C"; static const char __pyx_k_M[] = "M"; static const char __pyx_k_R[] = "R"; static const char __pyx_k_T[] = "T"; static const char __pyx_k_i[] = "i"; static const char __pyx_k__2[] = " "; static const char __pyx_k_dt[] = "dt"; static const char __pyx_k_mu[] = "mu"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k__10[] = "."; static const char __pyx_k__11[] = "/"; static const char __pyx_k__24[] = "*"; static const char __pyx_k_abs[] = "abs"; static const char __pyx_k_bar[] = "bar"; static const char __pyx_k_dot[] = "dot"; static const char __pyx_k_end[] = "end"; static const char __pyx_k_max[] = "max"; static const char __pyx_k_min[] = "min"; static const char __pyx_k_plt[] = "plt"; static const char __pyx_k_rho[] = "rho"; static const char __pyx_k_sec[] = " sec."; static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_diff[] = "diff"; static const char __pyx_k_file[] = "file"; static const char __pyx_k_grid[] = "grid"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_ones[] = "ones"; static const char __pyx_k_rnge[] = "rnge"; static const char __pyx_k_show[] = "show"; static const char __pyx_k_sign[] = "sign"; static const char __pyx_k_sqrt[] = "sqrt"; static const char __pyx_k_tanh[] = "tanh"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_tick[] = "tick"; static const char __pyx_k_time[] = "time"; static const char __pyx_k_Epoch[] = "Epoch: "; static const char __pyx_k_array[] = "array"; static const char __pyx_k_clock[] = "clock"; static const char __pyx_k_dtype[] = "dtype"; static const char __pyx_k_empty[] = "empty"; static const char __pyx_k_index[] = "index"; static const char __pyx_k_numpy[] = "numpy"; static const char __pyx_k_order[] = "order"; static const char __pyx_k_print[] = "print"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_sigma[] = "sigma"; static const char __pyx_k_w_csv[] = "w.csv"; static const char __pyx_k_where[] = "where"; static const char __pyx_k_width[] = "width"; static const char __pyx_k_zeros[] = "zeros"; static const char __pyx_k_append[] = "append"; static const char __pyx_k_calc_R[] = "calc_R"; static const char __pyx_k_cumsum[] = "cumsum"; static const char __pyx_k_header[] = "header"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_init_t[] = "init_t"; static const char __pyx_k_n_tick[] = "n_tick"; static const char __pyx_k_pandas[] = "pandas"; static const char __pyx_k_pickle[] = "pickle"; static const char __pyx_k_to_csv[] = "to_csv"; static const char __pyx_k_tolist[] = "tolist"; static const char __pyx_k_values[] = "values"; static const char __pyx_k_xrange[] = "xrange"; static const char __pyx_k_float64[] = "float64"; static const char __pyx_k_n_epoch[] = "n_epoch"; static const char __pyx_k_set_x_F[] = "set_x_F"; static const char __pyx_k_datetime[] = "datetime"; static const char __pyx_k_read_csv[] = "read_csv"; static const char __pyx_k_strptime[] = "strptime"; static const char __pyx_k_tick_max[] = "tick_max"; static const char __pyx_k_tick_min[] = "tick_min"; static const char __pyx_k_tick_val[] = "tick_val"; static const char __pyx_k_update_w[] = "update_w"; static const char __pyx_k_DataFrame[] = "DataFrame"; static const char __pyx_k_Y_m_d_H_M[] = "%Y.%m.%d %H:%M"; static const char __pyx_k_calc_dSdw[] = "calc_dSdw"; static const char __pyx_k_calc_sumR[] = "calc_sumR"; static const char __pyx_k_plot_hist[] = "plot_hist"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_tradingrrl[] = "tradingrrl"; static const char __pyx_k_ImportError[] = "ImportError"; static const char __pyx_k_epoch_S_csv[] = "epoch_S.csv"; static const char __pyx_k_tick_center[] = "tick_center"; static const char __pyx_k_Elapsed_time[] = ". Elapsed time: "; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_intersection[] = "intersection"; static const char __pyx_k_Shape_s_ratio[] = ". Shape's ratio: "; static const char __pyx_k_matplotlib_pyplot[] = "matplotlib.pyplot"; static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static const char __pyx_k_C_Work_Work_Dropbox_Dropbox_Jupy[] = "C:\\Work\\Work_Dropbox\\Dropbox\\Jupyter\\reinforcement_learning\\tradingrrl\\02_cython\\tradingrrl.pyx"; static const char __pyx_k_Epoch_loop_end_Optimized_sharp_s[] = "Epoch loop end. Optimized sharp's ratio is "; static const char __pyx_k_Epoch_loop_start_Initial_sharp_s[] = "Epoch loop start. Initial sharp's ratio is "; static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_C; static PyObject *__pyx_kp_s_C_Work_Work_Dropbox_Dropbox_Jupy; static PyObject *__pyx_n_s_DataFrame; static PyObject *__pyx_kp_s_Elapsed_time; static PyObject *__pyx_kp_s_Epoch; static PyObject *__pyx_kp_s_Epoch_loop_end_Optimized_sharp_s; static PyObject *__pyx_kp_s_Epoch_loop_start_Initial_sharp_s; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_n_s_ImportError; static PyObject *__pyx_n_s_M; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_R; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_kp_s_Shape_s_ratio; static PyObject *__pyx_n_s_T; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_kp_s_Y_m_d_H_M; static PyObject *__pyx_kp_s__10; static PyObject *__pyx_kp_s__11; static PyObject *__pyx_kp_s__2; static PyObject *__pyx_n_s__24; static PyObject *__pyx_n_s_abs; static PyObject *__pyx_n_s_append; static PyObject *__pyx_n_s_array; static PyObject *__pyx_n_s_bar; static PyObject *__pyx_n_s_calc_R; static PyObject *__pyx_n_s_calc_dSdw; static PyObject *__pyx_n_s_calc_sumR; static PyObject *__pyx_n_s_clock; static PyObject *__pyx_n_s_copy; static PyObject *__pyx_n_s_cumsum; static PyObject *__pyx_n_s_datetime; static PyObject *__pyx_n_s_diff; static PyObject *__pyx_n_s_dot; static PyObject *__pyx_n_s_dt; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_empty; static PyObject *__pyx_n_s_end; static PyObject *__pyx_kp_s_epoch_S_csv; static PyObject *__pyx_n_s_file; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_grid; static PyObject *__pyx_n_s_header; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_index; static PyObject *__pyx_n_s_init_t; static PyObject *__pyx_n_s_intersection; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_matplotlib_pyplot; static PyObject *__pyx_n_s_max; static PyObject *__pyx_n_s_min; static PyObject *__pyx_n_s_mu; static PyObject *__pyx_n_s_n_epoch; static PyObject *__pyx_n_s_n_tick; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; static PyObject *__pyx_n_s_ones; static PyObject *__pyx_n_s_order; static PyObject *__pyx_n_s_pandas; static PyObject *__pyx_n_s_pd; static PyObject *__pyx_n_s_pickle; static PyObject *__pyx_n_s_plot_hist; static PyObject *__pyx_n_s_plt; static PyObject *__pyx_n_s_print; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_read_csv; static PyObject *__pyx_n_s_rho; static PyObject *__pyx_n_s_rnge; static PyObject *__pyx_kp_s_sec; static PyObject *__pyx_n_s_set_x_F; static PyObject *__pyx_n_s_show; static PyObject *__pyx_n_s_sigma; static PyObject *__pyx_n_s_sign; static PyObject *__pyx_n_s_sqrt; static PyObject *__pyx_n_s_strptime; static PyObject *__pyx_n_s_tanh; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_tick; static PyObject *__pyx_n_s_tick_center; static PyObject *__pyx_n_s_tick_max; static PyObject *__pyx_n_s_tick_min; static PyObject *__pyx_n_s_tick_val; static PyObject *__pyx_n_s_time; static PyObject *__pyx_n_s_to_csv; static PyObject *__pyx_n_s_tolist; static PyObject *__pyx_n_s_tradingrrl; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_update_w; static PyObject *__pyx_n_s_values; static PyObject *__pyx_kp_s_w_csv; static PyObject *__pyx_n_s_where; static PyObject *__pyx_n_s_width; static PyObject *__pyx_n_s_xrange; static PyObject *__pyx_n_s_zeros; static int __pyx_pf_10tradingrrl_10TradingRRL___init__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_T, PyObject *__pyx_v_M, PyObject *__pyx_v_init_t, PyObject *__pyx_v_mu, PyObject *__pyx_v_sigma, PyObject *__pyx_v_rho, PyObject *__pyx_v_n_epoch); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_2load_csv(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_fname); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4quant(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_f); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_6set_t_p_r(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_8set_x_F(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_10calc_R(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_12calc_sumR(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_14calc_dSdw(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_16update_w(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_18fit(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_20save_weight(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_22load_weight(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1T___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1T_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1M___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1M_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_6init_t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_6init_t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_2mu___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_2mu_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5sigma___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5sigma_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_3rho___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_3rho_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5all_t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5all_t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5all_t_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5all_p___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5all_p_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5all_p_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1t_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1p___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1p_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1p_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1r___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1r_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1r_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1x___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1x_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1x_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1F___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1F_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1F_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1R___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1R_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1R_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1w___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1w_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1w_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5w_opt___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_7epoch_S___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_7n_epoch___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_7n_epoch_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_15progress_period___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_15progress_period_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_11q_threshold___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_11q_threshold_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4sumR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4sumR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4sumR_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5sumR2___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1A___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1A_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1B___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1B_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1S___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_1S_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5S_opt___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5S_opt_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdA___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdA_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdB___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdB_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dAdR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dAdR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dBdR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dRdF___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5dRdFp___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5dFpdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dFdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10tradingrrl_plot_hist(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n_tick, PyObject *__pyx_v_R); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tp_new_10tradingrrl_TradingRRL(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_float_0_0; static PyObject *__pyx_float_0_5; static PyObject *__pyx_float_1_0; static PyObject *__pyx_float_0_04; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_int_200; static PyObject *__pyx_int_1000; static PyObject *__pyx_int_10000; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_slice__3; static PyObject *__pyx_slice__4; static PyObject *__pyx_slice__5; static PyObject *__pyx_slice__6; static PyObject *__pyx_slice__7; static PyObject *__pyx_slice__8; static PyObject *__pyx_slice__9; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__15; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__17; static PyObject *__pyx_tuple__18; static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__21; static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__23; static PyObject *__pyx_tuple__25; static PyObject *__pyx_codeobj__26; /* "tradingrrl.pyx":56 * cdef public np.ndarray dSdw * * def __init__(self, T=1000, M=200, init_t=10000, mu=10000, sigma=0.04, rho=1.0, n_epoch=10000): # <<<<<<<<<<<<<< * self.T = T * self.M = M */ /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_T = 0; PyObject *__pyx_v_M = 0; PyObject *__pyx_v_init_t = 0; PyObject *__pyx_v_mu = 0; PyObject *__pyx_v_sigma = 0; PyObject *__pyx_v_rho = 0; PyObject *__pyx_v_n_epoch = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_T,&__pyx_n_s_M,&__pyx_n_s_init_t,&__pyx_n_s_mu,&__pyx_n_s_sigma,&__pyx_n_s_rho,&__pyx_n_s_n_epoch,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; values[0] = ((PyObject *)__pyx_int_1000); values[1] = ((PyObject *)__pyx_int_200); values[2] = ((PyObject *)__pyx_int_10000); values[3] = ((PyObject *)__pyx_int_10000); values[4] = ((PyObject *)__pyx_float_0_04); values[5] = ((PyObject *)__pyx_float_1_0); values[6] = ((PyObject *)__pyx_int_10000); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_T); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_M); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_init_t); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mu); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sigma); if (value) { values[4] = value; kw_args--; } } case 5: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rho); if (value) { values[5] = value; kw_args--; } } case 6: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_epoch); if (value) { values[6] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 56, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_T = values[0]; __pyx_v_M = values[1]; __pyx_v_init_t = values[2]; __pyx_v_mu = values[3]; __pyx_v_sigma = values[4]; __pyx_v_rho = values[5]; __pyx_v_n_epoch = values[6]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 56, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL___init__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), __pyx_v_T, __pyx_v_M, __pyx_v_init_t, __pyx_v_mu, __pyx_v_sigma, __pyx_v_rho, __pyx_v_n_epoch); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL___init__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_T, PyObject *__pyx_v_M, PyObject *__pyx_v_init_t, PyObject *__pyx_v_mu, PyObject *__pyx_v_sigma, PyObject *__pyx_v_rho, PyObject *__pyx_v_n_epoch) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; double __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; __Pyx_RefNannySetupContext("__init__", 0); /* "tradingrrl.pyx":57 * * def __init__(self, T=1000, M=200, init_t=10000, mu=10000, sigma=0.04, rho=1.0, n_epoch=10000): * self.T = T # <<<<<<<<<<<<<< * self.M = M * self.init_t = init_t */ __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_T); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error) __pyx_v_self->T = __pyx_t_1; /* "tradingrrl.pyx":58 * def __init__(self, T=1000, M=200, init_t=10000, mu=10000, sigma=0.04, rho=1.0, n_epoch=10000): * self.T = T * self.M = M # <<<<<<<<<<<<<< * self.init_t = init_t * self.mu = mu */ __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_M); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 58, __pyx_L1_error) __pyx_v_self->M = __pyx_t_1; /* "tradingrrl.pyx":59 * self.T = T * self.M = M * self.init_t = init_t # <<<<<<<<<<<<<< * self.mu = mu * self.sigma = sigma */ __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_init_t); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L1_error) __pyx_v_self->init_t = __pyx_t_1; /* "tradingrrl.pyx":60 * self.M = M * self.init_t = init_t * self.mu = mu # <<<<<<<<<<<<<< * self.sigma = sigma * self.rho = rho */ __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_mu); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L1_error) __pyx_v_self->mu = __pyx_t_2; /* "tradingrrl.pyx":61 * self.init_t = init_t * self.mu = mu * self.sigma = sigma # <<<<<<<<<<<<<< * self.rho = rho * self.all_t = None */ __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_sigma); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error) __pyx_v_self->sigma = __pyx_t_2; /* "tradingrrl.pyx":62 * self.mu = mu * self.sigma = sigma * self.rho = rho # <<<<<<<<<<<<<< * self.all_t = None * self.all_p = None */ __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_rho); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L1_error) __pyx_v_self->rho = __pyx_t_2; /* "tradingrrl.pyx":63 * self.sigma = sigma * self.rho = rho * self.all_t = None # <<<<<<<<<<<<<< * self.all_p = None * self.t = None */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->all_t); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_t)); __pyx_v_self->all_t = ((PyArrayObject *)Py_None); /* "tradingrrl.pyx":64 * self.rho = rho * self.all_t = None * self.all_p = None # <<<<<<<<<<<<<< * self.t = None * self.p = None */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->all_p); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_p)); __pyx_v_self->all_p = ((PyArrayObject *)Py_None); /* "tradingrrl.pyx":65 * self.all_t = None * self.all_p = None * self.t = None # <<<<<<<<<<<<<< * self.p = None * self.r = None */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->t); __Pyx_DECREF(((PyObject *)__pyx_v_self->t)); __pyx_v_self->t = ((PyArrayObject *)Py_None); /* "tradingrrl.pyx":66 * self.all_p = None * self.t = None * self.p = None # <<<<<<<<<<<<<< * self.r = None * self.x = np.zeros([T,M+2], dtype=np.float64) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->p); __Pyx_DECREF(((PyObject *)__pyx_v_self->p)); __pyx_v_self->p = ((PyArrayObject *)Py_None); /* "tradingrrl.pyx":67 * self.t = None * self.p = None * self.r = None # <<<<<<<<<<<<<< * self.x = np.zeros([T,M+2], dtype=np.float64) * self.F = np.zeros(T+1, dtype=np.float64) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->r); __Pyx_DECREF(((PyObject *)__pyx_v_self->r)); __pyx_v_self->r = ((PyArrayObject *)Py_None); /* "tradingrrl.pyx":68 * self.p = None * self.r = None * self.x = np.zeros([T,M+2], dtype=np.float64) # <<<<<<<<<<<<<< * self.F = np.zeros(T+1, dtype=np.float64) * self.R = np.zeros(T, dtype=np.float64) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_T); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->x); __Pyx_DECREF(((PyObject *)__pyx_v_self->x)); __pyx_v_self->x = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; /* "tradingrrl.pyx":69 * self.r = None * self.x = np.zeros([T,M+2], dtype=np.float64) * self.F = np.zeros(T+1, dtype=np.float64) # <<<<<<<<<<<<<< * self.R = np.zeros(T, dtype=np.float64) * self.w = np.ones(M+2, dtype=np.float64) */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_v_T, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __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 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_6); __Pyx_GOTREF(__pyx_v_self->F); __Pyx_DECREF(((PyObject *)__pyx_v_self->F)); __pyx_v_self->F = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; /* "tradingrrl.pyx":70 * self.x = np.zeros([T,M+2], dtype=np.float64) * self.F = np.zeros(T+1, dtype=np.float64) * self.R = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.w = np.ones(M+2, dtype=np.float64) * self.w_opt = np.ones(M+2, dtype=np.float64) */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_T); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->R); __Pyx_DECREF(((PyObject *)__pyx_v_self->R)); __pyx_v_self->R = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":71 * self.F = np.zeros(T+1, dtype=np.float64) * self.R = np.zeros(T, dtype=np.float64) * self.w = np.ones(M+2, dtype=np.float64) # <<<<<<<<<<<<<< * self.w_opt = np.ones(M+2, dtype=np.float64) * self.epoch_S = np.empty(0, dtype=np.float64) */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0; /* "tradingrrl.pyx":72 * self.R = np.zeros(T, dtype=np.float64) * self.w = np.ones(M+2, dtype=np.float64) * self.w_opt = np.ones(M+2, dtype=np.float64) # <<<<<<<<<<<<<< * self.epoch_S = np.empty(0, dtype=np.float64) * self.n_epoch = n_epoch */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->w_opt); __Pyx_DECREF(((PyObject *)__pyx_v_self->w_opt)); __pyx_v_self->w_opt = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; /* "tradingrrl.pyx":73 * self.w = np.ones(M+2, dtype=np.float64) * self.w_opt = np.ones(M+2, dtype=np.float64) * self.epoch_S = np.empty(0, dtype=np.float64) # <<<<<<<<<<<<<< * self.n_epoch = n_epoch * self.progress_period = 100 */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->epoch_S); __Pyx_DECREF(((PyObject *)__pyx_v_self->epoch_S)); __pyx_v_self->epoch_S = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":74 * self.w_opt = np.ones(M+2, dtype=np.float64) * self.epoch_S = np.empty(0, dtype=np.float64) * self.n_epoch = n_epoch # <<<<<<<<<<<<<< * self.progress_period = 100 * self.q_threshold = 0.7 */ __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_n_epoch); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error) __pyx_v_self->n_epoch = __pyx_t_1; /* "tradingrrl.pyx":75 * self.epoch_S = np.empty(0, dtype=np.float64) * self.n_epoch = n_epoch * self.progress_period = 100 # <<<<<<<<<<<<<< * self.q_threshold = 0.7 * self.sumR = np.zeros(T, dtype=np.float64) */ __pyx_v_self->progress_period = 0x64; /* "tradingrrl.pyx":76 * self.n_epoch = n_epoch * self.progress_period = 100 * self.q_threshold = 0.7 # <<<<<<<<<<<<<< * self.sumR = np.zeros(T, dtype=np.float64) * self.sumR2 = np.zeros(T, dtype=np.float64) */ __pyx_v_self->q_threshold = 0.7; /* "tradingrrl.pyx":77 * self.progress_period = 100 * self.q_threshold = 0.7 * self.sumR = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.sumR2 = np.zeros(T, dtype=np.float64) * self.A = 0.0 */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_T); __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->sumR); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR)); __pyx_v_self->sumR = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":78 * self.q_threshold = 0.7 * self.sumR = np.zeros(T, dtype=np.float64) * self.sumR2 = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.A = 0.0 * self.B = 0.0 */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_T); __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_6); __Pyx_GOTREF(__pyx_v_self->sumR2); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_v_self->sumR2 = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; /* "tradingrrl.pyx":79 * self.sumR = np.zeros(T, dtype=np.float64) * self.sumR2 = np.zeros(T, dtype=np.float64) * self.A = 0.0 # <<<<<<<<<<<<<< * self.B = 0.0 * self.S = 0.0 */ __pyx_v_self->A = 0.0; /* "tradingrrl.pyx":80 * self.sumR2 = np.zeros(T, dtype=np.float64) * self.A = 0.0 * self.B = 0.0 # <<<<<<<<<<<<<< * self.S = 0.0 * self.S_opt = 0.0 */ __pyx_v_self->B = 0.0; /* "tradingrrl.pyx":81 * self.A = 0.0 * self.B = 0.0 * self.S = 0.0 # <<<<<<<<<<<<<< * self.S_opt = 0.0 * self.dSdA = 0.0 */ __pyx_v_self->S = 0.0; /* "tradingrrl.pyx":82 * self.B = 0.0 * self.S = 0.0 * self.S_opt = 0.0 # <<<<<<<<<<<<<< * self.dSdA = 0.0 * self.dSdB = 0.0 */ __pyx_v_self->S_opt = 0.0; /* "tradingrrl.pyx":83 * self.S = 0.0 * self.S_opt = 0.0 * self.dSdA = 0.0 # <<<<<<<<<<<<<< * self.dSdB = 0.0 * self.dAdR = 0.0 */ __pyx_v_self->dSdA = 0.0; /* "tradingrrl.pyx":84 * self.S_opt = 0.0 * self.dSdA = 0.0 * self.dSdB = 0.0 # <<<<<<<<<<<<<< * self.dAdR = 0.0 * self.dBdR = np.zeros(T, dtype=np.float64) */ __pyx_v_self->dSdB = 0.0; /* "tradingrrl.pyx":85 * self.dSdA = 0.0 * self.dSdB = 0.0 * self.dAdR = 0.0 # <<<<<<<<<<<<<< * self.dBdR = np.zeros(T, dtype=np.float64) * self.dRdF = np.zeros(T, dtype=np.float64) */ __pyx_v_self->dAdR = 0.0; /* "tradingrrl.pyx":86 * self.dSdB = 0.0 * self.dAdR = 0.0 * self.dBdR = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.dRdF = np.zeros(T, dtype=np.float64) * self.dRdFp = np.zeros(T, dtype=np.float64) */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_T); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->dBdR); __Pyx_DECREF(((PyObject *)__pyx_v_self->dBdR)); __pyx_v_self->dBdR = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; /* "tradingrrl.pyx":87 * self.dAdR = 0.0 * self.dBdR = np.zeros(T, dtype=np.float64) * self.dRdF = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.dRdFp = np.zeros(T, dtype=np.float64) * self.dFpdw = np.zeros(M+2, dtype=np.float64) */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_T); __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->dRdF); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdF)); __pyx_v_self->dRdF = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0; /* "tradingrrl.pyx":88 * self.dBdR = np.zeros(T, dtype=np.float64) * self.dRdF = np.zeros(T, dtype=np.float64) * self.dRdFp = np.zeros(T, dtype=np.float64) # <<<<<<<<<<<<<< * self.dFpdw = np.zeros(M+2, dtype=np.float64) * self.dFdw = np.zeros(M+2, dtype=np.float64) */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_T); __Pyx_GIVEREF(__pyx_v_T); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_T); __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->dRdFp); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdFp)); __pyx_v_self->dRdFp = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":89 * self.dRdF = np.zeros(T, dtype=np.float64) * self.dRdFp = np.zeros(T, dtype=np.float64) * self.dFpdw = np.zeros(M+2, dtype=np.float64) # <<<<<<<<<<<<<< * self.dFdw = np.zeros(M+2, dtype=np.float64) * self.dSdw = np.zeros(M+2, dtype=np.float64) */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __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 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->dFpdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFpdw)); __pyx_v_self->dFpdw = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":90 * self.dRdFp = np.zeros(T, dtype=np.float64) * self.dFpdw = np.zeros(M+2, dtype=np.float64) * self.dFdw = np.zeros(M+2, dtype=np.float64) # <<<<<<<<<<<<<< * self.dSdw = np.zeros(M+2, dtype=np.float64) * */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_6); __Pyx_GOTREF(__pyx_v_self->dFdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFdw)); __pyx_v_self->dFdw = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; /* "tradingrrl.pyx":91 * self.dFpdw = np.zeros(M+2, dtype=np.float64) * self.dFdw = np.zeros(M+2, dtype=np.float64) * self.dSdw = np.zeros(M+2, dtype=np.float64) # <<<<<<<<<<<<<< * * def load_csv(self, fname): */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_M, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_7); __Pyx_GOTREF(__pyx_v_self->dSdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dSdw)); __pyx_v_self->dSdw = ((PyArrayObject *)__pyx_t_7); __pyx_t_7 = 0; /* "tradingrrl.pyx":56 * cdef public np.ndarray dSdw * * def __init__(self, T=1000, M=200, init_t=10000, mu=10000, sigma=0.04, rho=1.0, n_epoch=10000): # <<<<<<<<<<<<<< * self.T = T * self.M = M */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __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_AddTraceback("tradingrrl.TradingRRL.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":93 * self.dSdw = np.zeros(M+2, dtype=np.float64) * * def load_csv(self, fname): # <<<<<<<<<<<<<< * tmp = pd.read_csv(fname, header=None) * tmp_tstr = tmp[0] +" " + tmp[1] */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_3load_csv(PyObject *__pyx_v_self, PyObject *__pyx_v_fname); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_3load_csv(PyObject *__pyx_v_self, PyObject *__pyx_v_fname) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("load_csv (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_2load_csv(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_fname)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_2load_csv(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_fname) { PyObject *__pyx_v_tmp = NULL; PyObject *__pyx_v_tmp_tstr = NULL; PyObject *__pyx_v_tmp_t = NULL; PyObject *__pyx_v_tmp_p = NULL; Py_ssize_t __pyx_v_i; 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; Py_ssize_t __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("load_csv", 0); /* "tradingrrl.pyx":94 * * def load_csv(self, fname): * tmp = pd.read_csv(fname, header=None) # <<<<<<<<<<<<<< * tmp_tstr = tmp[0] +" " + tmp[1] * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_read_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_fname); __Pyx_GIVEREF(__pyx_v_fname); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fname); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_header, Py_None) < 0) __PYX_ERR(0, 94, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_tmp = __pyx_t_4; __pyx_t_4 = 0; /* "tradingrrl.pyx":95 * def load_csv(self, fname): * tmp = pd.read_csv(fname, header=None) * tmp_tstr = tmp[0] +" " + tmp[1] # <<<<<<<<<<<<<< * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] * tmp_p = list(tmp[5]) */ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_tmp, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_tmp, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_tmp_tstr = __pyx_t_1; __pyx_t_1 = 0; /* "tradingrrl.pyx":96 * tmp = pd.read_csv(fname, header=None) * tmp_tstr = tmp[0] +" " + tmp[1] * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] # <<<<<<<<<<<<<< * tmp_p = list(tmp[5]) * self.all_t = np.array(tmp_t[::-1]) */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_Length(__pyx_v_tmp_tstr); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 96, __pyx_L1_error) for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_dt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strptime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_tmp_tstr, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_kp_s_Y_m_d_H_M}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_kp_s_Y_m_d_H_M}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 96, __pyx_L1_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_3); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3); __Pyx_INCREF(__pyx_kp_s_Y_m_d_H_M); __Pyx_GIVEREF(__pyx_kp_s_Y_m_d_H_M); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_kp_s_Y_m_d_H_M); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_tmp_t = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":97 * tmp_tstr = tmp[0] +" " + tmp[1] * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] * tmp_p = list(tmp[5]) # <<<<<<<<<<<<<< * self.all_t = np.array(tmp_t[::-1]) * self.all_p = np.array(tmp_p[::-1]) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_tmp, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_tmp_p = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":98 * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] * tmp_p = list(tmp[5]) * self.all_t = np.array(tmp_t[::-1]) # <<<<<<<<<<<<<< * self.all_p = np.array(tmp_p[::-1]) * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_v_tmp_t, __pyx_slice__3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_9) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_1}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_2)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_1}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->all_t); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_t)); __pyx_v_self->all_t = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":99 * tmp_p = list(tmp[5]) * self.all_t = np.array(tmp_t[::-1]) * self.all_p = np.array(tmp_p[::-1]) # <<<<<<<<<<<<<< * * def quant(self, f): */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_v_tmp_p, __pyx_slice__4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_1) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->all_p); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_p)); __pyx_v_self->all_p = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":93 * self.dSdw = np.zeros(M+2, dtype=np.float64) * * def load_csv(self, fname): # <<<<<<<<<<<<<< * tmp = pd.read_csv(fname, header=None) * tmp_tstr = tmp[0] +" " + tmp[1] */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("tradingrrl.TradingRRL.load_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tmp); __Pyx_XDECREF(__pyx_v_tmp_tstr); __Pyx_XDECREF(__pyx_v_tmp_t); __Pyx_XDECREF(__pyx_v_tmp_p); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":101 * self.all_p = np.array(tmp_p[::-1]) * * def quant(self, f): # <<<<<<<<<<<<<< * fc = f.copy() * fc[np.where(np.abs(fc) < self.q_threshold)] = 0 */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5quant(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5quant(PyObject *__pyx_v_self, PyObject *__pyx_v_f) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("quant (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4quant(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_f)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4quant(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_f) { PyObject *__pyx_v_fc = 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; __Pyx_RefNannySetupContext("quant", 0); /* "tradingrrl.pyx":102 * * def quant(self, f): * fc = f.copy() # <<<<<<<<<<<<<< * fc[np.where(np.abs(fc) < self.q_threshold)] = 0 * return np.sign(fc) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_fc = __pyx_t_1; __pyx_t_1 = 0; /* "tradingrrl.pyx":103 * def quant(self, f): * fc = f.copy() * fc[np.where(np.abs(fc) < self.q_threshold)] = 0 # <<<<<<<<<<<<<< * return np.sign(fc) * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_where); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_abs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_fc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_fc}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_fc}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_fc); __Pyx_GIVEREF(__pyx_v_fc); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_fc); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->q_threshold); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_3)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(PyObject_SetItem(__pyx_v_fc, __pyx_t_1, __pyx_int_0) < 0)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":104 * fc = f.copy() * fc[np.where(np.abs(fc) < self.q_threshold)] = 0 * return np.sign(fc) # <<<<<<<<<<<<<< * * def set_t_p_r(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sign); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_fc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_fc}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_fc}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_fc); __Pyx_GIVEREF(__pyx_v_fc); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_fc); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "tradingrrl.pyx":101 * self.all_p = np.array(tmp_p[::-1]) * * def quant(self, f): # <<<<<<<<<<<<<< * fc = f.copy() * fc[np.where(np.abs(fc) < self.q_threshold)] = 0 */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("tradingrrl.TradingRRL.quant", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fc); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":106 * return np.sign(fc) * * def set_t_p_r(self): # <<<<<<<<<<<<<< * self.t = self.all_t[self.init_t:self.init_t+self.T+self.M+1] * self.p = self.all_p[self.init_t:self.init_t+self.T+self.M+1] */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7set_t_p_r(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7set_t_p_r(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_t_p_r (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_6set_t_p_r(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_6set_t_p_r(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { 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; __Pyx_RefNannySetupContext("set_t_p_r", 0); /* "tradingrrl.pyx":107 * * def set_t_p_r(self): * self.t = self.all_t[self.init_t:self.init_t+self.T+self.M+1] # <<<<<<<<<<<<<< * self.p = self.all_p[self.init_t:self.init_t+self.T+self.M+1] * self.r = -np.diff(self.p) */ __pyx_t_1 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->all_t), __pyx_v_self->init_t, (((__pyx_v_self->init_t + __pyx_v_self->T) + __pyx_v_self->M) + 1), NULL, NULL, NULL, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->t); __Pyx_DECREF(((PyObject *)__pyx_v_self->t)); __pyx_v_self->t = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":108 * def set_t_p_r(self): * self.t = self.all_t[self.init_t:self.init_t+self.T+self.M+1] * self.p = self.all_p[self.init_t:self.init_t+self.T+self.M+1] # <<<<<<<<<<<<<< * self.r = -np.diff(self.p) * */ __pyx_t_1 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->all_p), __pyx_v_self->init_t, (((__pyx_v_self->init_t + __pyx_v_self->T) + __pyx_v_self->M) + 1), NULL, NULL, NULL, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->p); __Pyx_DECREF(((PyObject *)__pyx_v_self->p)); __pyx_v_self->p = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":109 * self.t = self.all_t[self.init_t:self.init_t+self.T+self.M+1] * self.p = self.all_p[self.init_t:self.init_t+self.T+self.M+1] * self.r = -np.diff(self.p) # <<<<<<<<<<<<<< * * def set_x_F(self): */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_diff); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __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); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->p)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_self->p)}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_self->p)}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_self->p)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->p)); PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self->p)); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->r); __Pyx_DECREF(((PyObject *)__pyx_v_self->r)); __pyx_v_self->r = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":106 * return np.sign(fc) * * def set_t_p_r(self): # <<<<<<<<<<<<<< * self.t = self.all_t[self.init_t:self.init_t+self.T+self.M+1] * self.p = self.all_p[self.init_t:self.init_t+self.T+self.M+1] */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("tradingrrl.TradingRRL.set_t_p_r", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":111 * self.r = -np.diff(self.p) * * def set_x_F(self): # <<<<<<<<<<<<<< * cdef int i * cdef int j */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_9set_x_F(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_9set_x_F(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_x_F (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_8set_x_F(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_8set_x_F(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_v_i; int __pyx_v_j; PyArrayObject *__pyx_v_xt = 0; PyArrayObject *__pyx_v_x = 0; PyArrayObject *__pyx_v_r = 0; PyArrayObject *__pyx_v_F = 0; PyArrayObject *__pyx_v_w = 0; __Pyx_LocalBuf_ND __pyx_pybuffernd_F; __Pyx_Buffer __pyx_pybuffer_F; __Pyx_LocalBuf_ND __pyx_pybuffernd_r; __Pyx_Buffer __pyx_pybuffer_r; __Pyx_LocalBuf_ND __pyx_pybuffernd_w; __Pyx_Buffer __pyx_pybuffer_w; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; __Pyx_LocalBuf_ND __pyx_pybuffernd_xt; __Pyx_Buffer __pyx_pybuffer_xt; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; 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; PyObject *__pyx_t_9 = NULL; PyArrayObject *__pyx_t_10 = NULL; int __pyx_t_11; Py_ssize_t __pyx_t_12; Py_ssize_t __pyx_t_13; Py_ssize_t __pyx_t_14; long __pyx_t_15; Py_ssize_t __pyx_t_16; Py_ssize_t __pyx_t_17; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; __pyx_t_10tradingrrl_DOUBLE_t __pyx_t_20; Py_ssize_t __pyx_t_21; __Pyx_RefNannySetupContext("set_x_F", 0); __pyx_pybuffer_xt.pybuffer.buf = NULL; __pyx_pybuffer_xt.refcount = 0; __pyx_pybuffernd_xt.data = NULL; __pyx_pybuffernd_xt.rcbuffer = &__pyx_pybuffer_xt; __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; __pyx_pybuffer_r.pybuffer.buf = NULL; __pyx_pybuffer_r.refcount = 0; __pyx_pybuffernd_r.data = NULL; __pyx_pybuffernd_r.rcbuffer = &__pyx_pybuffer_r; __pyx_pybuffer_F.pybuffer.buf = NULL; __pyx_pybuffer_F.refcount = 0; __pyx_pybuffernd_F.data = NULL; __pyx_pybuffernd_F.rcbuffer = &__pyx_pybuffer_F; __pyx_pybuffer_w.pybuffer.buf = NULL; __pyx_pybuffer_w.refcount = 0; __pyx_pybuffernd_w.data = NULL; __pyx_pybuffernd_w.rcbuffer = &__pyx_pybuffer_w; /* "tradingrrl.pyx":119 * cdef np.ndarray[DOUBLE_t, ndim=1, mode="c"] F * cdef np.ndarray[DOUBLE_t, ndim=1, mode="c"] w * x = self.x # <<<<<<<<<<<<<< * r = self.r * F = self.F */ __pyx_t_1 = ((PyObject *)__pyx_v_self->x); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5); } } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 119, __pyx_L1_error) } __pyx_v_x = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":120 * cdef np.ndarray[DOUBLE_t, ndim=1, mode="c"] w * x = self.x * r = self.r # <<<<<<<<<<<<<< * F = self.F * w = self.w */ __pyx_t_1 = ((PyObject *)__pyx_v_self->r); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_r.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_r, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3); } } __pyx_pybuffernd_r.diminfo[0].strides = __pyx_pybuffernd_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_r.diminfo[0].shape = __pyx_pybuffernd_r.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) } __pyx_v_r = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":121 * x = self.x * r = self.r * F = self.F # <<<<<<<<<<<<<< * w = self.w * for i in xrange(self.T-1, -1, -1): */ __pyx_t_1 = ((PyObject *)__pyx_v_self->F); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_F.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_F.rcbuffer->pybuffer, (PyObject*)__pyx_v_F, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5); } } __pyx_pybuffernd_F.diminfo[0].strides = __pyx_pybuffernd_F.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_F.diminfo[0].shape = __pyx_pybuffernd_F.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 121, __pyx_L1_error) } __pyx_v_F = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":122 * r = self.r * F = self.F * w = self.w # <<<<<<<<<<<<<< * for i in xrange(self.T-1, -1, -1): * """ */ __pyx_t_1 = ((PyObject *)__pyx_v_self->w); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_2 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w.rcbuffer->pybuffer, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_3); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_4, __pyx_t_3); } } __pyx_pybuffernd_w.diminfo[0].strides = __pyx_pybuffernd_w.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w.diminfo[0].shape = __pyx_pybuffernd_w.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) } __pyx_v_w = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":123 * F = self.F * w = self.w * for i in xrange(self.T-1, -1, -1): # <<<<<<<<<<<<<< * """ * x[i] = np.zeros(self.M+2, dtype=np.float64) */ for (__pyx_t_2 = (__pyx_v_self->T - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) { __pyx_v_i = __pyx_t_2; /* "tradingrrl.pyx":131 * x[i][j] = r[i+j-1] * """ * xt = np.zeros(self.M+2, dtype=np.float64) # <<<<<<<<<<<<<< * xt[0] = 1.0 * xt[self.M+2-1] = F[i+1] */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_self->M + 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_float64); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 131, __pyx_L1_error) __pyx_t_10 = ((PyArrayObject *)__pyx_t_9); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_xt.rcbuffer->pybuffer); __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_xt.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack); if (unlikely(__pyx_t_11 < 0)) { PyErr_Fetch(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_xt.rcbuffer->pybuffer, (PyObject*)__pyx_v_xt, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_3); Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_3, __pyx_t_4, __pyx_t_5); } } __pyx_pybuffernd_xt.diminfo[0].strides = __pyx_pybuffernd_xt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_xt.diminfo[0].shape = __pyx_pybuffernd_xt.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 131, __pyx_L1_error) } __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_xt, ((PyArrayObject *)__pyx_t_9)); __pyx_t_9 = 0; /* "tradingrrl.pyx":132 * """ * xt = np.zeros(self.M+2, dtype=np.float64) * xt[0] = 1.0 # <<<<<<<<<<<<<< * xt[self.M+2-1] = F[i+1] * for j in xrange(1, self.M+2-1, 1): */ __pyx_t_12 = 0; *__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_xt.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_xt.diminfo[0].strides) = 1.0; /* "tradingrrl.pyx":133 * xt = np.zeros(self.M+2, dtype=np.float64) * xt[0] = 1.0 * xt[self.M+2-1] = F[i+1] # <<<<<<<<<<<<<< * for j in xrange(1, self.M+2-1, 1): * xt[j] = r[i+j-1] */ __pyx_t_13 = (__pyx_v_i + 1); __pyx_t_14 = ((__pyx_v_self->M + 2) - 1); *__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_xt.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_xt.diminfo[0].strides) = (*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_F.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_F.diminfo[0].strides)); /* "tradingrrl.pyx":134 * xt[0] = 1.0 * xt[self.M+2-1] = F[i+1] * for j in xrange(1, self.M+2-1, 1): # <<<<<<<<<<<<<< * xt[j] = r[i+j-1] * x[i] = xt */ __pyx_t_15 = ((__pyx_v_self->M + 2) - 1); for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_15; __pyx_t_11+=1) { __pyx_v_j = __pyx_t_11; /* "tradingrrl.pyx":135 * xt[self.M+2-1] = F[i+1] * for j in xrange(1, self.M+2-1, 1): * xt[j] = r[i+j-1] # <<<<<<<<<<<<<< * x[i] = xt * F[i] = np.tanh(np.dot(w, x[i])) */ __pyx_t_16 = ((__pyx_v_i + __pyx_v_j) - 1); __pyx_t_17 = __pyx_v_j; *__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_xt.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_xt.diminfo[0].strides) = (*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_r.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_r.diminfo[0].strides)); } /* "tradingrrl.pyx":136 * for j in xrange(1, self.M+2-1, 1): * xt[j] = r[i+j-1] * x[i] = xt # <<<<<<<<<<<<<< * F[i] = np.tanh(np.dot(w, x[i])) * */ if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_x), __pyx_v_i, ((PyObject *)__pyx_v_xt), int, 1, __Pyx_PyInt_From_int, 0, 0, 0) < 0)) __PYX_ERR(0, 136, __pyx_L1_error) /* "tradingrrl.pyx":137 * xt[j] = r[i+j-1] * x[i] = xt * F[i] = np.tanh(np.dot(w, x[i])) # <<<<<<<<<<<<<< * * self.x = x */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tanh); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dot); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_x), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_18 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_18)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_18, ((PyObject *)__pyx_v_w), __pyx_t_6}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 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_8)) { PyObject *__pyx_temp[3] = {__pyx_t_18, ((PyObject *)__pyx_v_w), __pyx_t_6}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_19 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); if (__pyx_t_18) { __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_18); __pyx_t_18 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_w)); __Pyx_GIVEREF(((PyObject *)__pyx_v_w)); PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_11, ((PyObject *)__pyx_v_w)); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_11, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(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); } } if (!__pyx_t_8) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_19, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_20 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_20 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_21 = __pyx_v_i; *__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_F.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_F.diminfo[0].strides) = __pyx_t_20; } /* "tradingrrl.pyx":139 * F[i] = np.tanh(np.dot(w, x[i])) * * self.x = x # <<<<<<<<<<<<<< * self.F = F * */ __Pyx_INCREF(((PyObject *)__pyx_v_x)); __Pyx_GIVEREF(((PyObject *)__pyx_v_x)); __Pyx_GOTREF(__pyx_v_self->x); __Pyx_DECREF(((PyObject *)__pyx_v_self->x)); __pyx_v_self->x = ((PyArrayObject *)__pyx_v_x); /* "tradingrrl.pyx":140 * * self.x = x * self.F = F # <<<<<<<<<<<<<< * * def calc_R(self): */ __Pyx_INCREF(((PyObject *)__pyx_v_F)); __Pyx_GIVEREF(((PyObject *)__pyx_v_F)); __Pyx_GOTREF(__pyx_v_self->F); __Pyx_DECREF(((PyObject *)__pyx_v_self->F)); __pyx_v_self->F = ((PyArrayObject *)__pyx_v_F); /* "tradingrrl.pyx":111 * self.r = -np.diff(self.p) * * def set_x_F(self): # <<<<<<<<<<<<<< * cdef int i * cdef int j */ /* 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_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_xt.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("tradingrrl.TradingRRL.set_x_F", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_xt.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_xt); __Pyx_XDECREF((PyObject *)__pyx_v_x); __Pyx_XDECREF((PyObject *)__pyx_v_r); __Pyx_XDECREF((PyObject *)__pyx_v_F); __Pyx_XDECREF((PyObject *)__pyx_v_w); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":142 * self.F = F * * def calc_R(self): # <<<<<<<<<<<<<< * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) * */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_11calc_R(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_11calc_R(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("calc_R (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_10calc_R(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_10calc_R(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { 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; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("calc_R", 0); /* "tradingrrl.pyx":143 * * def calc_R(self): * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) # <<<<<<<<<<<<<< * * def calc_sumR(self): */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->F), 1, 0, NULL, NULL, &__pyx_slice__5, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->r), 0, __pyx_v_self->T, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __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_t_3 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_abs); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_diff); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_7) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_self->F)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_7, ((PyObject *)__pyx_v_self->F)}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_7, ((PyObject *)__pyx_v_self->F)}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 143, __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 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_self->F)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->F)); PyTuple_SET_ITEM(__pyx_t_9, 0+1, ((PyObject *)__pyx_v_self->F)); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyNumber_Negative(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(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); } } if (!__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_8}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_8}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_6); __Pyx_GOTREF(__pyx_v_self->R); __Pyx_DECREF(((PyObject *)__pyx_v_self->R)); __pyx_v_self->R = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; /* "tradingrrl.pyx":142 * self.F = F * * def calc_R(self): # <<<<<<<<<<<<<< * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) * */ /* 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_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_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("tradingrrl.TradingRRL.calc_R", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":145 * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) * * def calc_sumR(self): # <<<<<<<<<<<<<< * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_13calc_sumR(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_13calc_sumR(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("calc_sumR (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_12calc_sumR(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_12calc_sumR(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { 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; __Pyx_RefNannySetupContext("calc_sumR", 0); /* "tradingrrl.pyx":146 * * def calc_sumR(self): * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') # <<<<<<<<<<<<<< * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cumsum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->R), __pyx_slice__6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __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 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_slice__7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(0, 146, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_5); __Pyx_GOTREF(__pyx_v_self->sumR); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR)); __pyx_v_self->sumR = ((PyArrayObject *)__pyx_t_5); __pyx_t_5 = 0; /* "tradingrrl.pyx":147 * def calc_sumR(self): * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') # <<<<<<<<<<<<<< * * def calc_dSdw(self): */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cumsum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Power(((PyObject *)__pyx_v_self->R), __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_GetItem(__pyx_t_3, __pyx_slice__8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (!__pyx_t_3) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_t_5, __pyx_slice__9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(0, 147, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->sumR2); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_v_self->sumR2 = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":145 * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) * * def calc_sumR(self): # <<<<<<<<<<<<<< * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("tradingrrl.TradingRRL.calc_sumR", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":149 * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') * * def calc_dSdw(self): # <<<<<<<<<<<<<< * cdef int i * cdef np.ndarray[DOUBLE_t, ndim=2, mode="c"] x */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_15calc_dSdw(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_15calc_dSdw(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("calc_dSdw (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_14calc_dSdw(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_14calc_dSdw(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_v_i; PyArrayObject *__pyx_v_x = 0; PyArrayObject *__pyx_v_r = 0; PyArrayObject *__pyx_v_F = 0; PyArrayObject *__pyx_v_R = 0; PyArrayObject *__pyx_v_w = 0; PyArrayObject *__pyx_v_sumR = 0; PyArrayObject *__pyx_v_sumR2 = 0; double __pyx_v_A; double __pyx_v_B; double __pyx_v_S; double __pyx_v_dSdA; double __pyx_v_dSdB; double __pyx_v_dAdR; PyArrayObject *__pyx_v_dBdR = 0; PyArrayObject *__pyx_v_dRdF = 0; PyArrayObject *__pyx_v_dRdFp = 0; PyArrayObject *__pyx_v_dFpdw = 0; PyArrayObject *__pyx_v_dFdw = 0; PyArrayObject *__pyx_v_dSdw = 0; __Pyx_LocalBuf_ND __pyx_pybuffernd_F; __Pyx_Buffer __pyx_pybuffer_F; __Pyx_LocalBuf_ND __pyx_pybuffernd_R; __Pyx_Buffer __pyx_pybuffer_R; __Pyx_LocalBuf_ND __pyx_pybuffernd_dBdR; __Pyx_Buffer __pyx_pybuffer_dBdR; __Pyx_LocalBuf_ND __pyx_pybuffernd_dFdw; __Pyx_Buffer __pyx_pybuffer_dFdw; __Pyx_LocalBuf_ND __pyx_pybuffernd_dFpdw; __Pyx_Buffer __pyx_pybuffer_dFpdw; __Pyx_LocalBuf_ND __pyx_pybuffernd_dRdF; __Pyx_Buffer __pyx_pybuffer_dRdF; __Pyx_LocalBuf_ND __pyx_pybuffernd_dRdFp; __Pyx_Buffer __pyx_pybuffer_dRdFp; __Pyx_LocalBuf_ND __pyx_pybuffernd_dSdw; __Pyx_Buffer __pyx_pybuffer_dSdw; __Pyx_LocalBuf_ND __pyx_pybuffernd_r; __Pyx_Buffer __pyx_pybuffer_r; __Pyx_LocalBuf_ND __pyx_pybuffernd_sumR; __Pyx_Buffer __pyx_pybuffer_sumR; __Pyx_LocalBuf_ND __pyx_pybuffernd_sumR2; __Pyx_Buffer __pyx_pybuffer_sumR2; __Pyx_LocalBuf_ND __pyx_pybuffernd_w; __Pyx_Buffer __pyx_pybuffer_w; __Pyx_LocalBuf_ND __pyx_pybuffernd_x; __Pyx_Buffer __pyx_pybuffer_x; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; Py_ssize_t __pyx_t_8; __pyx_t_10tradingrrl_DOUBLE_t __pyx_t_9; Py_ssize_t __pyx_t_10; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; double __pyx_t_14; double __pyx_t_15; PyArrayObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyArrayObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyArrayObject *__pyx_t_20 = NULL; PyArrayObject *__pyx_t_21 = NULL; PyArrayObject *__pyx_t_22 = NULL; PyArrayObject *__pyx_t_23 = NULL; int __pyx_t_24; int __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; __Pyx_RefNannySetupContext("calc_dSdw", 0); __pyx_pybuffer_x.pybuffer.buf = NULL; __pyx_pybuffer_x.refcount = 0; __pyx_pybuffernd_x.data = NULL; __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x; __pyx_pybuffer_r.pybuffer.buf = NULL; __pyx_pybuffer_r.refcount = 0; __pyx_pybuffernd_r.data = NULL; __pyx_pybuffernd_r.rcbuffer = &__pyx_pybuffer_r; __pyx_pybuffer_F.pybuffer.buf = NULL; __pyx_pybuffer_F.refcount = 0; __pyx_pybuffernd_F.data = NULL; __pyx_pybuffernd_F.rcbuffer = &__pyx_pybuffer_F; __pyx_pybuffer_R.pybuffer.buf = NULL; __pyx_pybuffer_R.refcount = 0; __pyx_pybuffernd_R.data = NULL; __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R; __pyx_pybuffer_w.pybuffer.buf = NULL; __pyx_pybuffer_w.refcount = 0; __pyx_pybuffernd_w.data = NULL; __pyx_pybuffernd_w.rcbuffer = &__pyx_pybuffer_w; __pyx_pybuffer_sumR.pybuffer.buf = NULL; __pyx_pybuffer_sumR.refcount = 0; __pyx_pybuffernd_sumR.data = NULL; __pyx_pybuffernd_sumR.rcbuffer = &__pyx_pybuffer_sumR; __pyx_pybuffer_sumR2.pybuffer.buf = NULL; __pyx_pybuffer_sumR2.refcount = 0; __pyx_pybuffernd_sumR2.data = NULL; __pyx_pybuffernd_sumR2.rcbuffer = &__pyx_pybuffer_sumR2; __pyx_pybuffer_dBdR.pybuffer.buf = NULL; __pyx_pybuffer_dBdR.refcount = 0; __pyx_pybuffernd_dBdR.data = NULL; __pyx_pybuffernd_dBdR.rcbuffer = &__pyx_pybuffer_dBdR; __pyx_pybuffer_dRdF.pybuffer.buf = NULL; __pyx_pybuffer_dRdF.refcount = 0; __pyx_pybuffernd_dRdF.data = NULL; __pyx_pybuffernd_dRdF.rcbuffer = &__pyx_pybuffer_dRdF; __pyx_pybuffer_dRdFp.pybuffer.buf = NULL; __pyx_pybuffer_dRdFp.refcount = 0; __pyx_pybuffernd_dRdFp.data = NULL; __pyx_pybuffernd_dRdFp.rcbuffer = &__pyx_pybuffer_dRdFp; __pyx_pybuffer_dFpdw.pybuffer.buf = NULL; __pyx_pybuffer_dFpdw.refcount = 0; __pyx_pybuffernd_dFpdw.data = NULL; __pyx_pybuffernd_dFpdw.rcbuffer = &__pyx_pybuffer_dFpdw; __pyx_pybuffer_dFdw.pybuffer.buf = NULL; __pyx_pybuffer_dFdw.refcount = 0; __pyx_pybuffernd_dFdw.data = NULL; __pyx_pybuffernd_dFdw.rcbuffer = &__pyx_pybuffer_dFdw; __pyx_pybuffer_dSdw.pybuffer.buf = NULL; __pyx_pybuffer_dSdw.refcount = 0; __pyx_pybuffernd_dSdw.data = NULL; __pyx_pybuffernd_dSdw.rcbuffer = &__pyx_pybuffer_dSdw; /* "tradingrrl.pyx":171 * cdef np.ndarray[DOUBLE_t, ndim=1, mode="c"] dSdw * * self.set_x_F() # <<<<<<<<<<<<<< * self.calc_R() * self.calc_sumR() */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_x_F); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":172 * * self.set_x_F() * self.calc_R() # <<<<<<<<<<<<<< * self.calc_sumR() * x = self.x */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calc_R); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":173 * self.set_x_F() * self.calc_R() * self.calc_sumR() # <<<<<<<<<<<<<< * x = self.x * r = self.r */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calc_sumR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":174 * self.calc_R() * self.calc_sumR() * x = self.x # <<<<<<<<<<<<<< * r = self.r * F = self.F */ __pyx_t_1 = ((PyObject *)__pyx_v_self->x); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_x.diminfo[1].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_x.diminfo[1].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[1]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 174, __pyx_L1_error) } __pyx_v_x = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":175 * self.calc_sumR() * x = self.x * r = self.r # <<<<<<<<<<<<<< * F = self.F * R = self.R */ __pyx_t_1 = ((PyObject *)__pyx_v_self->r); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_r.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_r.rcbuffer->pybuffer, (PyObject*)__pyx_v_r, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_r.diminfo[0].strides = __pyx_pybuffernd_r.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_r.diminfo[0].shape = __pyx_pybuffernd_r.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 175, __pyx_L1_error) } __pyx_v_r = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":176 * x = self.x * r = self.r * F = self.F # <<<<<<<<<<<<<< * R = self.R * w = self.w */ __pyx_t_1 = ((PyObject *)__pyx_v_self->F); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_F.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_F.rcbuffer->pybuffer, (PyObject*)__pyx_v_F, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_F.diminfo[0].strides = __pyx_pybuffernd_F.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_F.diminfo[0].shape = __pyx_pybuffernd_F.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 176, __pyx_L1_error) } __pyx_v_F = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":177 * r = self.r * F = self.F * R = self.R # <<<<<<<<<<<<<< * w = self.w * sumR = self.sumR */ __pyx_t_1 = ((PyObject *)__pyx_v_self->R); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_v_R, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 177, __pyx_L1_error) } __pyx_v_R = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":178 * F = self.F * R = self.R * w = self.w # <<<<<<<<<<<<<< * sumR = self.sumR * sumR2 = self.sumR2 */ __pyx_t_1 = ((PyObject *)__pyx_v_self->w); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_w.rcbuffer->pybuffer, (PyObject*)__pyx_v_w, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_w.diminfo[0].strides = __pyx_pybuffernd_w.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_w.diminfo[0].shape = __pyx_pybuffernd_w.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 178, __pyx_L1_error) } __pyx_v_w = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":179 * R = self.R * w = self.w * sumR = self.sumR # <<<<<<<<<<<<<< * sumR2 = self.sumR2 * */ __pyx_t_1 = ((PyObject *)__pyx_v_self->sumR); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumR.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumR.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumR, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_sumR.diminfo[0].strides = __pyx_pybuffernd_sumR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumR.diminfo[0].shape = __pyx_pybuffernd_sumR.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 179, __pyx_L1_error) } __pyx_v_sumR = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":180 * w = self.w * sumR = self.sumR * sumR2 = self.sumR2 # <<<<<<<<<<<<<< * * A = sumR[0]/self.T */ __pyx_t_1 = ((PyObject *)__pyx_v_self->sumR2); __Pyx_INCREF(__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR2.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumR2.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumR2.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumR2, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_sumR2.diminfo[0].strides = __pyx_pybuffernd_sumR2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumR2.diminfo[0].shape = __pyx_pybuffernd_sumR2.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 180, __pyx_L1_error) } __pyx_v_sumR2 = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":182 * sumR2 = self.sumR2 * * A = sumR[0]/self.T # <<<<<<<<<<<<<< * B = sumR2[0]/self.T * S = A/np.sqrt(B-A**2) */ __pyx_t_8 = 0; __pyx_t_9 = (*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_sumR.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_sumR.diminfo[0].strides)); if (unlikely(__pyx_v_self->T == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 182, __pyx_L1_error) } __pyx_v_A = (__pyx_t_9 / __pyx_v_self->T); /* "tradingrrl.pyx":183 * * A = sumR[0]/self.T * B = sumR2[0]/self.T # <<<<<<<<<<<<<< * S = A/np.sqrt(B-A**2) * dSdA = S * (1 + S**2) / A */ __pyx_t_10 = 0; __pyx_t_9 = (*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_sumR2.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_sumR2.diminfo[0].strides)); if (unlikely(__pyx_v_self->T == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 183, __pyx_L1_error) } __pyx_v_B = (__pyx_t_9 / __pyx_v_self->T); /* "tradingrrl.pyx":184 * A = sumR[0]/self.T * B = sumR2[0]/self.T * S = A/np.sqrt(B-A**2) # <<<<<<<<<<<<<< * dSdA = S * (1 + S**2) / A * dSdB = -S**3 / 2 / A**2 */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_A); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyFloat_FromDouble((__pyx_v_B - pow(__pyx_v_A, 2.0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (!__pyx_t_12) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_14 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_S = __pyx_t_14; /* "tradingrrl.pyx":185 * B = sumR2[0]/self.T * S = A/np.sqrt(B-A**2) * dSdA = S * (1 + S**2) / A # <<<<<<<<<<<<<< * dSdB = -S**3 / 2 / A**2 * dAdR = 1.0/self.T */ __pyx_t_14 = (__pyx_v_S * (1.0 + pow(__pyx_v_S, 2.0))); if (unlikely(__pyx_v_A == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 185, __pyx_L1_error) } __pyx_v_dSdA = (__pyx_t_14 / __pyx_v_A); /* "tradingrrl.pyx":186 * S = A/np.sqrt(B-A**2) * dSdA = S * (1 + S**2) / A * dSdB = -S**3 / 2 / A**2 # <<<<<<<<<<<<<< * dAdR = 1.0/self.T * dBdR = 2.0/self.T*R */ __pyx_t_14 = ((-pow(__pyx_v_S, 3.0)) / 2.0); __pyx_t_15 = pow(__pyx_v_A, 2.0); if (unlikely(__pyx_t_15 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 186, __pyx_L1_error) } __pyx_v_dSdB = (__pyx_t_14 / __pyx_t_15); /* "tradingrrl.pyx":187 * dSdA = S * (1 + S**2) / A * dSdB = -S**3 / 2 / A**2 * dAdR = 1.0/self.T # <<<<<<<<<<<<<< * dBdR = 2.0/self.T*R * dRdF = -self.mu*self.sigma*np.sign(-np.diff(F)) */ if (unlikely(__pyx_v_self->T == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 187, __pyx_L1_error) } __pyx_v_dAdR = (1.0 / __pyx_v_self->T); /* "tradingrrl.pyx":188 * dSdB = -S**3 / 2 / A**2 * dAdR = 1.0/self.T * dBdR = 2.0/self.T*R # <<<<<<<<<<<<<< * dRdF = -self.mu*self.sigma*np.sign(-np.diff(F)) * dRdFp = self.mu*r[:self.T] + self.mu*self.sigma*np.sign(-np.diff(F)) */ if (unlikely(__pyx_v_self->T == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 188, __pyx_L1_error) } __pyx_t_11 = PyFloat_FromDouble((2.0 / __pyx_v_self->T)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = PyNumber_Multiply(__pyx_t_11, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 188, __pyx_L1_error) __pyx_t_16 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dBdR.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dBdR.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dBdR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dBdR, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_dBdR.diminfo[0].strides = __pyx_pybuffernd_dBdR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dBdR.diminfo[0].shape = __pyx_pybuffernd_dBdR.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 188, __pyx_L1_error) } __pyx_t_16 = 0; __pyx_v_dBdR = ((PyArrayObject *)__pyx_t_2); __pyx_t_2 = 0; /* "tradingrrl.pyx":189 * dAdR = 1.0/self.T * dBdR = 2.0/self.T*R * dRdF = -self.mu*self.sigma*np.sign(-np.diff(F)) # <<<<<<<<<<<<<< * dRdFp = self.mu*r[:self.T] + self.mu*self.sigma*np.sign(-np.diff(F)) * */ __pyx_t_2 = PyFloat_FromDouble(((-__pyx_v_self->mu) * __pyx_v_self->sigma)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sign); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_diff); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject *)__pyx_v_F)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_F)}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_F)}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_F)); __Pyx_GIVEREF(((PyObject *)__pyx_v_F)); PyTuple_SET_ITEM(__pyx_t_17, 0+1, ((PyObject *)__pyx_v_F)); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } if (!__pyx_t_1) { __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_11); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_12}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_12}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyNumber_Multiply(__pyx_t_2, __pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 189, __pyx_L1_error) __pyx_t_18 = ((PyArrayObject *)__pyx_t_13); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdF.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRdF.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRdF.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRdF, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_dRdF.diminfo[0].strides = __pyx_pybuffernd_dRdF.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRdF.diminfo[0].shape = __pyx_pybuffernd_dRdF.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 189, __pyx_L1_error) } __pyx_t_18 = 0; __pyx_v_dRdF = ((PyArrayObject *)__pyx_t_13); __pyx_t_13 = 0; /* "tradingrrl.pyx":190 * dBdR = 2.0/self.T*R * dRdF = -self.mu*self.sigma*np.sign(-np.diff(F)) * dRdFp = self.mu*r[:self.T] + self.mu*self.sigma*np.sign(-np.diff(F)) # <<<<<<<<<<<<<< * * dFpdw = np.zeros(self.M+2, dtype=np.float64) */ __pyx_t_13 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_11 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_r), 0, __pyx_v_self->T, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = PyNumber_Multiply(__pyx_t_13, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyFloat_FromDouble((__pyx_v_self->mu * __pyx_v_self->sigma)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_sign); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_diff); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_1) { __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_F)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, ((PyObject *)__pyx_v_F)}; __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_17); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, ((PyObject *)__pyx_v_F)}; __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_17); } else #endif { __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_F)); __Pyx_GIVEREF(((PyObject *)__pyx_v_F)); PyTuple_SET_ITEM(__pyx_t_19, 0+1, ((PyObject *)__pyx_v_F)); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_19, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Negative(__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } if (!__pyx_t_17) { __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_13); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_3}; __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_3}; __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_17); __pyx_t_17 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_19, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_Multiply(__pyx_t_11, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyNumber_Add(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 190, __pyx_L1_error) __pyx_t_20 = ((PyArrayObject *)__pyx_t_13); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdFp.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRdFp.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRdFp.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRdFp, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_dRdFp.diminfo[0].strides = __pyx_pybuffernd_dRdFp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRdFp.diminfo[0].shape = __pyx_pybuffernd_dRdFp.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 190, __pyx_L1_error) } __pyx_t_20 = 0; __pyx_v_dRdFp = ((PyArrayObject *)__pyx_t_13); __pyx_t_13 = 0; /* "tradingrrl.pyx":192 * dRdFp = self.mu*r[:self.T] + self.mu*self.sigma*np.sign(-np.diff(F)) * * dFpdw = np.zeros(self.M+2, dtype=np.float64) # <<<<<<<<<<<<<< * dFdw = np.zeros(self.M+2, dtype=np.float64) * dSdw = np.zeros(self.M+2, dtype=np.float64) */ __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_zeros); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyInt_From_long((__pyx_v_self->M + 2)); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_float64); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, __pyx_t_19) < 0) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (!(likely(((__pyx_t_19) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_19, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 192, __pyx_L1_error) __pyx_t_21 = ((PyArrayObject *)__pyx_t_19); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dFpdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_dFpdw.diminfo[0].strides = __pyx_pybuffernd_dFpdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dFpdw.diminfo[0].shape = __pyx_pybuffernd_dFpdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 192, __pyx_L1_error) } __pyx_t_21 = 0; __pyx_v_dFpdw = ((PyArrayObject *)__pyx_t_19); __pyx_t_19 = 0; /* "tradingrrl.pyx":193 * * dFpdw = np.zeros(self.M+2, dtype=np.float64) * dFdw = np.zeros(self.M+2, dtype=np.float64) # <<<<<<<<<<<<<< * dSdw = np.zeros(self.M+2, dtype=np.float64) * for i in xrange(self.T-1, -1, -1): */ __pyx_t_19 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_zeros); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyInt_From_long((__pyx_v_self->M + 2)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = PyDict_New(); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_float64); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_dtype, __pyx_t_11) < 0) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_2, __pyx_t_19); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 193, __pyx_L1_error) __pyx_t_22 = ((PyArrayObject *)__pyx_t_11); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dFdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_dFdw.diminfo[0].strides = __pyx_pybuffernd_dFdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dFdw.diminfo[0].shape = __pyx_pybuffernd_dFdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 193, __pyx_L1_error) } __pyx_t_22 = 0; __pyx_v_dFdw = ((PyArrayObject *)__pyx_t_11); __pyx_t_11 = 0; /* "tradingrrl.pyx":194 * dFpdw = np.zeros(self.M+2, dtype=np.float64) * dFdw = np.zeros(self.M+2, dtype=np.float64) * dSdw = np.zeros(self.M+2, dtype=np.float64) # <<<<<<<<<<<<<< * for i in xrange(self.T-1, -1, -1): * if i!=self.T-1: */ __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_zeros); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyInt_From_long((__pyx_v_self->M + 2)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_float64); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_t_12) < 0) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_2, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 194, __pyx_L1_error) __pyx_t_23 = ((PyArrayObject *)__pyx_t_12); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer); __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_4 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dSdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_dSdw.diminfo[0].strides = __pyx_pybuffernd_dSdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dSdw.diminfo[0].shape = __pyx_pybuffernd_dSdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) } __pyx_t_23 = 0; __pyx_v_dSdw = ((PyArrayObject *)__pyx_t_12); __pyx_t_12 = 0; /* "tradingrrl.pyx":195 * dFdw = np.zeros(self.M+2, dtype=np.float64) * dSdw = np.zeros(self.M+2, dtype=np.float64) * for i in xrange(self.T-1, -1, -1): # <<<<<<<<<<<<<< * if i!=self.T-1: * dFpdw = dFdw.copy() */ for (__pyx_t_4 = (__pyx_v_self->T - 1); __pyx_t_4 > -1L; __pyx_t_4-=1) { __pyx_v_i = __pyx_t_4; /* "tradingrrl.pyx":196 * dSdw = np.zeros(self.M+2, dtype=np.float64) * for i in xrange(self.T-1, -1, -1): * if i!=self.T-1: # <<<<<<<<<<<<<< * dFpdw = dFdw.copy() * dFdw = (1 - F[i]**2)*(x[i] + w[self.M+2-1]*dFpdw) */ __pyx_t_24 = ((__pyx_v_i != (__pyx_v_self->T - 1)) != 0); if (__pyx_t_24) { /* "tradingrrl.pyx":197 * for i in xrange(self.T-1, -1, -1): * if i!=self.T-1: * dFpdw = dFdw.copy() # <<<<<<<<<<<<<< * dFdw = (1 - F[i]**2)*(x[i] + w[self.M+2-1]*dFpdw) * dSdw += (dSdA*dAdR + dSdB*dBdR[i])*(dRdF[i]*dFdw + dRdFp[i]*dFpdw) */ __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dFdw), __pyx_n_s_copy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (__pyx_t_2) { __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 197, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 197, __pyx_L1_error) __pyx_t_21 = ((PyArrayObject *)__pyx_t_12); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer); __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_25 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dFpdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_dFpdw.diminfo[0].strides = __pyx_pybuffernd_dFpdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dFpdw.diminfo[0].shape = __pyx_pybuffernd_dFpdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 197, __pyx_L1_error) } __pyx_t_21 = 0; __Pyx_DECREF_SET(__pyx_v_dFpdw, ((PyArrayObject *)__pyx_t_12)); __pyx_t_12 = 0; /* "tradingrrl.pyx":196 * dSdw = np.zeros(self.M+2, dtype=np.float64) * for i in xrange(self.T-1, -1, -1): * if i!=self.T-1: # <<<<<<<<<<<<<< * dFpdw = dFdw.copy() * dFdw = (1 - F[i]**2)*(x[i] + w[self.M+2-1]*dFpdw) */ } /* "tradingrrl.pyx":198 * if i!=self.T-1: * dFpdw = dFdw.copy() * dFdw = (1 - F[i]**2)*(x[i] + w[self.M+2-1]*dFpdw) # <<<<<<<<<<<<<< * dSdw += (dSdA*dAdR + dSdB*dBdR[i])*(dRdF[i]*dFdw + dRdFp[i]*dFpdw) * */ __pyx_t_26 = __pyx_v_i; __pyx_t_12 = PyFloat_FromDouble((1.0 - pow((*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_F.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_F.diminfo[0].strides)), 2.0))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = __Pyx_GetItemInt(((PyObject *)__pyx_v_x), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_27 = ((__pyx_v_self->M + 2) - 1); __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_w.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_w.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_19 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_dFpdw)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_t_11, __pyx_t_19); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = PyNumber_Multiply(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_19) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_19, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 198, __pyx_L1_error) __pyx_t_22 = ((PyArrayObject *)__pyx_t_19); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer); __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_25 < 0)) { PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dFdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7); } } __pyx_pybuffernd_dFdw.diminfo[0].strides = __pyx_pybuffernd_dFdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dFdw.diminfo[0].shape = __pyx_pybuffernd_dFdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) } __pyx_t_22 = 0; __Pyx_DECREF_SET(__pyx_v_dFdw, ((PyArrayObject *)__pyx_t_19)); __pyx_t_19 = 0; /* "tradingrrl.pyx":199 * dFpdw = dFdw.copy() * dFdw = (1 - F[i]**2)*(x[i] + w[self.M+2-1]*dFpdw) * dSdw += (dSdA*dAdR + dSdB*dBdR[i])*(dRdF[i]*dFdw + dRdFp[i]*dFpdw) # <<<<<<<<<<<<<< * * self.sumR = sumR */ __pyx_t_28 = __pyx_v_i; __pyx_t_19 = PyFloat_FromDouble(((__pyx_v_dSdA * __pyx_v_dAdR) + (__pyx_v_dSdB * (*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_dBdR.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_dBdR.diminfo[0].strides))))); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_29 = __pyx_v_i; __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_dRdF.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_dRdF.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_dFdw)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_30 = __pyx_v_i; __pyx_t_2 = PyFloat_FromDouble((*__Pyx_BufPtrCContig1d(__pyx_t_10tradingrrl_DOUBLE_t *, __pyx_pybuffernd_dRdFp.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_dRdFp.diminfo[0].strides))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = PyNumber_Multiply(__pyx_t_2, ((PyObject *)__pyx_v_dFpdw)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Multiply(__pyx_t_19, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_dSdw), __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_t_23 = ((PyArrayObject *)__pyx_t_2); { __Pyx_BufFmt_StackElem __pyx_stack[1]; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer); __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack); if (unlikely(__pyx_t_25 < 0)) { PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer, (PyObject*)__pyx_v_dSdw, &__Pyx_TypeInfo_nn___pyx_t_10tradingrrl_DOUBLE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) { Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); __Pyx_RaiseBufferFallbackError(); } else { PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5); } } __pyx_pybuffernd_dSdw.diminfo[0].strides = __pyx_pybuffernd_dSdw.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dSdw.diminfo[0].shape = __pyx_pybuffernd_dSdw.rcbuffer->pybuffer.shape[0]; if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 199, __pyx_L1_error) } __pyx_t_23 = 0; __Pyx_DECREF_SET(__pyx_v_dSdw, ((PyArrayObject *)__pyx_t_2)); __pyx_t_2 = 0; } /* "tradingrrl.pyx":201 * dSdw += (dSdA*dAdR + dSdB*dBdR[i])*(dRdF[i]*dFdw + dRdFp[i]*dFpdw) * * self.sumR = sumR # <<<<<<<<<<<<<< * self.sumR2 = sumR2 * self.A = A */ __Pyx_INCREF(((PyObject *)__pyx_v_sumR)); __Pyx_GIVEREF(((PyObject *)__pyx_v_sumR)); __Pyx_GOTREF(__pyx_v_self->sumR); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR)); __pyx_v_self->sumR = ((PyArrayObject *)__pyx_v_sumR); /* "tradingrrl.pyx":202 * * self.sumR = sumR * self.sumR2 = sumR2 # <<<<<<<<<<<<<< * self.A = A * self.B = B */ __Pyx_INCREF(((PyObject *)__pyx_v_sumR2)); __Pyx_GIVEREF(((PyObject *)__pyx_v_sumR2)); __Pyx_GOTREF(__pyx_v_self->sumR2); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_v_self->sumR2 = ((PyArrayObject *)__pyx_v_sumR2); /* "tradingrrl.pyx":203 * self.sumR = sumR * self.sumR2 = sumR2 * self.A = A # <<<<<<<<<<<<<< * self.B = B * self.S = S */ __pyx_v_self->A = __pyx_v_A; /* "tradingrrl.pyx":204 * self.sumR2 = sumR2 * self.A = A * self.B = B # <<<<<<<<<<<<<< * self.S = S * self.dSdA = dSdA */ __pyx_v_self->B = __pyx_v_B; /* "tradingrrl.pyx":205 * self.A = A * self.B = B * self.S = S # <<<<<<<<<<<<<< * self.dSdA = dSdA * self.dSdB = dSdB */ __pyx_v_self->S = __pyx_v_S; /* "tradingrrl.pyx":206 * self.B = B * self.S = S * self.dSdA = dSdA # <<<<<<<<<<<<<< * self.dSdB = dSdB * self.dAdR = dAdR */ __pyx_v_self->dSdA = __pyx_v_dSdA; /* "tradingrrl.pyx":207 * self.S = S * self.dSdA = dSdA * self.dSdB = dSdB # <<<<<<<<<<<<<< * self.dAdR = dAdR * self.dBdR = dBdR */ __pyx_v_self->dSdB = __pyx_v_dSdB; /* "tradingrrl.pyx":208 * self.dSdA = dSdA * self.dSdB = dSdB * self.dAdR = dAdR # <<<<<<<<<<<<<< * self.dBdR = dBdR * self.dRdF = dRdF */ __pyx_v_self->dAdR = __pyx_v_dAdR; /* "tradingrrl.pyx":209 * self.dSdB = dSdB * self.dAdR = dAdR * self.dBdR = dBdR # <<<<<<<<<<<<<< * self.dRdF = dRdF * self.dRdFp = dRdFp */ __Pyx_INCREF(((PyObject *)__pyx_v_dBdR)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dBdR)); __Pyx_GOTREF(__pyx_v_self->dBdR); __Pyx_DECREF(((PyObject *)__pyx_v_self->dBdR)); __pyx_v_self->dBdR = ((PyArrayObject *)__pyx_v_dBdR); /* "tradingrrl.pyx":210 * self.dAdR = dAdR * self.dBdR = dBdR * self.dRdF = dRdF # <<<<<<<<<<<<<< * self.dRdFp = dRdFp * self.dFpdw = dFpdw */ __Pyx_INCREF(((PyObject *)__pyx_v_dRdF)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dRdF)); __Pyx_GOTREF(__pyx_v_self->dRdF); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdF)); __pyx_v_self->dRdF = ((PyArrayObject *)__pyx_v_dRdF); /* "tradingrrl.pyx":211 * self.dBdR = dBdR * self.dRdF = dRdF * self.dRdFp = dRdFp # <<<<<<<<<<<<<< * self.dFpdw = dFpdw * self.dFdw = dFdw */ __Pyx_INCREF(((PyObject *)__pyx_v_dRdFp)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dRdFp)); __Pyx_GOTREF(__pyx_v_self->dRdFp); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdFp)); __pyx_v_self->dRdFp = ((PyArrayObject *)__pyx_v_dRdFp); /* "tradingrrl.pyx":212 * self.dRdF = dRdF * self.dRdFp = dRdFp * self.dFpdw = dFpdw # <<<<<<<<<<<<<< * self.dFdw = dFdw * self.dSdw = dSdw */ __Pyx_INCREF(((PyObject *)__pyx_v_dFpdw)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dFpdw)); __Pyx_GOTREF(__pyx_v_self->dFpdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFpdw)); __pyx_v_self->dFpdw = ((PyArrayObject *)__pyx_v_dFpdw); /* "tradingrrl.pyx":213 * self.dRdFp = dRdFp * self.dFpdw = dFpdw * self.dFdw = dFdw # <<<<<<<<<<<<<< * self.dSdw = dSdw * */ __Pyx_INCREF(((PyObject *)__pyx_v_dFdw)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dFdw)); __Pyx_GOTREF(__pyx_v_self->dFdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFdw)); __pyx_v_self->dFdw = ((PyArrayObject *)__pyx_v_dFdw); /* "tradingrrl.pyx":214 * self.dFpdw = dFpdw * self.dFdw = dFdw * self.dSdw = dSdw # <<<<<<<<<<<<<< * * def update_w(self): */ __Pyx_INCREF(((PyObject *)__pyx_v_dSdw)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dSdw)); __Pyx_GOTREF(__pyx_v_self->dSdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dSdw)); __pyx_v_self->dSdw = ((PyArrayObject *)__pyx_v_dSdw); /* "tradingrrl.pyx":149 * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') * * def calc_dSdw(self): # <<<<<<<<<<<<<< * cdef int i * cdef np.ndarray[DOUBLE_t, ndim=2, mode="c"] x */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_19); { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dBdR.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdF.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdFp.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR2.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} __Pyx_AddTraceback("tradingrrl.TradingRRL.calc_dSdw", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_F.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dBdR.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dFpdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdF.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRdFp.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSdw.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_r.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumR2.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_w.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_x); __Pyx_XDECREF((PyObject *)__pyx_v_r); __Pyx_XDECREF((PyObject *)__pyx_v_F); __Pyx_XDECREF((PyObject *)__pyx_v_R); __Pyx_XDECREF((PyObject *)__pyx_v_w); __Pyx_XDECREF((PyObject *)__pyx_v_sumR); __Pyx_XDECREF((PyObject *)__pyx_v_sumR2); __Pyx_XDECREF((PyObject *)__pyx_v_dBdR); __Pyx_XDECREF((PyObject *)__pyx_v_dRdF); __Pyx_XDECREF((PyObject *)__pyx_v_dRdFp); __Pyx_XDECREF((PyObject *)__pyx_v_dFpdw); __Pyx_XDECREF((PyObject *)__pyx_v_dFdw); __Pyx_XDECREF((PyObject *)__pyx_v_dSdw); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":216 * self.dSdw = dSdw * * def update_w(self): # <<<<<<<<<<<<<< * self.w += self.rho*self.dSdw * */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_17update_w(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_17update_w(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update_w (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_16update_w(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_16update_w(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("update_w", 0); /* "tradingrrl.pyx":217 * * def update_w(self): * self.w += self.rho*self.dSdw # <<<<<<<<<<<<<< * * def fit(self): */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->rho); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, ((PyObject *)__pyx_v_self->dSdw)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->w), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":216 * self.dSdw = dSdw * * def update_w(self): # <<<<<<<<<<<<<< * self.w += self.rho*self.dSdw * */ /* 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_2); __Pyx_AddTraceback("tradingrrl.TradingRRL.update_w", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":219 * self.w += self.rho*self.dSdw * * def fit(self): # <<<<<<<<<<<<<< * cdef double tic * cdef double toc */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_19fit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_19fit(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fit (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_18fit(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_18fit(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { double __pyx_v_tic; double __pyx_v_toc; int __pyx_v_pre_epoch_times; int __pyx_v_e_index; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; double __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; int __pyx_t_10; PyObject *__pyx_t_11 = NULL; __Pyx_RefNannySetupContext("fit", 0); /* "tradingrrl.pyx":225 * cdef int e_index * * pre_epoch_times = len(self.epoch_S) # <<<<<<<<<<<<<< * * self.calc_dSdw() */ __pyx_t_1 = ((PyObject *)__pyx_v_self->epoch_S); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_pre_epoch_times = __pyx_t_2; /* "tradingrrl.pyx":227 * pre_epoch_times = len(self.epoch_S) * * self.calc_dSdw() # <<<<<<<<<<<<<< * print("Epoch loop start. Initial sharp's ratio is " + str(self.S) + ".") * self.S_opt = self.S */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calc_dSdw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":228 * * self.calc_dSdw() * print("Epoch loop start. Initial sharp's ratio is " + str(self.S) + ".") # <<<<<<<<<<<<<< * self.S_opt = self.S * */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->S); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_kp_s_Epoch_loop_start_Initial_sharp_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":229 * self.calc_dSdw() * print("Epoch loop start. Initial sharp's ratio is " + str(self.S) + ".") * self.S_opt = self.S # <<<<<<<<<<<<<< * * tic = time.clock() */ __pyx_t_5 = __pyx_v_self->S; __pyx_v_self->S_opt = __pyx_t_5; /* "tradingrrl.pyx":231 * self.S_opt = self.S * * tic = time.clock() # <<<<<<<<<<<<<< * for e_index in range(self.n_epoch): * self.calc_dSdw() */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_clock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_tic = __pyx_t_5; /* "tradingrrl.pyx":232 * * tic = time.clock() * for e_index in range(self.n_epoch): # <<<<<<<<<<<<<< * self.calc_dSdw() * if self.S > self.S_opt: */ __pyx_t_6 = __pyx_v_self->n_epoch; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_e_index = __pyx_t_7; /* "tradingrrl.pyx":233 * tic = time.clock() * for e_index in range(self.n_epoch): * self.calc_dSdw() # <<<<<<<<<<<<<< * if self.S > self.S_opt: * self.S_opt = self.S */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calc_dSdw); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":234 * for e_index in range(self.n_epoch): * self.calc_dSdw() * if self.S > self.S_opt: # <<<<<<<<<<<<<< * self.S_opt = self.S * self.w_opt = self.w.copy() */ __pyx_t_8 = ((__pyx_v_self->S > __pyx_v_self->S_opt) != 0); if (__pyx_t_8) { /* "tradingrrl.pyx":235 * self.calc_dSdw() * if self.S > self.S_opt: * self.S_opt = self.S # <<<<<<<<<<<<<< * self.w_opt = self.w.copy() * self.epoch_S = np.append(self.epoch_S, self.S) */ __pyx_t_5 = __pyx_v_self->S; __pyx_v_self->S_opt = __pyx_t_5; /* "tradingrrl.pyx":236 * if self.S > self.S_opt: * self.S_opt = self.S * self.w_opt = self.w.copy() # <<<<<<<<<<<<<< * self.epoch_S = np.append(self.epoch_S, self.S) * self.update_w() */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->w), __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->w_opt); __Pyx_DECREF(((PyObject *)__pyx_v_self->w_opt)); __pyx_v_self->w_opt = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":234 * for e_index in range(self.n_epoch): * self.calc_dSdw() * if self.S > self.S_opt: # <<<<<<<<<<<<<< * self.S_opt = self.S * self.w_opt = self.w.copy() */ } /* "tradingrrl.pyx":237 * self.S_opt = self.S * self.w_opt = self.w.copy() * self.epoch_S = np.append(self.epoch_S, self.S) # <<<<<<<<<<<<<< * self.update_w() * if e_index % self.progress_period == self.progress_period-1: */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_append); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->S); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_self->epoch_S), __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_self->epoch_S), __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self->epoch_S)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->epoch_S)); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, ((PyObject *)__pyx_v_self->epoch_S)); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->epoch_S); __Pyx_DECREF(((PyObject *)__pyx_v_self->epoch_S)); __pyx_v_self->epoch_S = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":238 * self.w_opt = self.w.copy() * self.epoch_S = np.append(self.epoch_S, self.S) * self.update_w() # <<<<<<<<<<<<<< * if e_index % self.progress_period == self.progress_period-1: * toc = time.clock() */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_11) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":239 * self.epoch_S = np.append(self.epoch_S, self.S) * self.update_w() * if e_index % self.progress_period == self.progress_period-1: # <<<<<<<<<<<<<< * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") */ if (unlikely(__pyx_v_self->progress_period == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(0, 239, __pyx_L1_error) } __pyx_t_8 = ((__Pyx_mod_int(__pyx_v_e_index, __pyx_v_self->progress_period) == (__pyx_v_self->progress_period - 1)) != 0); if (__pyx_t_8) { /* "tradingrrl.pyx":240 * self.update_w() * if e_index % self.progress_period == self.progress_period-1: * toc = time.clock() # <<<<<<<<<<<<<< * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * toc = time.clock() */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_clock); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_toc = __pyx_t_5; /* "tradingrrl.pyx":241 * if e_index % self.progress_period == self.progress_period-1: * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") # <<<<<<<<<<<<<< * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") */ __pyx_t_1 = __Pyx_PyInt_From_long(((__pyx_v_e_index + __pyx_v_pre_epoch_times) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_kp_s_Epoch, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_11, __pyx_kp_s__11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyInt_From_int((__pyx_v_self->n_epoch + __pyx_v_pre_epoch_times)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_t_3, __pyx_kp_s_Shape_s_ratio); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->S); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_kp_s_Elapsed_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyFloat_FromDouble((__pyx_v_toc - __pyx_v_tic)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_11, __pyx_kp_s_sec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":239 * self.epoch_S = np.append(self.epoch_S, self.S) * self.update_w() * if e_index % self.progress_period == self.progress_period-1: # <<<<<<<<<<<<<< * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") */ } } /* "tradingrrl.pyx":242 * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * toc = time.clock() # <<<<<<<<<<<<<< * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * self.w = self.w_opt.copy() */ __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_clock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_11) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_toc = __pyx_t_5; /* "tradingrrl.pyx":243 * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") # <<<<<<<<<<<<<< * self.w = self.w_opt.copy() * self.calc_dSdw() */ __pyx_t_1 = __Pyx_PyInt_From_long(((__pyx_v_e_index + __pyx_v_pre_epoch_times) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_kp_s_Epoch, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->n_epoch + __pyx_v_pre_epoch_times)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_11, __pyx_kp_s_Shape_s_ratio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->S); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_t_1, __pyx_kp_s_Elapsed_time); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyFloat_FromDouble((__pyx_v_toc - __pyx_v_tic)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_s_sec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":244 * toc = time.clock() * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * self.w = self.w_opt.copy() # <<<<<<<<<<<<<< * self.calc_dSdw() * print("Epoch loop end. Optimized sharp's ratio is " + str(self.S_opt) + ".") */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->w_opt), __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_11) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":245 * print("Epoch: " + str(e_index + pre_epoch_times + 1) + "/" + str(self.n_epoch + pre_epoch_times) +". Shape's ratio: " + str(self.S) + ". Elapsed time: " + str(toc-tic) + " sec.") * self.w = self.w_opt.copy() * self.calc_dSdw() # <<<<<<<<<<<<<< * print("Epoch loop end. Optimized sharp's ratio is " + str(self.S_opt) + ".") * */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calc_dSdw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_11) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":246 * self.w = self.w_opt.copy() * self.calc_dSdw() * print("Epoch loop end. Optimized sharp's ratio is " + str(self.S_opt) + ".") # <<<<<<<<<<<<<< * * def save_weight(self): */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->S_opt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_kp_s_Epoch_loop_end_Optimized_sharp_s, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":219 * self.w += self.rho*self.dSdw * * def fit(self): # <<<<<<<<<<<<<< * cdef double tic * cdef double toc */ /* 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_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("tradingrrl.TradingRRL.fit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":248 * print("Epoch loop end. Optimized sharp's ratio is " + str(self.S_opt) + ".") * * def save_weight(self): # <<<<<<<<<<<<<< * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_21save_weight(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_21save_weight(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("save_weight (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_20save_weight(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_20save_weight(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { 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; __Pyx_RefNannySetupContext("save_weight", 0); /* "tradingrrl.pyx":249 * * def save_weight(self): * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) # <<<<<<<<<<<<<< * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __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); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->w)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_self->w)}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_self->w)}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_self->w)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->w)); PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_self->w)); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_to_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_header, Py_False) < 0) __PYX_ERR(0, 249, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, Py_False) < 0) __PYX_ERR(0, 249, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__12, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "tradingrrl.pyx":250 * def save_weight(self): * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) # <<<<<<<<<<<<<< * * def load_weight(self): */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_1) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->epoch_S)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, ((PyObject *)__pyx_v_self->epoch_S)}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, ((PyObject *)__pyx_v_self->epoch_S)}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __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 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_self->epoch_S)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->epoch_S)); PyTuple_SET_ITEM(__pyx_t_2, 0+1, ((PyObject *)__pyx_v_self->epoch_S)); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __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_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_to_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_header, Py_False) < 0) __PYX_ERR(0, 250, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_index, Py_False) < 0) __PYX_ERR(0, 250, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__13, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "tradingrrl.pyx":248 * print("Epoch loop end. Optimized sharp's ratio is " + str(self.S_opt) + ".") * * def save_weight(self): # <<<<<<<<<<<<<< * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("tradingrrl.TradingRRL.save_weight", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":252 * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) * * def load_weight(self): # <<<<<<<<<<<<<< * tmp = pd.read_csv("w.csv", header=None) * self.w = tmp.T.values[0] */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_23load_weight(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_23load_weight(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("load_weight (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_22load_weight(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_22load_weight(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_v_tmp = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("load_weight", 0); /* "tradingrrl.pyx":253 * * def load_weight(self): * tmp = pd.read_csv("w.csv", header=None) # <<<<<<<<<<<<<< * self.w = tmp.T.values[0] * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_read_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_header, Py_None) < 0) __PYX_ERR(0, 253, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__14, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_tmp = __pyx_t_3; __pyx_t_3 = 0; /* "tradingrrl.pyx":254 * def load_weight(self): * tmp = pd.read_csv("w.csv", header=None) * self.w = tmp.T.values[0] # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_tmp, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":252 * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) * * def load_weight(self): # <<<<<<<<<<<<<< * tmp = pd.read_csv("w.csv", header=None) * self.w = tmp.T.values[0] */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("tradingrrl.TradingRRL.load_weight", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tmp); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":20 * * cdef class TradingRRL(object): * cdef public int T # <<<<<<<<<<<<<< * cdef public int M * cdef public int init_t */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1T_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1T___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1T___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1T_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1T_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1T_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1T_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L1_error) __pyx_v_self->T = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.T.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":21 * cdef class TradingRRL(object): * cdef public int T * cdef public int M # <<<<<<<<<<<<<< * cdef public int init_t * cdef public double mu */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1M_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1M_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1M___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1M___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->M); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.M.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1M_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1M_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1M_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1M_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L1_error) __pyx_v_self->M = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.M.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":22 * cdef public int T * cdef public int M * cdef public int init_t # <<<<<<<<<<<<<< * cdef public double mu * cdef public double sigma */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_6init_t_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_6init_t_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_6init_t___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_6init_t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->init_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.init_t.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_6init_t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_6init_t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_6init_t_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_6init_t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L1_error) __pyx_v_self->init_t = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.init_t.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":23 * cdef public int M * cdef public int init_t * cdef public double mu # <<<<<<<<<<<<<< * cdef public double sigma * cdef public double rho */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_2mu_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_2mu_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_2mu___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_2mu___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.mu.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_2mu_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_2mu_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_2mu_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_2mu_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 23, __pyx_L1_error) __pyx_v_self->mu = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.mu.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":24 * cdef public int init_t * cdef public double mu * cdef public double sigma # <<<<<<<<<<<<<< * cdef public double rho * cdef public np.ndarray all_t */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5sigma_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5sigma_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5sigma___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5sigma___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.sigma.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5sigma_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5sigma_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5sigma_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5sigma_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 24, __pyx_L1_error) __pyx_v_self->sigma = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.sigma.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":25 * cdef public double mu * cdef public double sigma * cdef public double rho # <<<<<<<<<<<<<< * cdef public np.ndarray all_t * cdef public np.ndarray all_p */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_3rho_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_3rho_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_3rho___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_3rho___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->rho); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.rho.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_3rho_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_3rho_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_3rho_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_3rho_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L1_error) __pyx_v_self->rho = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.rho.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":26 * cdef public double sigma * cdef public double rho * cdef public np.ndarray all_t # <<<<<<<<<<<<<< * cdef public np.ndarray all_p * cdef public np.ndarray t */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5all_t_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5all_t_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_t___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5all_t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->all_t)); __pyx_r = ((PyObject *)__pyx_v_self->all_t); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_t_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5all_t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 26, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->all_t); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_t)); __pyx_v_self->all_t = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.all_t.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_t_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_t_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_t_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5all_t_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->all_t); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_t)); __pyx_v_self->all_t = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":27 * cdef public double rho * cdef public np.ndarray all_t * cdef public np.ndarray all_p # <<<<<<<<<<<<<< * cdef public np.ndarray t * cdef public np.ndarray p */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5all_p_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5all_p_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_p___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5all_p___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->all_p)); __pyx_r = ((PyObject *)__pyx_v_self->all_p); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_p_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_p_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_p_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5all_p_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 27, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->all_p); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_p)); __pyx_v_self->all_p = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.all_p.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_p_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5all_p_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5all_p_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5all_p_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->all_p); __Pyx_DECREF(((PyObject *)__pyx_v_self->all_p)); __pyx_v_self->all_p = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":28 * cdef public np.ndarray all_t * cdef public np.ndarray all_p * cdef public np.ndarray t # <<<<<<<<<<<<<< * cdef public np.ndarray p * cdef public np.ndarray r */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1t_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1t_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1t___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1t___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->t)); __pyx_r = ((PyObject *)__pyx_v_self->t); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1t_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1t_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 28, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->t); __Pyx_DECREF(((PyObject *)__pyx_v_self->t)); __pyx_v_self->t = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.t.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1t_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1t_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1t_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1t_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->t); __Pyx_DECREF(((PyObject *)__pyx_v_self->t)); __pyx_v_self->t = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":29 * cdef public np.ndarray all_p * cdef public np.ndarray t * cdef public np.ndarray p # <<<<<<<<<<<<<< * cdef public np.ndarray r * cdef public np.ndarray x */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1p_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1p_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1p___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1p___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->p)); __pyx_r = ((PyObject *)__pyx_v_self->p); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1p_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1p_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1p_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1p_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 29, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->p); __Pyx_DECREF(((PyObject *)__pyx_v_self->p)); __pyx_v_self->p = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.p.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1p_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1p_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1p_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1p_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->p); __Pyx_DECREF(((PyObject *)__pyx_v_self->p)); __pyx_v_self->p = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":30 * cdef public np.ndarray t * cdef public np.ndarray p * cdef public np.ndarray r # <<<<<<<<<<<<<< * cdef public np.ndarray x * cdef public np.ndarray F */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1r_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1r_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1r___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1r___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->r)); __pyx_r = ((PyObject *)__pyx_v_self->r); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1r_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1r_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1r_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1r_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 30, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->r); __Pyx_DECREF(((PyObject *)__pyx_v_self->r)); __pyx_v_self->r = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.r.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1r_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1r_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1r_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1r_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->r); __Pyx_DECREF(((PyObject *)__pyx_v_self->r)); __pyx_v_self->r = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":31 * cdef public np.ndarray p * cdef public np.ndarray r * cdef public np.ndarray x # <<<<<<<<<<<<<< * cdef public np.ndarray F * cdef public np.ndarray R */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1x_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1x_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1x___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1x___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->x)); __pyx_r = ((PyObject *)__pyx_v_self->x); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1x_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1x_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 31, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->x); __Pyx_DECREF(((PyObject *)__pyx_v_self->x)); __pyx_v_self->x = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.x.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1x_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1x_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1x_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1x_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->x); __Pyx_DECREF(((PyObject *)__pyx_v_self->x)); __pyx_v_self->x = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":32 * cdef public np.ndarray r * cdef public np.ndarray x * cdef public np.ndarray F # <<<<<<<<<<<<<< * cdef public np.ndarray R * cdef public np.ndarray w */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1F_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1F_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1F___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1F___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->F)); __pyx_r = ((PyObject *)__pyx_v_self->F); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1F_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1F_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1F_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1F_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 32, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->F); __Pyx_DECREF(((PyObject *)__pyx_v_self->F)); __pyx_v_self->F = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.F.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1F_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1F_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1F_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1F_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->F); __Pyx_DECREF(((PyObject *)__pyx_v_self->F)); __pyx_v_self->F = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":33 * cdef public np.ndarray x * cdef public np.ndarray F * cdef public np.ndarray R # <<<<<<<<<<<<<< * cdef public np.ndarray w * cdef public np.ndarray w_opt */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1R_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1R_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1R___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1R___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->R)); __pyx_r = ((PyObject *)__pyx_v_self->R); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1R_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1R_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1R_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1R_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 33, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->R); __Pyx_DECREF(((PyObject *)__pyx_v_self->R)); __pyx_v_self->R = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.R.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1R_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1R_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1R_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1R_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->R); __Pyx_DECREF(((PyObject *)__pyx_v_self->R)); __pyx_v_self->R = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":34 * cdef public np.ndarray F * cdef public np.ndarray R * cdef public np.ndarray w # <<<<<<<<<<<<<< * cdef public np.ndarray w_opt * cdef public np.ndarray epoch_S */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1w_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1w_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1w___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1w___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->w)); __pyx_r = ((PyObject *)__pyx_v_self->w); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1w_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1w_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1w_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1w_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 34, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.w.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1w_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1w_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1w_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1w_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->w); __Pyx_DECREF(((PyObject *)__pyx_v_self->w)); __pyx_v_self->w = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":35 * cdef public np.ndarray R * cdef public np.ndarray w * cdef public np.ndarray w_opt # <<<<<<<<<<<<<< * cdef public np.ndarray epoch_S * cdef public int n_epoch */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5w_opt_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5w_opt_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5w_opt___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5w_opt___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->w_opt)); __pyx_r = ((PyObject *)__pyx_v_self->w_opt); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 35, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->w_opt); __Pyx_DECREF(((PyObject *)__pyx_v_self->w_opt)); __pyx_v_self->w_opt = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.w_opt.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5w_opt_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->w_opt); __Pyx_DECREF(((PyObject *)__pyx_v_self->w_opt)); __pyx_v_self->w_opt = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":36 * cdef public np.ndarray w * cdef public np.ndarray w_opt * cdef public np.ndarray epoch_S # <<<<<<<<<<<<<< * cdef public int n_epoch * cdef public int progress_period */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_7epoch_S___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->epoch_S)); __pyx_r = ((PyObject *)__pyx_v_self->epoch_S); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 36, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->epoch_S); __Pyx_DECREF(((PyObject *)__pyx_v_self->epoch_S)); __pyx_v_self->epoch_S = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.epoch_S.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_7epoch_S_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->epoch_S); __Pyx_DECREF(((PyObject *)__pyx_v_self->epoch_S)); __pyx_v_self->epoch_S = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":37 * cdef public np.ndarray w_opt * cdef public np.ndarray epoch_S * cdef public int n_epoch # <<<<<<<<<<<<<< * cdef public int progress_period * cdef public double q_threshold */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_7n_epoch___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_7n_epoch___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->n_epoch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.n_epoch.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_7n_epoch_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_7n_epoch_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 37, __pyx_L1_error) __pyx_v_self->n_epoch = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.n_epoch.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":38 * cdef public np.ndarray epoch_S * cdef public int n_epoch * cdef public int progress_period # <<<<<<<<<<<<<< * cdef public double q_threshold * cdef public np.ndarray sumR */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_15progress_period_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_15progress_period_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_15progress_period___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_15progress_period___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->progress_period); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.progress_period.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_15progress_period_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_15progress_period_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_15progress_period_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_15progress_period_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error) __pyx_v_self->progress_period = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.progress_period.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":39 * cdef public int n_epoch * cdef public int progress_period * cdef public double q_threshold # <<<<<<<<<<<<<< * cdef public np.ndarray sumR * cdef public np.ndarray sumR2 */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_11q_threshold___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_11q_threshold___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->q_threshold); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.q_threshold.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_11q_threshold_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_11q_threshold_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 39, __pyx_L1_error) __pyx_v_self->q_threshold = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.q_threshold.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":40 * cdef public int progress_period * cdef public double q_threshold * cdef public np.ndarray sumR # <<<<<<<<<<<<<< * cdef public np.ndarray sumR2 * cdef public double A */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4sumR_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4sumR_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4sumR___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4sumR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->sumR)); __pyx_r = ((PyObject *)__pyx_v_self->sumR); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4sumR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4sumR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4sumR_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4sumR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 40, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->sumR); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR)); __pyx_v_self->sumR = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.sumR.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4sumR_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4sumR_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4sumR_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4sumR_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->sumR); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR)); __pyx_v_self->sumR = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":41 * cdef public double q_threshold * cdef public np.ndarray sumR * cdef public np.ndarray sumR2 # <<<<<<<<<<<<<< * cdef public double A * cdef public double B */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5sumR2_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5sumR2_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5sumR2___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5sumR2___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_r = ((PyObject *)__pyx_v_self->sumR2); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 41, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->sumR2); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_v_self->sumR2 = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.sumR2.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5sumR2_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->sumR2); __Pyx_DECREF(((PyObject *)__pyx_v_self->sumR2)); __pyx_v_self->sumR2 = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":42 * cdef public np.ndarray sumR * cdef public np.ndarray sumR2 * cdef public double A # <<<<<<<<<<<<<< * cdef public double B * cdef public double S */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1A_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1A_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1A___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1A___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->A); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.A.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1A_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1A_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1A_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1A_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error) __pyx_v_self->A = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.A.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":43 * cdef public np.ndarray sumR2 * cdef public double A * cdef public double B # <<<<<<<<<<<<<< * cdef public double S * cdef public double S_opt */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1B_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1B_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1B___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1B___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->B); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.B.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1B_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1B_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1B_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1B_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error) __pyx_v_self->B = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.B.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":44 * cdef public double A * cdef public double B * cdef public double S # <<<<<<<<<<<<<< * cdef public double S_opt * cdef public double dSdA */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1S_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_1S_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1S___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_1S___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->S); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.S.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_1S_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_1S_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_1S_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_1S_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error) __pyx_v_self->S = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.S.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":45 * cdef public double B * cdef public double S * cdef public double S_opt # <<<<<<<<<<<<<< * cdef public double dSdA * cdef public double dSdB */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5S_opt_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5S_opt_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5S_opt___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5S_opt___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->S_opt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.S_opt.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5S_opt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5S_opt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5S_opt_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5S_opt_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L1_error) __pyx_v_self->S_opt = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.S_opt.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":46 * cdef public double S * cdef public double S_opt * cdef public double dSdA # <<<<<<<<<<<<<< * cdef public double dSdB * cdef public double dAdR */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdA_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdA_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdA___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdA___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->dSdA); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dSdA.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdA_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdA_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdA_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdA_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) __pyx_v_self->dSdA = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.dSdA.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":47 * cdef public double S_opt * cdef public double dSdA * cdef public double dSdB # <<<<<<<<<<<<<< * cdef public double dAdR * cdef public np.ndarray dBdR */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdB_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdB_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdB___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdB___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->dSdB); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dSdB.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdB_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdB_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdB_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdB_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) __pyx_v_self->dSdB = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.dSdB.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":48 * cdef public double dSdA * cdef public double dSdB * cdef public double dAdR # <<<<<<<<<<<<<< * cdef public np.ndarray dBdR * cdef public np.ndarray dRdF */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dAdR_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dAdR_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dAdR___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dAdR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->dAdR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dAdR.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dAdR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dAdR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dAdR_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dAdR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error) __pyx_v_self->dAdR = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("tradingrrl.TradingRRL.dAdR.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":49 * cdef public double dSdB * cdef public double dAdR * cdef public np.ndarray dBdR # <<<<<<<<<<<<<< * cdef public np.ndarray dRdF * cdef public np.ndarray dRdFp */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dBdR_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dBdR_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dBdR___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dBdR___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dBdR)); __pyx_r = ((PyObject *)__pyx_v_self->dBdR); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 49, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dBdR); __Pyx_DECREF(((PyObject *)__pyx_v_self->dBdR)); __pyx_v_self->dBdR = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dBdR.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dBdR_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dBdR); __Pyx_DECREF(((PyObject *)__pyx_v_self->dBdR)); __pyx_v_self->dBdR = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":50 * cdef public double dAdR * cdef public np.ndarray dBdR * cdef public np.ndarray dRdF # <<<<<<<<<<<<<< * cdef public np.ndarray dRdFp * cdef public np.ndarray dFpdw */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dRdF_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dRdF_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dRdF___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dRdF___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dRdF)); __pyx_r = ((PyObject *)__pyx_v_self->dRdF); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 50, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dRdF); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdF)); __pyx_v_self->dRdF = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dRdF.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dRdF_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dRdF); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdF)); __pyx_v_self->dRdF = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":51 * cdef public np.ndarray dBdR * cdef public np.ndarray dRdF * cdef public np.ndarray dRdFp # <<<<<<<<<<<<<< * cdef public np.ndarray dFpdw * cdef public np.ndarray dFdw */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5dRdFp___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dRdFp)); __pyx_r = ((PyObject *)__pyx_v_self->dRdFp); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 51, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dRdFp); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdFp)); __pyx_v_self->dRdFp = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dRdFp.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5dRdFp_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dRdFp); __Pyx_DECREF(((PyObject *)__pyx_v_self->dRdFp)); __pyx_v_self->dRdFp = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":52 * cdef public np.ndarray dRdF * cdef public np.ndarray dRdFp * cdef public np.ndarray dFpdw # <<<<<<<<<<<<<< * cdef public np.ndarray dFdw * cdef public np.ndarray dSdw */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_5dFpdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dFpdw)); __pyx_r = ((PyObject *)__pyx_v_self->dFpdw); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dFpdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFpdw)); __pyx_v_self->dFpdw = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dFpdw.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_5dFpdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dFpdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFpdw)); __pyx_v_self->dFpdw = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":53 * cdef public np.ndarray dRdFp * cdef public np.ndarray dFpdw * cdef public np.ndarray dFdw # <<<<<<<<<<<<<< * cdef public np.ndarray dSdw * */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dFdw_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dFdw_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dFdw___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dFdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dFdw)); __pyx_r = ((PyObject *)__pyx_v_self->dFdw); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 53, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dFdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFdw)); __pyx_v_self->dFdw = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dFdw.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dFdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dFdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dFdw)); __pyx_v_self->dFdw = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":54 * cdef public np.ndarray dFpdw * cdef public np.ndarray dFdw * cdef public np.ndarray dSdw # <<<<<<<<<<<<<< * * def __init__(self, T=1000, M=200, init_t=10000, mu=10000, sigma=0.04, rho=1.0, n_epoch=10000): */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdw_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_10tradingrrl_10TradingRRL_4dSdw_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdw___get__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_10TradingRRL_4dSdw___get__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self->dSdw)); __pyx_r = ((PyObject *)__pyx_v_self->dSdw); goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_2__set__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_2__set__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 54, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->dSdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dSdw)); __pyx_v_self->dSdw = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("tradingrrl.TradingRRL.dSdw.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_5__del__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_r = __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_4__del__(((struct __pyx_obj_10tradingrrl_TradingRRL *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10tradingrrl_10TradingRRL_4dSdw_4__del__(struct __pyx_obj_10tradingrrl_TradingRRL *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->dSdw); __Pyx_DECREF(((PyObject *)__pyx_v_self->dSdw)); __pyx_v_self->dSdw = ((PyArrayObject *)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "tradingrrl.pyx":257 * * * def plot_hist(n_tick, R): # <<<<<<<<<<<<<< * rnge = max(R)-min(R) * tick = rnge/n_tick */ /* Python wrapper */ static PyObject *__pyx_pw_10tradingrrl_1plot_hist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10tradingrrl_1plot_hist = {"plot_hist", (PyCFunction)__pyx_pw_10tradingrrl_1plot_hist, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10tradingrrl_1plot_hist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_n_tick = 0; PyObject *__pyx_v_R = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plot_hist (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_tick,&__pyx_n_s_R,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n_tick)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_R)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plot_hist", 1, 2, 2, 1); __PYX_ERR(0, 257, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "plot_hist") < 0)) __PYX_ERR(0, 257, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_n_tick = values[0]; __pyx_v_R = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("plot_hist", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 257, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("tradingrrl.plot_hist", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10tradingrrl_plot_hist(__pyx_self, __pyx_v_n_tick, __pyx_v_R); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10tradingrrl_plot_hist(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n_tick, PyObject *__pyx_v_R) { PyObject *__pyx_v_rnge = NULL; PyObject *__pyx_v_tick = NULL; PyObject *__pyx_v_tick_min = NULL; PyObject *__pyx_v_tick_max = NULL; PyObject *__pyx_v_tick_center = NULL; PyObject *__pyx_v_tick_val = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); 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; PyObject *__pyx_t_12 = NULL; Py_ssize_t __pyx_t_13; __Pyx_RefNannySetupContext("plot_hist", 0); /* "tradingrrl.pyx":258 * * def plot_hist(n_tick, R): * rnge = max(R)-min(R) # <<<<<<<<<<<<<< * tick = rnge/n_tick * tick_min = [min(R)-tick*0.5 +i*tick for i in range(n_tick)] */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_R); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_R); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_min, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_rnge = __pyx_t_1; __pyx_t_1 = 0; /* "tradingrrl.pyx":259 * def plot_hist(n_tick, R): * rnge = max(R)-min(R) * tick = rnge/n_tick # <<<<<<<<<<<<<< * tick_min = [min(R)-tick*0.5 +i*tick for i in range(n_tick)] * tick_max = [min(R)+tick*0.5 +i*tick for i in range(n_tick)] */ __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_rnge, __pyx_v_n_tick); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_tick = __pyx_t_1; __pyx_t_1 = 0; /* "tradingrrl.pyx":260 * rnge = max(R)-min(R) * tick = rnge/n_tick * tick_min = [min(R)-tick*0.5 +i*tick for i in range(n_tick)] # <<<<<<<<<<<<<< * tick_max = [min(R)+tick*0.5 +i*tick for i in range(n_tick)] * tick_center = [min(R) +i*tick for i in range(n_tick)] */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_n_tick); __Pyx_GIVEREF(__pyx_v_n_tick); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_n_tick); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 260, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 260, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 260, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_R); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_min, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_v_tick, __pyx_float_0_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyNumber_Subtract(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_v_i, __pyx_v_tick); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_tick_min = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":261 * tick = rnge/n_tick * tick_min = [min(R)-tick*0.5 +i*tick for i in range(n_tick)] * tick_max = [min(R)+tick*0.5 +i*tick for i in range(n_tick)] # <<<<<<<<<<<<<< * tick_center = [min(R) +i*tick for i in range(n_tick)] * tick_val=[0.0]*n_tick */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_n_tick); __Pyx_GIVEREF(__pyx_v_n_tick); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_n_tick); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_3 = __pyx_t_6; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 261, __pyx_L1_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif } } else { __pyx_t_6 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 261, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_R); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_min, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_v_tick, __pyx_float_0_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_v_i, __pyx_v_tick); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_tick_max = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":262 * tick_min = [min(R)-tick*0.5 +i*tick for i in range(n_tick)] * tick_max = [min(R)+tick*0.5 +i*tick for i in range(n_tick)] * tick_center = [min(R) +i*tick for i in range(n_tick)] # <<<<<<<<<<<<<< * tick_val=[0.0]*n_tick * for i in range(n_tick ): */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_n_tick); __Pyx_GIVEREF(__pyx_v_n_tick); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_n_tick); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 262, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 262, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 262, __pyx_L1_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 262, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_R); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_min, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_v_i, __pyx_v_tick); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_tick_center = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":263 * tick_max = [min(R)+tick*0.5 +i*tick for i in range(n_tick)] * tick_center = [min(R) +i*tick for i in range(n_tick)] * tick_val=[0.0]*n_tick # <<<<<<<<<<<<<< * for i in range(n_tick ): * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_float_0_0); __Pyx_GIVEREF(__pyx_float_0_0); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_float_0_0); { PyObject* __pyx_temp = PyNumber_InPlaceMultiply(__pyx_t_1, __pyx_v_n_tick); if (unlikely(!__pyx_temp)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_temp); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_temp; } __pyx_v_tick_val = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":264 * tick_center = [min(R) +i*tick for i in range(n_tick)] * tick_val=[0.0]*n_tick * for i in range(n_tick ): # <<<<<<<<<<<<<< * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) * plt.bar(tick_center,tick_val, width=tick) */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_n_tick); __Pyx_GIVEREF(__pyx_v_n_tick); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_n_tick); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 264, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":265 * tick_val=[0.0]*n_tick * for i in range(n_tick ): * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) # <<<<<<<<<<<<<< * plt.bar(tick_center,tick_val, width=tick) * plt.grid() */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_where); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyObject_GetItem(__pyx_v_tick_min, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } if (!__pyx_t_10) { __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_R); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_R}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_R}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_9); } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL; __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_R); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_t_9, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } if (!__pyx_t_9) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_11}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_11}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else #endif { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (__pyx_t_8) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PySet_New(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intersection); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_where); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (!__pyx_t_11) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_R); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_R}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_R}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif { __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; __Pyx_INCREF(__pyx_v_R); __Pyx_GIVEREF(__pyx_v_R); PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_R); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyObject_GetItem(__pyx_v_tick_max, __pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = PyObject_RichCompare(__pyx_t_8, __pyx_t_9, Py_LE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_9) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_12}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_12}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_2) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_13 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(PyObject_SetItem(__pyx_v_tick_val, __pyx_v_i, __pyx_t_3) < 0)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "tradingrrl.pyx":264 * tick_center = [min(R) +i*tick for i in range(n_tick)] * tick_val=[0.0]*n_tick * for i in range(n_tick ): # <<<<<<<<<<<<<< * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) * plt.bar(tick_center,tick_val, width=tick) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":266 * for i in range(n_tick ): * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) * plt.bar(tick_center,tick_val, width=tick) # <<<<<<<<<<<<<< * plt.grid() * plt.show() */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_plt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_bar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_tick_center); __Pyx_GIVEREF(__pyx_v_tick_center); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_tick_center); __Pyx_INCREF(__pyx_v_tick_val); __Pyx_GIVEREF(__pyx_v_tick_val); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tick_val); __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_width, __pyx_v_tick) < 0) __PYX_ERR(0, 266, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "tradingrrl.pyx":267 * tick_val[i]=len(set(np.where(tick_min[i]<np.array(R))[0].tolist()).intersection(np.where(np.array(R)<=tick_max[i])[0])) * plt.bar(tick_center,tick_val, width=tick) * plt.grid() # <<<<<<<<<<<<<< * plt.show() */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_plt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_grid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } if (__pyx_t_7) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 267, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "tradingrrl.pyx":268 * plt.bar(tick_center,tick_val, width=tick) * plt.grid() * plt.show() # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_plt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_show); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (__pyx_t_1) { __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 268, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "tradingrrl.pyx":257 * * * def plot_hist(n_tick, R): # <<<<<<<<<<<<<< * rnge = max(R)-min(R) * tick = rnge/n_tick */ /* 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_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("tradingrrl.plot_hist", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_rnge); __Pyx_XDECREF(__pyx_v_tick); __Pyx_XDECREF(__pyx_v_tick_min); __Pyx_XDECREF(__pyx_v_tick_max); __Pyx_XDECREF(__pyx_v_tick_center); __Pyx_XDECREF(__pyx_v_tick_val); __Pyx_XDECREF(__pyx_v_i); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__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_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __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, 218, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __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, 222, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = <Py_ssize_t*>PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __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); } __pyx_L14:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __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, 259, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = ((char *)"b"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = ((char *)"B"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = ((char *)"h"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = ((char *)"H"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = ((char *)"i"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = ((char *)"I"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = ((char *)"l"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = ((char *)"L"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = ((char *)"q"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = ((char *)"Q"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = ((char *)"f"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = ((char *)"d"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = ((char *)"g"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = ((char *)"Zf"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = ((char *)"Zd"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = ((char *)"Zg"); break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = ((char *)"O"); break; default: /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(1, 278, __pyx_L1_error) break; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = <char*>stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) __pyx_v_f = __pyx_t_7; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, <void*>a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, <void*>a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, <void*>a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, <void*>a, <void*>b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, <void*>a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, <void*>a, <void*>b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, <void*>a, <void*>b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, <void*>a, <void*>b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(1, 794, __pyx_L1_error) } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 795, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - <int>(new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 796, __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, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - <int>(new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __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, 799, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __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, 803, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 823, __pyx_L1_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __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, 844, __pyx_L1_error) } __pyx_L15:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = <PyObject*>base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = <PyObject*>base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = <PyObject*>base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = <PyObject*>base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return <object>arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return <object>arr.base # <<<<<<<<<<<<<< * * */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":985 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< * try: * _import_array() */ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_array", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":986 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< * _import_array() * except Exception: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":987 * cdef inline int import_array() except -1: * try: * _import_array() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.multiarray failed to import") */ __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 987, __pyx_L3_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":986 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< * _import_array() * except Exception: */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_PyThreadState_assign /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":988 * try: * _import_array() * except Exception: # <<<<<<<<<<<<<< * raise ImportError("numpy.core.multiarray failed to import") * */ __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 988, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":989 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 989, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(1, 989, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":986 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< * _import_array() * except Exception: */ __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L10_try_end:; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":985 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< * try: * _import_array() */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":991 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< * try: * _import_umath() */ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_umath", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":992 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":993 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 993, __pyx_L3_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":992 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_PyThreadState_assign /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":994 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< * raise ImportError("numpy.core.umath failed to import") * */ __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 994, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":995 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 995, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(1, 995, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":992 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L10_try_end:; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":991 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< * try: * _import_umath() */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":997 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< * try: * _import_umath() */ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_ufunc", 0); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":998 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":999 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< * except Exception: * raise ImportError("numpy.core.umath failed to import") */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 999, __pyx_L3_error) /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":998 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; __Pyx_PyThreadState_assign /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1000 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< * raise ImportError("numpy.core.umath failed to import") */ __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1000, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1001 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< */ __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1001, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(1, 1001, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":998 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< * _import_umath() * except Exception: */ __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L10_try_end:; } /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":997 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< * try: * _import_umath() */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_tp_new_10tradingrrl_TradingRRL(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_10tradingrrl_TradingRRL *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_obj_10tradingrrl_TradingRRL *)o); p->all_t = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->all_p = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->t = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->p = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->r = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->F = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->w = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->w_opt = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->epoch_S = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->sumR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->sumR2 = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dBdR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dRdF = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dRdFp = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dFpdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dFdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); p->dSdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_10tradingrrl_TradingRRL(PyObject *o) { struct __pyx_obj_10tradingrrl_TradingRRL *p = (struct __pyx_obj_10tradingrrl_TradingRRL *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->all_t); Py_CLEAR(p->all_p); Py_CLEAR(p->t); Py_CLEAR(p->p); Py_CLEAR(p->r); Py_CLEAR(p->x); Py_CLEAR(p->F); Py_CLEAR(p->R); Py_CLEAR(p->w); Py_CLEAR(p->w_opt); Py_CLEAR(p->epoch_S); Py_CLEAR(p->sumR); Py_CLEAR(p->sumR2); Py_CLEAR(p->dBdR); Py_CLEAR(p->dRdF); Py_CLEAR(p->dRdFp); Py_CLEAR(p->dFpdw); Py_CLEAR(p->dFdw); Py_CLEAR(p->dSdw); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_10tradingrrl_TradingRRL(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_10tradingrrl_TradingRRL *p = (struct __pyx_obj_10tradingrrl_TradingRRL *)o; if (p->all_t) { e = (*v)(((PyObject*)p->all_t), a); if (e) return e; } if (p->all_p) { e = (*v)(((PyObject*)p->all_p), a); if (e) return e; } if (p->t) { e = (*v)(((PyObject*)p->t), a); if (e) return e; } if (p->p) { e = (*v)(((PyObject*)p->p), a); if (e) return e; } if (p->r) { e = (*v)(((PyObject*)p->r), a); if (e) return e; } if (p->x) { e = (*v)(((PyObject*)p->x), a); if (e) return e; } if (p->F) { e = (*v)(((PyObject*)p->F), a); if (e) return e; } if (p->R) { e = (*v)(((PyObject*)p->R), a); if (e) return e; } if (p->w) { e = (*v)(((PyObject*)p->w), a); if (e) return e; } if (p->w_opt) { e = (*v)(((PyObject*)p->w_opt), a); if (e) return e; } if (p->epoch_S) { e = (*v)(((PyObject*)p->epoch_S), a); if (e) return e; } if (p->sumR) { e = (*v)(((PyObject*)p->sumR), a); if (e) return e; } if (p->sumR2) { e = (*v)(((PyObject*)p->sumR2), a); if (e) return e; } if (p->dBdR) { e = (*v)(((PyObject*)p->dBdR), a); if (e) return e; } if (p->dRdF) { e = (*v)(((PyObject*)p->dRdF), a); if (e) return e; } if (p->dRdFp) { e = (*v)(((PyObject*)p->dRdFp), a); if (e) return e; } if (p->dFpdw) { e = (*v)(((PyObject*)p->dFpdw), a); if (e) return e; } if (p->dFdw) { e = (*v)(((PyObject*)p->dFdw), a); if (e) return e; } if (p->dSdw) { e = (*v)(((PyObject*)p->dSdw), a); if (e) return e; } return 0; } static int __pyx_tp_clear_10tradingrrl_TradingRRL(PyObject *o) { PyObject* tmp; struct __pyx_obj_10tradingrrl_TradingRRL *p = (struct __pyx_obj_10tradingrrl_TradingRRL *)o; tmp = ((PyObject*)p->all_t); p->all_t = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->all_p); p->all_p = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->t); p->t = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->p); p->p = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->r); p->r = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->x); p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->F); p->F = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->R); p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->w); p->w = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->w_opt); p->w_opt = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->epoch_S); p->epoch_S = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->sumR); p->sumR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->sumR2); p->sumR2 = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dBdR); p->dBdR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dRdF); p->dRdF = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dRdFp); p->dRdFp = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dFpdw); p->dFpdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dFdw); p->dFdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->dSdw); p->dSdw = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_T(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1T_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_T(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1T_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_M(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1M_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_M(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1M_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_init_t(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_6init_t_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_init_t(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_6init_t_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_mu(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_2mu_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_mu(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_2mu_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_sigma(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5sigma_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_sigma(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5sigma_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_rho(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_3rho_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_rho(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_3rho_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_all_t(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5all_t_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_all_t(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5all_t_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5all_t_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_all_p(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5all_p_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_all_p(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5all_p_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5all_p_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_t(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1t_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_t(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1t_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1t_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_p(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1p_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_p(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1p_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1p_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_r(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1r_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_r(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1r_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1r_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_x(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1x_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_x(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1x_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1x_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_F(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1F_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_F(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1F_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1F_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_R(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1R_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_R(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1R_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1R_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_w(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1w_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_w(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1w_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_1w_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_w_opt(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_w_opt(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5w_opt_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_epoch_S(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_epoch_S(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_7epoch_S_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_n_epoch(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_n_epoch(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_7n_epoch_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_progress_period(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_15progress_period_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_progress_period(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_15progress_period_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_q_threshold(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_q_threshold(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_11q_threshold_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_sumR(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4sumR_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_sumR(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4sumR_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_4sumR_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_sumR2(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_sumR2(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5sumR2_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_A(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1A_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_A(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1A_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_B(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1B_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_B(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1B_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_S(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_1S_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_S(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_1S_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_S_opt(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5S_opt_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_S_opt(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5S_opt_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dSdA(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdA_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dSdA(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdA_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dSdB(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdB_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dSdB(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdB_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dAdR(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dAdR_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dAdR(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dAdR_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dBdR(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dBdR(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_4dBdR_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dRdF(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dRdF(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_4dRdF_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dRdFp(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dRdFp(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5dRdFp_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dFpdw(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dFpdw(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_5dFpdw_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dFdw(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dFdw(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_4dFdw_5__del__(o); } } static PyObject *__pyx_getprop_10tradingrrl_10TradingRRL_dSdw(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_1__get__(o); } static int __pyx_setprop_10tradingrrl_10TradingRRL_dSdw(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_3__set__(o, v); } else { return __pyx_pw_10tradingrrl_10TradingRRL_4dSdw_5__del__(o); } } static PyMethodDef __pyx_methods_10tradingrrl_TradingRRL[] = { {"load_csv", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_3load_csv, METH_O, 0}, {"quant", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_5quant, METH_O, 0}, {"set_t_p_r", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_7set_t_p_r, METH_NOARGS, 0}, {"set_x_F", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_9set_x_F, METH_NOARGS, 0}, {"calc_R", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_11calc_R, METH_NOARGS, 0}, {"calc_sumR", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_13calc_sumR, METH_NOARGS, 0}, {"calc_dSdw", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_15calc_dSdw, METH_NOARGS, 0}, {"update_w", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_17update_w, METH_NOARGS, 0}, {"fit", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_19fit, METH_NOARGS, 0}, {"save_weight", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_21save_weight, METH_NOARGS, 0}, {"load_weight", (PyCFunction)__pyx_pw_10tradingrrl_10TradingRRL_23load_weight, METH_NOARGS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_10tradingrrl_TradingRRL[] = { {(char *)"T", __pyx_getprop_10tradingrrl_10TradingRRL_T, __pyx_setprop_10tradingrrl_10TradingRRL_T, (char *)0, 0}, {(char *)"M", __pyx_getprop_10tradingrrl_10TradingRRL_M, __pyx_setprop_10tradingrrl_10TradingRRL_M, (char *)0, 0}, {(char *)"init_t", __pyx_getprop_10tradingrrl_10TradingRRL_init_t, __pyx_setprop_10tradingrrl_10TradingRRL_init_t, (char *)0, 0}, {(char *)"mu", __pyx_getprop_10tradingrrl_10TradingRRL_mu, __pyx_setprop_10tradingrrl_10TradingRRL_mu, (char *)0, 0}, {(char *)"sigma", __pyx_getprop_10tradingrrl_10TradingRRL_sigma, __pyx_setprop_10tradingrrl_10TradingRRL_sigma, (char *)0, 0}, {(char *)"rho", __pyx_getprop_10tradingrrl_10TradingRRL_rho, __pyx_setprop_10tradingrrl_10TradingRRL_rho, (char *)0, 0}, {(char *)"all_t", __pyx_getprop_10tradingrrl_10TradingRRL_all_t, __pyx_setprop_10tradingrrl_10TradingRRL_all_t, (char *)0, 0}, {(char *)"all_p", __pyx_getprop_10tradingrrl_10TradingRRL_all_p, __pyx_setprop_10tradingrrl_10TradingRRL_all_p, (char *)0, 0}, {(char *)"t", __pyx_getprop_10tradingrrl_10TradingRRL_t, __pyx_setprop_10tradingrrl_10TradingRRL_t, (char *)0, 0}, {(char *)"p", __pyx_getprop_10tradingrrl_10TradingRRL_p, __pyx_setprop_10tradingrrl_10TradingRRL_p, (char *)0, 0}, {(char *)"r", __pyx_getprop_10tradingrrl_10TradingRRL_r, __pyx_setprop_10tradingrrl_10TradingRRL_r, (char *)0, 0}, {(char *)"x", __pyx_getprop_10tradingrrl_10TradingRRL_x, __pyx_setprop_10tradingrrl_10TradingRRL_x, (char *)0, 0}, {(char *)"F", __pyx_getprop_10tradingrrl_10TradingRRL_F, __pyx_setprop_10tradingrrl_10TradingRRL_F, (char *)0, 0}, {(char *)"R", __pyx_getprop_10tradingrrl_10TradingRRL_R, __pyx_setprop_10tradingrrl_10TradingRRL_R, (char *)0, 0}, {(char *)"w", __pyx_getprop_10tradingrrl_10TradingRRL_w, __pyx_setprop_10tradingrrl_10TradingRRL_w, (char *)0, 0}, {(char *)"w_opt", __pyx_getprop_10tradingrrl_10TradingRRL_w_opt, __pyx_setprop_10tradingrrl_10TradingRRL_w_opt, (char *)0, 0}, {(char *)"epoch_S", __pyx_getprop_10tradingrrl_10TradingRRL_epoch_S, __pyx_setprop_10tradingrrl_10TradingRRL_epoch_S, (char *)0, 0}, {(char *)"n_epoch", __pyx_getprop_10tradingrrl_10TradingRRL_n_epoch, __pyx_setprop_10tradingrrl_10TradingRRL_n_epoch, (char *)0, 0}, {(char *)"progress_period", __pyx_getprop_10tradingrrl_10TradingRRL_progress_period, __pyx_setprop_10tradingrrl_10TradingRRL_progress_period, (char *)0, 0}, {(char *)"q_threshold", __pyx_getprop_10tradingrrl_10TradingRRL_q_threshold, __pyx_setprop_10tradingrrl_10TradingRRL_q_threshold, (char *)0, 0}, {(char *)"sumR", __pyx_getprop_10tradingrrl_10TradingRRL_sumR, __pyx_setprop_10tradingrrl_10TradingRRL_sumR, (char *)0, 0}, {(char *)"sumR2", __pyx_getprop_10tradingrrl_10TradingRRL_sumR2, __pyx_setprop_10tradingrrl_10TradingRRL_sumR2, (char *)0, 0}, {(char *)"A", __pyx_getprop_10tradingrrl_10TradingRRL_A, __pyx_setprop_10tradingrrl_10TradingRRL_A, (char *)0, 0}, {(char *)"B", __pyx_getprop_10tradingrrl_10TradingRRL_B, __pyx_setprop_10tradingrrl_10TradingRRL_B, (char *)0, 0}, {(char *)"S", __pyx_getprop_10tradingrrl_10TradingRRL_S, __pyx_setprop_10tradingrrl_10TradingRRL_S, (char *)0, 0}, {(char *)"S_opt", __pyx_getprop_10tradingrrl_10TradingRRL_S_opt, __pyx_setprop_10tradingrrl_10TradingRRL_S_opt, (char *)0, 0}, {(char *)"dSdA", __pyx_getprop_10tradingrrl_10TradingRRL_dSdA, __pyx_setprop_10tradingrrl_10TradingRRL_dSdA, (char *)0, 0}, {(char *)"dSdB", __pyx_getprop_10tradingrrl_10TradingRRL_dSdB, __pyx_setprop_10tradingrrl_10TradingRRL_dSdB, (char *)0, 0}, {(char *)"dAdR", __pyx_getprop_10tradingrrl_10TradingRRL_dAdR, __pyx_setprop_10tradingrrl_10TradingRRL_dAdR, (char *)0, 0}, {(char *)"dBdR", __pyx_getprop_10tradingrrl_10TradingRRL_dBdR, __pyx_setprop_10tradingrrl_10TradingRRL_dBdR, (char *)0, 0}, {(char *)"dRdF", __pyx_getprop_10tradingrrl_10TradingRRL_dRdF, __pyx_setprop_10tradingrrl_10TradingRRL_dRdF, (char *)0, 0}, {(char *)"dRdFp", __pyx_getprop_10tradingrrl_10TradingRRL_dRdFp, __pyx_setprop_10tradingrrl_10TradingRRL_dRdFp, (char *)0, 0}, {(char *)"dFpdw", __pyx_getprop_10tradingrrl_10TradingRRL_dFpdw, __pyx_setprop_10tradingrrl_10TradingRRL_dFpdw, (char *)0, 0}, {(char *)"dFdw", __pyx_getprop_10tradingrrl_10TradingRRL_dFdw, __pyx_setprop_10tradingrrl_10TradingRRL_dFdw, (char *)0, 0}, {(char *)"dSdw", __pyx_getprop_10tradingrrl_10TradingRRL_dSdw, __pyx_setprop_10tradingrrl_10TradingRRL_dSdw, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_10tradingrrl_TradingRRL = { PyVarObject_HEAD_INIT(0, 0) "tradingrrl.TradingRRL", /*tp_name*/ sizeof(struct __pyx_obj_10tradingrrl_TradingRRL), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_10tradingrrl_TradingRRL, /*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*/ 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_10tradingrrl_TradingRRL, /*tp_traverse*/ __pyx_tp_clear_10tradingrrl_TradingRRL, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_10tradingrrl_TradingRRL, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_10tradingrrl_TradingRRL, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_10tradingrrl_10TradingRRL_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_10tradingrrl_TradingRRL, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "tradingrrl", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1}, {&__pyx_kp_s_C_Work_Work_Dropbox_Dropbox_Jupy, __pyx_k_C_Work_Work_Dropbox_Dropbox_Jupy, sizeof(__pyx_k_C_Work_Work_Dropbox_Dropbox_Jupy), 0, 0, 1, 0}, {&__pyx_n_s_DataFrame, __pyx_k_DataFrame, sizeof(__pyx_k_DataFrame), 0, 0, 1, 1}, {&__pyx_kp_s_Elapsed_time, __pyx_k_Elapsed_time, sizeof(__pyx_k_Elapsed_time), 0, 0, 1, 0}, {&__pyx_kp_s_Epoch, __pyx_k_Epoch, sizeof(__pyx_k_Epoch), 0, 0, 1, 0}, {&__pyx_kp_s_Epoch_loop_end_Optimized_sharp_s, __pyx_k_Epoch_loop_end_Optimized_sharp_s, sizeof(__pyx_k_Epoch_loop_end_Optimized_sharp_s), 0, 0, 1, 0}, {&__pyx_kp_s_Epoch_loop_start_Initial_sharp_s, __pyx_k_Epoch_loop_start_Initial_sharp_s, sizeof(__pyx_k_Epoch_loop_start_Initial_sharp_s), 0, 0, 1, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_kp_s_Shape_s_ratio, __pyx_k_Shape_s_ratio, sizeof(__pyx_k_Shape_s_ratio), 0, 0, 1, 0}, {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_kp_s_Y_m_d_H_M, __pyx_k_Y_m_d_H_M, sizeof(__pyx_k_Y_m_d_H_M), 0, 0, 1, 0}, {&__pyx_kp_s__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 0, 1, 0}, {&__pyx_kp_s__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 0, 1, 0}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_n_s__24, __pyx_k__24, sizeof(__pyx_k__24), 0, 0, 1, 1}, {&__pyx_n_s_abs, __pyx_k_abs, sizeof(__pyx_k_abs), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1}, {&__pyx_n_s_bar, __pyx_k_bar, sizeof(__pyx_k_bar), 0, 0, 1, 1}, {&__pyx_n_s_calc_R, __pyx_k_calc_R, sizeof(__pyx_k_calc_R), 0, 0, 1, 1}, {&__pyx_n_s_calc_dSdw, __pyx_k_calc_dSdw, sizeof(__pyx_k_calc_dSdw), 0, 0, 1, 1}, {&__pyx_n_s_calc_sumR, __pyx_k_calc_sumR, sizeof(__pyx_k_calc_sumR), 0, 0, 1, 1}, {&__pyx_n_s_clock, __pyx_k_clock, sizeof(__pyx_k_clock), 0, 0, 1, 1}, {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, {&__pyx_n_s_cumsum, __pyx_k_cumsum, sizeof(__pyx_k_cumsum), 0, 0, 1, 1}, {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1}, {&__pyx_n_s_diff, __pyx_k_diff, sizeof(__pyx_k_diff), 0, 0, 1, 1}, {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1}, {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, {&__pyx_kp_s_epoch_S_csv, __pyx_k_epoch_S_csv, sizeof(__pyx_k_epoch_S_csv), 0, 0, 1, 0}, {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_grid, __pyx_k_grid, sizeof(__pyx_k_grid), 0, 0, 1, 1}, {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, {&__pyx_n_s_init_t, __pyx_k_init_t, sizeof(__pyx_k_init_t), 0, 0, 1, 1}, {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_matplotlib_pyplot, __pyx_k_matplotlib_pyplot, sizeof(__pyx_k_matplotlib_pyplot), 0, 0, 1, 1}, {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, {&__pyx_n_s_mu, __pyx_k_mu, sizeof(__pyx_k_mu), 0, 0, 1, 1}, {&__pyx_n_s_n_epoch, __pyx_k_n_epoch, sizeof(__pyx_k_n_epoch), 0, 0, 1, 1}, {&__pyx_n_s_n_tick, __pyx_k_n_tick, sizeof(__pyx_k_n_tick), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1}, {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1}, {&__pyx_n_s_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 0, 1, 1}, {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, {&__pyx_n_s_plot_hist, __pyx_k_plot_hist, sizeof(__pyx_k_plot_hist), 0, 0, 1, 1}, {&__pyx_n_s_plt, __pyx_k_plt, sizeof(__pyx_k_plt), 0, 0, 1, 1}, {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_read_csv, __pyx_k_read_csv, sizeof(__pyx_k_read_csv), 0, 0, 1, 1}, {&__pyx_n_s_rho, __pyx_k_rho, sizeof(__pyx_k_rho), 0, 0, 1, 1}, {&__pyx_n_s_rnge, __pyx_k_rnge, sizeof(__pyx_k_rnge), 0, 0, 1, 1}, {&__pyx_kp_s_sec, __pyx_k_sec, sizeof(__pyx_k_sec), 0, 0, 1, 0}, {&__pyx_n_s_set_x_F, __pyx_k_set_x_F, sizeof(__pyx_k_set_x_F), 0, 0, 1, 1}, {&__pyx_n_s_show, __pyx_k_show, sizeof(__pyx_k_show), 0, 0, 1, 1}, {&__pyx_n_s_sigma, __pyx_k_sigma, sizeof(__pyx_k_sigma), 0, 0, 1, 1}, {&__pyx_n_s_sign, __pyx_k_sign, sizeof(__pyx_k_sign), 0, 0, 1, 1}, {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, {&__pyx_n_s_strptime, __pyx_k_strptime, sizeof(__pyx_k_strptime), 0, 0, 1, 1}, {&__pyx_n_s_tanh, __pyx_k_tanh, sizeof(__pyx_k_tanh), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_tick, __pyx_k_tick, sizeof(__pyx_k_tick), 0, 0, 1, 1}, {&__pyx_n_s_tick_center, __pyx_k_tick_center, sizeof(__pyx_k_tick_center), 0, 0, 1, 1}, {&__pyx_n_s_tick_max, __pyx_k_tick_max, sizeof(__pyx_k_tick_max), 0, 0, 1, 1}, {&__pyx_n_s_tick_min, __pyx_k_tick_min, sizeof(__pyx_k_tick_min), 0, 0, 1, 1}, {&__pyx_n_s_tick_val, __pyx_k_tick_val, sizeof(__pyx_k_tick_val), 0, 0, 1, 1}, {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, {&__pyx_n_s_to_csv, __pyx_k_to_csv, sizeof(__pyx_k_to_csv), 0, 0, 1, 1}, {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1}, {&__pyx_n_s_tradingrrl, __pyx_k_tradingrrl, sizeof(__pyx_k_tradingrrl), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_update_w, __pyx_k_update_w, sizeof(__pyx_k_update_w), 0, 0, 1, 1}, {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1}, {&__pyx_kp_s_w_csv, __pyx_k_w_csv, sizeof(__pyx_k_w_csv), 0, 0, 1, 0}, {&__pyx_n_s_where, __pyx_k_where, sizeof(__pyx_k_where), 0, 0, 1, 1}, {&__pyx_n_s_width, __pyx_k_width, sizeof(__pyx_k_width), 0, 0, 1, 1}, {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 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 int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 96, __pyx_L1_error) #if PY_MAJOR_VERSION >= 3 __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) __PYX_ERR(0, 123, __pyx_L1_error) #else __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) __PYX_ERR(0, 123, __pyx_L1_error) #endif __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 258, __pyx_L1_error) __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s_min); if (!__pyx_builtin_min) __PYX_ERR(0, 258, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 989, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "tradingrrl.pyx":73 * self.w = np.ones(M+2, dtype=np.float64) * self.w_opt = np.ones(M+2, dtype=np.float64) * self.epoch_S = np.empty(0, dtype=np.float64) # <<<<<<<<<<<<<< * self.n_epoch = n_epoch * self.progress_period = 100 */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "tradingrrl.pyx":98 * tmp_t = [dt.strptime(tmp_tstr[i], '%Y.%m.%d %H:%M') for i in range(len(tmp_tstr))] * tmp_p = list(tmp[5]) * self.all_t = np.array(tmp_t[::-1]) # <<<<<<<<<<<<<< * self.all_p = np.array(tmp_p[::-1]) * */ __pyx_slice__3 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__3); __Pyx_GIVEREF(__pyx_slice__3); /* "tradingrrl.pyx":99 * tmp_p = list(tmp[5]) * self.all_t = np.array(tmp_t[::-1]) * self.all_p = np.array(tmp_p[::-1]) # <<<<<<<<<<<<<< * * def quant(self, f): */ __pyx_slice__4 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__4); __Pyx_GIVEREF(__pyx_slice__4); /* "tradingrrl.pyx":143 * * def calc_R(self): * self.R = self.mu*(self.F[1:]*self.r[:self.T] - self.sigma*np.abs(-np.diff(self.F))) # <<<<<<<<<<<<<< * * def calc_sumR(self): */ __pyx_slice__5 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5); /* "tradingrrl.pyx":146 * * def calc_sumR(self): * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') # <<<<<<<<<<<<<< * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') * */ __pyx_slice__6 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__6)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__6); __Pyx_GIVEREF(__pyx_slice__6); __pyx_slice__7 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__7)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__7); __Pyx_GIVEREF(__pyx_slice__7); /* "tradingrrl.pyx":147 * def calc_sumR(self): * self.sumR = np.cumsum(self.R[::-1])[::-1].copy(order='C') * self.sumR2 = np.cumsum((self.R**2)[::-1])[::-1].copy(order='C') # <<<<<<<<<<<<<< * * def calc_dSdw(self): */ __pyx_slice__8 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__8)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__8); __Pyx_GIVEREF(__pyx_slice__8); __pyx_slice__9 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__9)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__9); __Pyx_GIVEREF(__pyx_slice__9); /* "tradingrrl.pyx":249 * * def save_weight(self): * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) # <<<<<<<<<<<<<< * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) * */ __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_w_csv); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* "tradingrrl.pyx":250 * def save_weight(self): * pd.DataFrame(self.w).to_csv("w.csv", header=False, index=False) * pd.DataFrame(self.epoch_S).to_csv("epoch_S.csv", header=False, index=False) # <<<<<<<<<<<<<< * * def load_weight(self): */ __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_epoch_S_csv); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* "tradingrrl.pyx":253 * * def load_weight(self): * tmp = pd.read_csv("w.csv", header=None) # <<<<<<<<<<<<<< * self.w = tmp.T.values[0] * */ __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_w_csv); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - <int>(new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":989 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_umath() except -1: */ __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":995 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< * * cdef inline int import_ufunc() except -1: */ __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1001 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< */ __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 1001, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* "tradingrrl.pyx":257 * * * def plot_hist(n_tick, R): # <<<<<<<<<<<<<< * rnge = max(R)-min(R) * tick = rnge/n_tick */ __pyx_tuple__25 = PyTuple_Pack(9, __pyx_n_s_n_tick, __pyx_n_s_R, __pyx_n_s_rnge, __pyx_n_s_tick, __pyx_n_s_tick_min, __pyx_n_s_tick_max, __pyx_n_s_tick_center, __pyx_n_s_tick_val, __pyx_n_s_i); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_Work_Work_Dropbox_Dropbox_Jupy, __pyx_n_s_plot_hist, 257, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_float_0_5 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_float_0_5)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_float_0_04 = PyFloat_FromDouble(0.04); if (unlikely(!__pyx_float_0_04)) __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_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_200 = PyInt_FromLong(200); if (unlikely(!__pyx_int_200)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1000 = PyInt_FromLong(1000); if (unlikely(!__pyx_int_1000)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_10000 = PyInt_FromLong(10000L); if (unlikely(!__pyx_int_10000)) __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; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC inittradingrrl(void); /*proto*/ PyMODINIT_FUNC inittradingrrl(void) #else PyMODINIT_FUNC PyInit_tradingrrl(void); /*proto*/ PyMODINIT_FUNC PyInit_tradingrrl(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_tradingrrl(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) __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_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 PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("tradingrrl", __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) __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) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif 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_tradingrrl) { if (PyObject_SetAttrString(__pyx_m, "__name__", __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, "tradingrrl")) { if (unlikely(PyDict_SetItemString(modules, "tradingrrl", __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 init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_10tradingrrl_TradingRRL) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __pyx_type_10tradingrrl_TradingRRL.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "TradingRRL", (PyObject *)&__pyx_type_10tradingrrl_TradingRRL) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __pyx_ptype_10tradingrrl_TradingRRL = &__pyx_type_10tradingrrl_TradingRRL; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "tradingrrl.pyx":6 * #cython: nonecheck=False * * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * cimport cython */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":13 * ctypedef np.int_t INT_t * * import time # <<<<<<<<<<<<<< * import pickle * import pandas as pd */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_time, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":14 * * import time * import pickle # <<<<<<<<<<<<<< * import pandas as pd * from datetime import datetime as dt */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_pickle, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":15 * import time * import pickle * import pandas as pd # <<<<<<<<<<<<<< * from datetime import datetime as dt * import matplotlib.pyplot as plt */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_pandas, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":16 * import pickle * import pandas as pd * from datetime import datetime as dt # <<<<<<<<<<<<<< * import matplotlib.pyplot as plt * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_datetime); __Pyx_GIVEREF(__pyx_n_s_datetime); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_datetime); __pyx_t_2 = __Pyx_Import(__pyx_n_s_datetime, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_dt, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "tradingrrl.pyx":17 * import pandas as pd * from datetime import datetime as dt * import matplotlib.pyplot as plt # <<<<<<<<<<<<<< * * cdef class TradingRRL(object): */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s__24); __Pyx_GIVEREF(__pyx_n_s__24); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s__24); __pyx_t_1 = __Pyx_Import(__pyx_n_s_matplotlib_pyplot, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_plt, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":257 * * * def plot_hist(n_tick, R): # <<<<<<<<<<<<<< * rnge = max(R)-min(R) * tick = rnge/n_tick */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10tradingrrl_1plot_hist, NULL, __pyx_n_s_tradingrrl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_plot_hist, __pyx_t_1) < 0) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "tradingrrl.pyx":1 * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<< * #cython: boundscheck=False * #cython: wraparound=False */ __pyx_t_1 = PyDict_New(); 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; /* "../../../../../../../Python27/lib/site-packages/Cython/Includes/numpy/__init__.pxd":997 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< * try: * _import_umath() */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init tradingrrl", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init tradingrrl"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #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((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* 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; } /* 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; } /* 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); } /* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS 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 } 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 } 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 } 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 } 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 } 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 } 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 /* 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 /* 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(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } /* GetItemInt */ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_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((n >= 0) & (n < PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) 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)); } /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL #include "frameobject.h" static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = PyThreadState_GET(); 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 = f->f_localsplus; 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 // CPython < 3.6 #endif // CYTHON_FAST_PYCALL /* 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); assert(PyCFunction_Check(func)); assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); 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()); return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); } #endif // CYTHON_FAST_PYCCALL /* 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 #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); #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 /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* SliceObject */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { #if CYTHON_USE_TYPE_SLOTS PyMappingMethods* mp; #if PY_MAJOR_VERSION < 3 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; if (likely(ms && ms->sq_slice)) { if (!has_cstart) { if (_py_start && (*_py_start != Py_None)) { cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstart = 0; } if (!has_cstop) { if (_py_stop && (*_py_stop != Py_None)) { cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstop = PY_SSIZE_T_MAX; } if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { Py_ssize_t l = ms->sq_length(obj); if (likely(l >= 0)) { if (cstop < 0) { cstop += l; if (cstop < 0) cstop = 0; } if (cstart < 0) { cstart += l; if (cstart < 0) cstart = 0; } } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) goto bad; PyErr_Clear(); } } return ms->sq_slice(obj, cstart, cstop); } #endif mp = Py_TYPE(obj)->tp_as_mapping; if (likely(mp && mp->mp_subscript)) #endif { PyObject* result; PyObject *py_slice, *py_start, *py_stop; if (_py_slice) { py_slice = *_py_slice; } else { PyObject* owned_start = NULL; PyObject* owned_stop = NULL; if (_py_start) { py_start = *_py_start; } else { if (has_cstart) { owned_start = py_start = PyInt_FromSsize_t(cstart); if (unlikely(!py_start)) goto bad; } else py_start = Py_None; } if (_py_stop) { py_stop = *_py_stop; } else { if (has_cstop) { owned_stop = py_stop = PyInt_FromSsize_t(cstop); if (unlikely(!py_stop)) { Py_XDECREF(owned_start); goto bad; } } else py_stop = Py_None; } py_slice = PySlice_New(py_start, py_stop, Py_None); Py_XDECREF(owned_start); Py_XDECREF(owned_stop); if (unlikely(!py_slice)) goto bad; } #if CYTHON_USE_TYPE_SLOTS result = mp->mp_subscript(obj, py_slice); #else result = PyObject_GetItem(obj, py_slice); #endif if (!_py_slice) { Py_DECREF(py_slice); } return result; } PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); bad: return NULL; } /* BufferFormatCheck */ static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { unsigned int n = 1; return *(unsigned char*)(&n) != 0; } static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, __Pyx_BufFmt_StackElem* stack, __Pyx_TypeInfo* type) { stack[0].field = &ctx->root; stack[0].parent_offset = 0; ctx->root.type = type; ctx->root.name = "buffer dtype"; ctx->root.offset = 0; ctx->head = stack; ctx->head->field = &ctx->root; ctx->fmt_offset = 0; ctx->head->parent_offset = 0; ctx->new_packmode = '@'; ctx->enc_packmode = '@'; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->is_complex = 0; ctx->is_valid_array = 0; ctx->struct_alignment = 0; while (type->typegroup == 'S') { ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = 0; type = type->fields->type; } } static int __Pyx_BufFmt_ParseNumber(const char** ts) { int count; const char* t = *ts; if (*t < '0' || *t > '9') { return -1; } else { count = *t++ - '0'; while (*t >= '0' && *t < '9') { count *= 10; count += *t++ - '0'; } } *ts = t; return count; } static int __Pyx_BufFmt_ExpectNumber(const char **ts) { int number = __Pyx_BufFmt_ParseNumber(ts); if (number == -1) PyErr_Format(PyExc_ValueError,\ "Does not understand character buffer dtype format string ('%c')", **ts); return number; } static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%c'", ch); } static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { switch (ch) { case 'c': return "'char'"; case 'b': return "'signed char'"; case 'B': return "'unsigned char'"; case 'h': return "'short'"; case 'H': return "'unsigned short'"; case 'i': return "'int'"; case 'I': return "'unsigned int'"; case 'l': return "'long'"; case 'L': return "'unsigned long'"; case 'q': return "'long long'"; case 'Q': return "'unsigned long long'"; case 'f': return (is_complex ? "'complex float'" : "'float'"); case 'd': return (is_complex ? "'complex double'" : "'double'"); case 'g': return (is_complex ? "'complex long double'" : "'long double'"); case 'T': return "a struct"; case 'O': return "Python object"; case 'P': return "a pointer"; case 's': case 'p': return "a string"; case 0: return "end"; default: return "unparseable format string"; } } static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return 2; case 'i': case 'I': case 'l': case 'L': return 4; case 'q': case 'Q': return 8; case 'f': return (is_complex ? 8 : 4); case 'd': return (is_complex ? 16 : 8); case 'g': { PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); return 0; } case 'O': case 'P': return sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { switch (ch) { case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(short); case 'i': case 'I': return sizeof(int); case 'l': case 'L': return sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(float) * (is_complex ? 2 : 1); case 'd': return sizeof(double) * (is_complex ? 2 : 1); case 'g': return sizeof(long double) * (is_complex ? 2 : 1); case 'O': case 'P': return sizeof(void*); default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } typedef struct { char c; short x; } __Pyx_st_short; typedef struct { char c; int x; } __Pyx_st_int; typedef struct { char c; long x; } __Pyx_st_long; typedef struct { char c; float x; } __Pyx_st_float; typedef struct { char c; double x; } __Pyx_st_double; typedef struct { char c; long double x; } __Pyx_st_longdouble; typedef struct { char c; void *x; } __Pyx_st_void_p; #ifdef HAVE_LONG_LONG typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_st_float) - sizeof(float); case 'd': return sizeof(__Pyx_st_double) - sizeof(double); case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } /* These are for computing the padding at the end of the struct to align on the first member of the struct. This will probably the same as above, but we don't have any guarantees. */ typedef struct { short x; char c; } __Pyx_pad_short; typedef struct { int x; char c; } __Pyx_pad_int; typedef struct { long x; char c; } __Pyx_pad_long; typedef struct { float x; char c; } __Pyx_pad_float; typedef struct { double x; char c; } __Pyx_pad_double; typedef struct { long double x; char c; } __Pyx_pad_longdouble; typedef struct { void *x; char c; } __Pyx_pad_void_p; #ifdef HAVE_LONG_LONG typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; #endif static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { switch (ch) { case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); #ifdef HAVE_LONG_LONG case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); #endif case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); default: __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { switch (ch) { case 'c': return 'H'; case 'b': case 'h': case 'i': case 'l': case 'q': case 's': case 'p': return 'I'; case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U'; case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R'); case 'O': return 'O'; case 'P': return 'P'; default: { __Pyx_BufFmt_RaiseUnexpectedChar(ch); return 0; } } } static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { if (ctx->head == NULL || ctx->head->field == &ctx->root) { const char* expected; const char* quote; if (ctx->head == NULL) { expected = "end"; quote = ""; } else { expected = ctx->head->field->type->name; quote = "'"; } PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected %s%s%s but got %s", quote, expected, quote, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); } else { __Pyx_StructField* field = ctx->head->field; __Pyx_StructField* parent = (ctx->head - 1)->field; PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), parent->type->name, field->name); } } static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { char group; size_t size, offset, arraysize = 1; if (ctx->enc_type == 0) return 0; if (ctx->head->field->type->arraysize[0]) { int i, ndim = 0; if (ctx->enc_type == 's' || ctx->enc_type == 'p') { ctx->is_valid_array = ctx->head->field->type->ndim == 1; ndim = 1; if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %zu", ctx->head->field->type->arraysize[0], ctx->enc_count); return -1; } } if (!ctx->is_valid_array) { PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", ctx->head->field->type->ndim, ndim); return -1; } for (i = 0; i < ctx->head->field->type->ndim; i++) { arraysize *= ctx->head->field->type->arraysize[i]; } ctx->is_valid_array = 0; ctx->enc_count = 1; } group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); do { __Pyx_StructField* field = ctx->head->field; __Pyx_TypeInfo* type = field->type; if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); } else { size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); } if (ctx->enc_packmode == '@') { size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); size_t align_mod_offset; if (align_at == 0) return -1; align_mod_offset = ctx->fmt_offset % align_at; if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; if (ctx->struct_alignment == 0) ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, ctx->is_complex); } if (type->size != size || type->typegroup != group) { if (type->typegroup == 'C' && type->fields != NULL) { size_t parent_offset = ctx->head->parent_offset + field->offset; ++ctx->head; ctx->head->field = type->fields; ctx->head->parent_offset = parent_offset; continue; } if ((type->typegroup == 'H' || group == 'H') && type->size == size) { } else { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } } offset = ctx->head->parent_offset + field->offset; if (ctx->fmt_offset != offset) { PyErr_Format(PyExc_ValueError, "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); return -1; } ctx->fmt_offset += size; if (arraysize) ctx->fmt_offset += (arraysize - 1) * size; --ctx->enc_count; while (1) { if (field == &ctx->root) { ctx->head = NULL; if (ctx->enc_count != 0) { __Pyx_BufFmt_RaiseExpected(ctx); return -1; } break; } ctx->head->field = ++field; if (field->type == NULL) { --ctx->head; field = ctx->head->field; continue; } else if (field->type->typegroup == 'S') { size_t parent_offset = ctx->head->parent_offset + field->offset; if (field->type->fields->type == NULL) continue; field = field->type->fields; ++ctx->head; ctx->head->field = field; ctx->head->parent_offset = parent_offset; break; } else { break; } } } while (ctx->enc_count); ctx->enc_type = 0; ctx->is_complex = 0; return 0; } static CYTHON_INLINE PyObject * __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) { const char *ts = *tsp; int i = 0, number; int ndim = ctx->head->field->type->ndim; ; ++ts; if (ctx->new_count != 1) { PyErr_SetString(PyExc_ValueError, "Cannot handle repeated arrays in format string"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; while (*ts && *ts != ')') { switch (*ts) { case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; default: break; } number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) return PyErr_Format(PyExc_ValueError, "Expected a dimension of size %zu, got %d", ctx->head->field->type->arraysize[i], number); if (*ts != ',' && *ts != ')') return PyErr_Format(PyExc_ValueError, "Expected a comma in format string, got '%c'", *ts); if (*ts == ',') ts++; i++; } if (i != ndim) return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", ctx->head->field->type->ndim, i); if (!*ts) { PyErr_SetString(PyExc_ValueError, "Unexpected end of format string, expected ')'"); return NULL; } ctx->is_valid_array = 1; ctx->new_count = 1; *tsp = ++ts; return Py_None; } static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { int got_Z = 0; while (1) { switch(*ts) { case 0: if (ctx->enc_type != 0 && ctx->head == NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; if (ctx->head != NULL) { __Pyx_BufFmt_RaiseExpected(ctx); return NULL; } return ts; case ' ': case '\r': case '\n': ++ts; break; case '<': if (!__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '>': case '!': if (__Pyx_IsLittleEndian()) { PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); return NULL; } ctx->new_packmode = '='; ++ts; break; case '=': case '@': case '^': ctx->new_packmode = *ts++; break; case 'T': { const char* ts_after_sub; size_t i, struct_count = ctx->new_count; size_t struct_alignment = ctx->struct_alignment; ctx->new_count = 1; ++ts; if (*ts != '{') { PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); return NULL; } if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; ctx->enc_count = 0; ctx->struct_alignment = 0; ++ts; ts_after_sub = ts; for (i = 0; i != struct_count; ++i) { ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); if (!ts_after_sub) return NULL; } ts = ts_after_sub; if (struct_alignment) ctx->struct_alignment = struct_alignment; } break; case '}': { size_t alignment = ctx->struct_alignment; ++ts; if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_type = 0; if (alignment && ctx->fmt_offset % alignment) { ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); } } return ts; case 'x': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->fmt_offset += ctx->new_count; ctx->new_count = 1; ctx->enc_count = 0; ctx->enc_type = 0; ctx->enc_packmode = ctx->new_packmode; ++ts; break; case 'Z': got_Z = 1; ++ts; if (*ts != 'f' && *ts != 'd' && *ts != 'g') { __Pyx_BufFmt_RaiseUnexpectedChar('Z'); return NULL; } case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': case 'l': case 'L': case 'q': case 'Q': case 'f': case 'd': case 'g': case 'O': case 'p': if (ctx->enc_type == *ts && got_Z == ctx->is_complex && ctx->enc_packmode == ctx->new_packmode) { ctx->enc_count += ctx->new_count; ctx->new_count = 1; got_Z = 0; ++ts; break; } case 's': if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; ctx->enc_count = ctx->new_count; ctx->enc_packmode = ctx->new_packmode; ctx->enc_type = *ts; ctx->is_complex = got_Z; ++ts; ctx->new_count = 1; got_Z = 0; break; case ':': ++ts; while(*ts != ':') ++ts; ++ts; break; case '(': if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; break; default: { int number = __Pyx_BufFmt_ExpectNumber(&ts); if (number == -1) return NULL; ctx->new_count = (size_t)number; } } } } static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { buf->buf = NULL; buf->obj = NULL; buf->strides = __Pyx_zeros; buf->shape = __Pyx_zeros; buf->suboffsets = __Pyx_minusones; } static CYTHON_INLINE int __Pyx_GetBufferAndValidate( Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) { if (obj == Py_None || obj == NULL) { __Pyx_ZeroBuffer(buf); return 0; } buf->buf = NULL; if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; if (buf->ndim != nd) { PyErr_Format(PyExc_ValueError, "Buffer has wrong number of dimensions (expected %d, got %d)", nd, buf->ndim); goto fail; } if (!cast) { __Pyx_BufFmt_Context ctx; __Pyx_BufFmt_Init(&ctx, stack, dtype); if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; } if ((unsigned)buf->itemsize != dtype->size) { PyErr_Format(PyExc_ValueError, "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", buf->itemsize, (buf->itemsize > 1) ? "s" : "", dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); goto fail; } if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; return 0; fail:; __Pyx_ZeroBuffer(buf); return -1; } static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { if (info->buf == NULL) return; if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; __Pyx_ReleaseBuffer(info); } /* BufferFallbackError */ static void __Pyx_RaiseBufferFallbackError(void) { PyErr_SetString(PyExc_ValueError, "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); } /* SetItemInt */ static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (!j) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { PyObject* old = PyList_GET_ITEM(o, n); Py_INCREF(v); PyList_SET_ITEM(o, n, v); Py_DECREF(old); return 1; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_ass_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return -1; PyErr_Clear(); } } return m->sq_ass_item(o, i, v); } } #else #if CYTHON_COMPILING_IN_PYPY if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { #else if (is_list || PySequence_Check(o)) { #endif return PySequence_SetItem(o, i, v); } #endif return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); } /* 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 /* None */ static CYTHON_INLINE int __Pyx_mod_int(int a, int b) { int r = a % b; r += ((r != 0) & ((r ^ b) < 0)) * b; return r; } /* 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 PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* 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"); } /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; 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; tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE 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; return PyErr_GivenExceptionMatches(exc_type, err); } #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 tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* 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_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* 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; } /* 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; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __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 (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__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 (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } Py_DECREF(obj); view->obj = NULL; } #endif /* 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;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #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); } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #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); } } /* Print */ #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 static PyObject *__Pyx_GetStdout(void) { PyObject *f = PySys_GetObject((char *)"stdout"); if (!f) { PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); } return f; } static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { int i; if (!f) { if (!(f = __Pyx_GetStdout())) return -1; } Py_INCREF(f); for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { PyObject* v; if (PyFile_SoftSpace(f, 1)) { if (PyFile_WriteString(" ", f) < 0) goto error; } v = PyTuple_GET_ITEM(arg_tuple, i); if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) goto error; if (PyString_Check(v)) { char *s = PyString_AsString(v); Py_ssize_t len = PyString_Size(v); if (len > 0) { switch (s[len-1]) { case ' ': break; case '\f': case '\r': case '\n': case '\t': case '\v': PyFile_SoftSpace(f, 0); break; default: break; } } } } if (newline) { if (PyFile_WriteString("\n", f) < 0) goto error; PyFile_SoftSpace(f, 0); } Py_DECREF(f); return 0; error: Py_DECREF(f); return -1; } #else static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { PyObject* kwargs = 0; PyObject* result = 0; PyObject* end_string; if (unlikely(!__pyx_print)) { __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); if (!__pyx_print) return -1; } if (stream) { kwargs = PyDict_New(); if (unlikely(!kwargs)) return -1; if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) goto bad; if (!newline) { end_string = PyUnicode_FromStringAndSize(" ", 1); if (unlikely(!end_string)) goto bad; if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { Py_DECREF(end_string); goto bad; } Py_DECREF(end_string); } } else if (!newline) { if (unlikely(!__pyx_print_kwargs)) { __pyx_print_kwargs = PyDict_New(); if (unlikely(!__pyx_print_kwargs)) return -1; end_string = PyUnicode_FromStringAndSize(" ", 1); if (unlikely(!end_string)) return -1; if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { Py_DECREF(end_string); return -1; } Py_DECREF(end_string); } kwargs = __pyx_print_kwargs; } result = PyObject_Call(__pyx_print, arg_tuple, kwargs); if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) Py_DECREF(kwargs); if (!result) return -1; Py_DECREF(result); return 0; bad: if (kwargs != __pyx_print_kwargs) Py_XDECREF(kwargs); return -1; } #endif /* 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 = 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 = 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, -1); } } 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 = 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 = 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, -1); } } 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 /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(enum NPY_TYPES) <= 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(enum NPY_TYPES), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #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; } /* PrintOne */ #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 static int __Pyx_PrintOne(PyObject* f, PyObject *o) { if (!f) { if (!(f = __Pyx_GetStdout())) return -1; } Py_INCREF(f); if (PyFile_SoftSpace(f, 0)) { if (PyFile_WriteString(" ", f) < 0) goto error; } if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) goto error; if (PyFile_WriteString("\n", f) < 0) goto error; Py_DECREF(f); return 0; error: Py_DECREF(f); return -1; /* the line below is just to avoid C compiler * warnings about unused functions */ return __Pyx_Print(f, NULL, 0); } #else static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { int res; PyObject* arg_tuple = PyTuple_Pack(1, o); if (unlikely(!arg_tuple)) return -1; res = __Pyx_Print(stream, arg_tuple, 1); Py_DECREF(arg_tuple); return res; } #endif /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #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; } /* 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; } /* ModuleImport */ #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", module_name, class_name, basicsize, size); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", module_name, class_name, basicsize, size); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #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; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); #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 = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif #else res = PyNumber_Int(x); #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */
jehung/universal_portfolio
universal_portfolio/rrl_trading/04_cython_cppwraper/test/cpp_test_sum_.h
<reponame>jehung/universal_portfolio #ifndef CPPTESTSUM_H #define CPPTESTSUM_H #include <vector> using namespace std; namespace cpp_test_sum{ class cppTestSum{ public: int n_iter; vector<double> sum; // Constructor cppTestSum(int n_iter); // Destructor ~cppTestSum(); // Menber function void calc_sum(); }; } #endif
wosta/Music
QQMusic/Classes/Tool/ZWMusicTool.h
<reponame>wosta/Music // // ZWMusicTool.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> #import "ZWMusicModel.h" @interface ZWMusicTool : NSObject /* 因为音乐播放不仅仅在当前控制器会使用,还会在其他控制器中进行切换,所以要封装成工具类 */ /** 所有音乐 */ + (NSArray *)musics; /* 正在播放的音乐 */ +(ZWMusicModel *)playingMusic; /************* 设置默认播放的音乐 */ +(void)setupPlayingMusic:(ZWMusicModel *)playingMusic; /*返回上一首音乐*/ + (ZWMusicModel *)previousMusic; /*返回下一首音乐*/ + (ZWMusicModel *)nextMusic; @end
wosta/Music
QQMusic/Classes/C/ZWPlayViewController.h
// // ZWPlayViewController.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <UIKit/UIKit.h> @interface ZWPlayViewController : UIViewController @end
wosta/Music
QQMusic/Classes/V/ZWLrcCell.h
// // ZWLrcCell.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <UIKit/UIKit.h> #import "ZWLrcLabel.h" @interface ZWLrcCell : UITableViewCell @property(nonatomic,strong)ZWLrcLabel *lrcLabel; + (instancetype)lrcCellWithTableView:(UITableView *)tableView; @end
wosta/Music
QQMusic/Classes/M/ZWMusicModel.h
<reponame>wosta/Music<filename>QQMusic/Classes/M/ZWMusicModel.h<gh_stars>0 // // ZWMusicModel.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> @interface ZWMusicModel : NSObject @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *filename; @property (nonatomic, copy) NSString *lrcname; @property (nonatomic, copy) NSString *singer; @property (nonatomic, copy) NSString *singerIcon; @property (nonatomic, copy) NSString *icon; - (instancetype)initWithDict:(NSDictionary *)dic; @end
wosta/Music
QQMusic/Classes/NSString+ZWTime.h
<gh_stars>0 // // NSString+ZWTime.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> @interface NSString (ZWTime) + (NSString *)stringWithTime:(NSTimeInterval)time; @end
wosta/Music
QQMusic/Classes/V/ZWLrcLabel.h
// // ZWLrcLabel.h // QQMusic // // Created by 郑亚伟 on 2016/12/30. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <UIKit/UIKit.h> @interface ZWLrcLabel : UILabel /*当前播放的进度*/ @property(nonatomic,assign)CGFloat progress; @end
wosta/Music
QQMusic/Classes/V/ZWLrcScrollView.h
<filename>QQMusic/Classes/V/ZWLrcScrollView.h<gh_stars>0 // // ZWLrcScrollView.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <UIKit/UIKit.h> #import "ZWLrcLabel.h" @interface ZWLrcScrollView : UIScrollView<UITableViewDelegate,UITableViewDataSource> /*歌词名*/ @property(nonatomic,copy)NSString *lrcName; /*当前播放器播放时间*/ @property(nonatomic,assign)NSTimeInterval currentTime; /*记录当前刷新的是哪一行*/ @property(nonatomic,assign)NSInteger currentIndex; @property(nonatomic,weak)ZWLrcLabel *lrcLabel; /** 当前播放器总时间时间 */ @property (nonatomic, assign) NSTimeInterval duration; @end
wosta/Music
QQMusic/Classes/Tool/ZWLrcTool.h
// // ZWLrcTool.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> @interface ZWLrcTool : NSObject +(NSArray *)lrcToolWithLrcName:(NSString *)lrcName; @end
wosta/Music
QQMusic/Classes/Tool/ZWAudioTool.h
// // ZWAudioTool.h // 02-播放音效 // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> #import <AVFoundation/AVFoundation.h> @interface ZWAudioTool : NSObject // 播放音乐 fileName:音乐文件 + (AVAudioPlayer *)playMusicWithFileName:(NSString *)fileName; // 暂停音乐 fileName:音乐文件 + (void)pauseMusicWithFileName:(NSString *)fileName; // 停止音乐 fileName:音乐文件 + (void)stopMusicWithFileName:(NSString *)fileName; // 播放音效 soundName:音效文件 + (void)playSoundWithSoundName:(NSString *)soundName; @end
wosta/Music
QQMusic/Classes/M/ZWLrcModel.h
// // ZWLrcModel.h // QQMusic // // Created by 郑亚伟 on 2016/12/29. // Copyright © 2016年 郑亚伟. All rights reserved. // #import <Foundation/Foundation.h> @interface ZWLrcModel : NSObject @property(nonatomic,copy)NSString *text; @property(nonatomic,assign)NSTimeInterval time; - (instancetype)initWithLrcLineString:(NSString *)lrcLineString; + (instancetype)lrcLineString:(NSString *)lrcLineString; @end
wosta/Music
QQMusic/Classes/CALayer+PauseAimate.h
<gh_stars>0 // // CALayer+PauseAimate.h // QQ // // Created by apple on 16/8/14. // Copyright (c) 2016年 郑亚伟. All rights reserved. // #import <QuartzCore/QuartzCore.h> @interface CALayer (PauseAimate) // 暂停动画 - (void)pauseAnimate; // 恢复动画 - (void)resumeAnimate; @end
imastio/shoc
assets/samples-mpi/quad.c
# include <math.h> # include <mpi.h> # include <stdio.h> # include <stdlib.h> # include <time.h> int main ( int argc, char *argv[] ); double f ( double x ); void timestamp ( ); /******************************************************************************/ int main ( int argc, char *argv[] ) /******************************************************************************/ /* Purpose: MAIN is the main program for QUAD_MPI. Licensing: This code is distributed under the GNU LGPL license. Modified: 19 July 2010 Author: <NAME> */ { double a; double b; double error; double exact; int i; int master = 0; double my_a; double my_b; int my_id; int my_n; double my_total; int n; int p; int p_num; int source; MPI_Status status; int tag; int target; double total; double wtime; double x; a = 0.0; b = 10.0; n = 10000000; exact = 0.49936338107645674464; /* Initialize MPI. */ MPI_Init ( &argc, &argv ); /* Get this processor's ID. */ MPI_Comm_rank ( MPI_COMM_WORLD, &my_id ); /* Get the number of processes. */ MPI_Comm_size ( MPI_COMM_WORLD, &p_num ); if ( my_id == master ) { /* We want N to be the total number of evaluations. If necessary, we adjust N to be divisible by the number of processes. */ my_n = n / ( p_num - 1 ); n = ( p_num - 1 ) * my_n; wtime = MPI_Wtime ( ); timestamp ( ); printf ( "\n" ); printf ( "QUAD_MPI\n" ); printf ( " C/MPI version\n" ); printf ( " Estimate an integral of f(x) from A to B.\n" ); printf ( " f(x) = 50 / (pi * ( 2500 * x * x + 1 ) )\n" ); printf ( "\n" ); printf ( " A = %f\n", a ); printf ( " B = %f\n", b ); printf ( " N = %d\n", n ); printf ( " EXACT = %24.16f\n", exact ); printf ( "\n" ); printf ( " Use MPI to divide the computation among\n" ); printf ( " multiple processes.\n" ); } source = master; MPI_Bcast ( &my_n, 1, MPI_INT, source, MPI_COMM_WORLD ); /* Process 0 assigns each process a subinterval of [A,B]. */ if ( my_id == master ) { for ( p = 1; p <= p_num - 1; p++ ) { my_a = ( ( double ) ( p_num - p ) * a + ( double ) ( p - 1 ) * b ) / ( double ) ( p_num - 1 ); target = p; tag = 1; MPI_Send ( &my_a, 1, MPI_DOUBLE, target, tag, MPI_COMM_WORLD ); my_b = ( ( double ) ( p_num - p - 1 ) * a + ( double ) ( p ) * b ) / ( double ) ( p_num - 1 ); target = p; tag = 2; MPI_Send ( &my_b, 1, MPI_DOUBLE, target, tag, MPI_COMM_WORLD ); } total = 0.0; my_total = 0.0; } /* Processes receive MY_A, MY_B, and compute their part of the integral. */ else { source = master; tag = 1; MPI_Recv ( &my_a, 1, MPI_DOUBLE, source, tag, MPI_COMM_WORLD, &status ); source = master; tag = 2; MPI_Recv ( &my_b, 1, MPI_DOUBLE, source, tag, MPI_COMM_WORLD, &status ); my_total = 0.0; for ( i = 1; i <= my_n; i++ ) { x = ( ( double ) ( my_n - i ) * my_a + ( double ) ( i - 1 ) * my_b ) / ( double ) ( my_n - 1 ); my_total = my_total + f ( x ); } my_total = ( my_b - my_a ) * my_total / ( double ) ( my_n ); printf ( " Process %d contributed MY_TOTAL = %f\n", my_id, my_total ); } /* Each process sends its value to the master process. */ MPI_Reduce ( &my_total, &total, 1, MPI_DOUBLE, MPI_SUM, master, MPI_COMM_WORLD ); /* Compute the weighted estimate. */ if ( my_id == master ) { error = fabs ( total - exact ); wtime = MPI_Wtime ( ) - wtime; printf ( "\n" ); printf ( " Estimate = %24.16f\n", total ); printf ( " Error = %e\n\n", error ); printf ( " Time = %f\n\n", wtime ); } /* Terminate MPI. */ MPI_Finalize ( ); /* Terminate. */ if ( my_id == master ) { printf ( "\n" ); printf ( "QUAD_MPI:\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); } return 0; } /******************************************************************************/ double f ( double x ) /******************************************************************************/ /* Purpose: F evaluates the function. */ { double pi; double value; pi = 3.141592653589793; value = 50.0 / ( pi * ( 2500.0 * x * x + 1.0 ) ); return value; } /******************************************************************************/ void timestamp ( void ) /******************************************************************************/ /* Purpose: TIMESTAMP prints the current YMDHMS date as a time stamp. Example: 31 May 2001 09:45:54 AM Licensing: This code is distributed under the GNU LGPL license. Modified: 24 September 2003 Author: <NAME> Parameters: None */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }
houxinbing/WZFPSKit
Example/WZFPSKit/SGViewController.h
// // SGViewController.h // WZFPSKit // // Created by <EMAIL> on 03/17/2020. // Copyright (c) 2020 <EMAIL>. All rights reserved. // @import UIKit; @interface SGViewController : UIViewController @end
houxinbing/WZFPSKit
WZFPSKit/Classes/SGAlertSheet.h
// // SGAlertSheet.h // FPS // // Created by sungrow on 2020/3/17. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN typedef enum : NSUInteger { SGAlertSheetTypeNormal = 0, SGAlertSheetTypeCancelButton,//默认有取消按钮且在最下面 } SGAlertSheetType; @class SGAlertSheet; typedef void(^SGAlertSheetHandler) (SGAlertSheet *alertView); @interface SGAlertSheet : UIView /** 标题文字颜色*/ @property (nonatomic ,strong) UIColor *titleTextColor; /** 内容文字颜色*/ @property (nonatomic ,strong) UIColor *messageTextColor; /** cancleButtonColor*/ @property (nonatomic ,strong) UIColor *cancleButtonColor; /** cancleButtonTextColor*/ @property (nonatomic ,strong) UIColor *cancleButtonTextColor; /** cancleButtonText */ @property (nonatomic, copy) NSString *cancleButtonText; /** 取消按钮与下方是否有间隙*/ @property (nonatomic ,assign) SGAlertSheetType type; /** 是否有icon */ @property (nonatomic, assign) BOOL isIcon; @property (nonatomic, strong, readonly) UIImageView *iconImgView; /** title-- 标题*/ @property (nonatomic ,copy) NSString *title; /** 内容*/ @property (nonatomic ,copy) NSString *message; - (instancetype)initWithTitle:(NSString *)title andMessage:(NSString *)message; - (void)addSheetWithTitle:(NSString *)title color:(UIColor *)color handler:(SGAlertSheetHandler )handler; - (void)show; - (void)dismiss; @end NS_ASSUME_NONNULL_END
sethcoder/cc65
testcode/lib/strnicmp-test.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <conio.h> static int do_test(const char *s1, const char *s2, size_t n) { printf("strnicmp(\"%s\", \"%s\", %d): ", s1, s2, (int)n); return strncasecmp(s1, s2, n); } int main(void) { int ret; ret = do_test("Wurzl", "wURZL", 5); if (ret) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("Wurzl", "wURZL", 6); if (ret) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("Wurzl", "wURZL", 10); if (ret) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("Wurzla", "wURZLB", 10); if (ret >= 0) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("Wurzla", "wURZLb", 5); if (ret) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("BLI", "bla", 5); if (ret <= 0) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("", "bla", 5); if (ret >= 0) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("BLI", "", 5); if (ret <= 0) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); ret = do_test("", "", 5); if (ret) printf("fail (%d)\n", ret); else printf("OK (%d)\n", ret); cgetc(); return 0; }
sethcoder/cc65
src/cc65/function.c
/*****************************************************************************/ /* */ /* function.c */ /* */ /* Parse function entry/body/exit */ /* */ /* */ /* */ /* (C) 2000-2015, <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* common */ #include "check.h" #include "xmalloc.h" /* cc65 */ #include "asmcode.h" #include "asmlabel.h" #include "codegen.h" #include "error.h" #include "funcdesc.h" #include "global.h" #include "litpool.h" #include "locals.h" #include "scanner.h" #include "stackptr.h" #include "standard.h" #include "stmt.h" #include "symtab.h" #include "function.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* Pointer to current function */ Function* CurrentFunc = 0; /*****************************************************************************/ /* Subroutines working with struct Function */ /*****************************************************************************/ static Function* NewFunction (struct SymEntry* Sym) /* Create a new function activation structure and return it */ { /* Allocate a new structure */ Function* F = (Function*) xmalloc (sizeof (Function)); /* Initialize the fields */ F->FuncEntry = Sym; F->ReturnType = GetFuncReturn (Sym->Type); F->Desc = GetFuncDesc (Sym->Type); F->Reserved = 0; F->RetLab = GetLocalLabel (); F->TopLevelSP = 0; F->RegOffs = RegisterSpace; F->Flags = IsTypeVoid (F->ReturnType) ? FF_VOID_RETURN : FF_NONE; InitCollection (&F->LocalsBlockStack); /* Return the new structure */ return F; } static void FreeFunction (Function* F) /* Free a function activation structure */ { DoneCollection (&F->LocalsBlockStack); xfree (F); } const char* F_GetFuncName (const Function* F) /* Return the name of the current function */ { return F->FuncEntry->Name; } unsigned F_GetParamCount (const Function* F) /* Return the parameter count for the current function */ { return F->Desc->ParamCount; } unsigned F_GetParamSize (const Function* F) /* Return the parameter size for the current function */ { return F->Desc->ParamSize; } Type* F_GetReturnType (Function* F) /* Get the return type for the function */ { return F->ReturnType; } int F_HasVoidReturn (const Function* F) /* Return true if the function does not have a return value */ { return (F->Flags & FF_VOID_RETURN) != 0; } void F_ReturnFound (Function* F) /* Mark the function as having a return statement */ { F->Flags |= FF_HAS_RETURN; } int F_HasReturn (const Function* F) /* Return true if the function contains a return statement*/ { return (F->Flags & FF_HAS_RETURN) != 0; } int F_IsMainFunc (const Function* F) /* Return true if this is the main function */ { return (F->Flags & FF_IS_MAIN) != 0; } int F_IsVariadic (const Function* F) /* Return true if this is a variadic function */ { return (F->Desc->Flags & FD_VARIADIC) != 0; } int F_IsOldStyle (const Function* F) /* Return true if this is an old style (K&R) function */ { return (F->Desc->Flags & FD_OLDSTYLE) != 0; } int F_HasOldStyleIntRet (const Function* F) /* Return true if this is an old style (K&R) function with an implicit int return */ { return (F->Desc->Flags & FD_OLDSTYLE_INTRET) != 0; } unsigned F_GetRetLab (const Function* F) /* Return the return jump label */ { return F->RetLab; } int F_GetTopLevelSP (const Function* F) /* Get the value of the stack pointer on function top level */ { return F->TopLevelSP; } int F_ReserveLocalSpace (Function* F, unsigned Size) /* Reserve (but don't allocate) the given local space and return the stack ** offset. */ { F->Reserved += Size; return StackPtr - F->Reserved; } int F_GetStackPtr (const Function* F) /* Return the current stack pointer including reserved (but not allocated) ** space on the stack. */ { return StackPtr - F->Reserved; } void F_AllocLocalSpace (Function* F) /* Allocate any local space previously reserved. The function will do ** nothing if there is no reserved local space. */ { if (F->Reserved > 0) { /* Create space on the stack */ g_space (F->Reserved); /* Correct the stack pointer */ StackPtr -= F->Reserved; /* Nothing more reserved */ F->Reserved = 0; } } int F_AllocRegVar (Function* F, const Type* Type) /* Allocate a register variable for the given variable type. If the allocation ** was successful, return the offset of the register variable in the register ** bank (zero page storage). If there is no register space left, return -1. */ { /* Allow register variables only on top level and if enabled */ if (IS_Get (&EnableRegVars) && GetLexicalLevel () == LEX_LEVEL_FUNCTION) { /* Get the size of the variable */ unsigned Size = CheckedSizeOf (Type); /* Do we have space left? */ if (F->RegOffs >= Size) { /* Space left. We allocate the variables from high to low addresses, ** so the addressing is compatible with the saved values on stack. ** This allows shorter code when saving/restoring the variables. */ F->RegOffs -= Size; return F->RegOffs; } } /* No space left or no allocation */ return -1; } static void F_RestoreRegVars (Function* F) /* Restore the register variables for the local function if there are any. */ { const SymEntry* Sym; /* If we don't have register variables in this function, bail out early */ if (F->RegOffs == RegisterSpace) { return; } /* Save the accumulator if needed */ if (!F_HasVoidReturn (F)) { g_save (CF_CHAR | CF_FORCECHAR); } /* Get the first symbol from the function symbol table */ Sym = F->FuncEntry->V.F.Func->SymTab->SymHead; /* Walk through all symbols checking for register variables */ while (Sym) { if (SymIsRegVar (Sym)) { /* Check for more than one variable */ int Offs = Sym->V.R.SaveOffs; unsigned Bytes = CheckedSizeOf (Sym->Type); while (1) { /* Find next register variable */ const SymEntry* NextSym = Sym->NextSym; while (NextSym && !SymIsRegVar (NextSym)) { NextSym = NextSym->NextSym; } /* If we have a next one, compare the stack offsets */ if (NextSym) { /* We have a following register variable. Get the size */ int Size = CheckedSizeOf (NextSym->Type); /* Adjacent variable? */ if (NextSym->V.R.SaveOffs + Size != Offs) { /* No */ break; } /* Adjacent variable */ Bytes += Size; Offs -= Size; Sym = NextSym; } else { break; } } /* Restore the memory range */ g_restore_regvars (Offs, Sym->V.R.RegOffs, Bytes); } /* Check next symbol */ Sym = Sym->NextSym; } /* Restore the accumulator if needed */ if (!F_HasVoidReturn (F)) { g_restore (CF_CHAR | CF_FORCECHAR); } } static void F_EmitDebugInfo (void) /* Emit debug infos for the current function */ { if (DebugInfo) { /* Get the current function */ const SymEntry* Sym = CurrentFunc->FuncEntry; /* Output info for the function itself */ AddTextLine ("\t.dbg\tfunc, \"%s\", \"00\", %s, \"%s\"", Sym->Name, (Sym->Flags & SC_EXTERN)? "extern" : "static", Sym->AsmName); } } /*****************************************************************************/ /* code */ /*****************************************************************************/ void NewFunc (SymEntry* Func) /* Parse argument declarations and function body. */ { int C99MainFunc = 0;/* Flag for C99 main function returning int */ SymEntry* Param; /* Get the function descriptor from the function entry */ FuncDesc* D = Func->V.F.Func; /* Allocate the function activation record for the function */ CurrentFunc = NewFunction (Func); /* Reenter the lexical level */ ReenterFunctionLevel (D); /* Check if the function header contains unnamed parameters. These are ** only allowed in cc65 mode. */ if ((D->Flags & FD_UNNAMED_PARAMS) != 0 && (IS_Get (&Standard) != STD_CC65)) { Error ("Parameter name omitted"); } /* Declare two special functions symbols: __fixargs__ and __argsize__. ** The latter is different depending on the type of the function (variadic ** or not). */ AddConstSym ("__fixargs__", type_uint, SC_DEF | SC_CONST, D->ParamSize); if (D->Flags & FD_VARIADIC) { /* Variadic function. The variable must be const. */ static const Type T[] = { TYPE(T_UCHAR | T_QUAL_CONST), TYPE(T_END) }; AddLocalSym ("__argsize__", T, SC_DEF | SC_REF | SC_AUTO, 0); } else { /* Non variadic */ AddConstSym ("__argsize__", type_uchar, SC_DEF | SC_CONST, D->ParamSize); } /* Function body now defined */ Func->Flags |= SC_DEF; /* Special handling for main() */ if (strcmp (Func->Name, "main") == 0) { /* Mark this as the main function */ CurrentFunc->Flags |= FF_IS_MAIN; /* Main cannot be a fastcall function */ if (IsQualFastcall (Func->Type)) { Error ("'main' cannot be declared as __fastcall__"); } /* If cc65 extensions aren't enabled, don't allow a main function that ** doesn't return an int. */ if (IS_Get (&Standard) != STD_CC65 && CurrentFunc->ReturnType[0].C != T_INT) { Error ("'main' must always return an int"); } /* Add a forced import of a symbol that is contained in the startup ** code. This will force the startup code to be linked in. */ g_importstartup (); /* If main() takes parameters, generate a forced import to a function ** that will setup these parameters. This way, programs that do not ** need the additional code will not get it. */ if (D->ParamCount > 0 || (D->Flags & FD_VARIADIC) != 0) { g_importmainargs (); /* The start-up code doesn't fast-call main(). */ Func->Type->C |= T_QUAL_CDECL; } /* Determine if this is a main function in a C99 environment that ** returns an int. */ if (IsTypeInt (F_GetReturnType (CurrentFunc)) && IS_Get (&Standard) == STD_C99) { C99MainFunc = 1; } } /* Allocate code and data segments for this function */ Func->V.F.Seg = PushSegments (Func); /* Allocate a new literal pool */ PushLiteralPool (Func); /* If this is a fastcall function, push the last parameter onto the stack */ if ((D->Flags & FD_VARIADIC) == 0 && D->ParamCount > 0 && (AutoCDecl ? IsQualFastcall (Func->Type) : !IsQualCDecl (Func->Type))) { unsigned Flags; /* Generate the push */ if (IsTypeFunc (D->LastParam->Type)) { /* Pointer to function */ Flags = CF_PTR; } else { Flags = TypeOf (D->LastParam->Type) | CF_FORCECHAR; } g_push (Flags, 0); } /* Generate function entry code if needed */ g_enter (TypeOf (Func->Type), F_GetParamSize (CurrentFunc)); /* If stack checking code is requested, emit a call to the helper routine */ if (IS_Get (&CheckStack)) { g_stackcheck (); } /* Setup the stack */ StackPtr = 0; /* Walk through the parameter list and allocate register variable space ** for parameters declared as register. Generate code to swap the contents ** of the register bank with the save area on the stack. */ Param = D->SymTab->SymHead; while (Param && (Param->Flags & SC_PARAM) != 0) { /* Check for a register variable */ if (SymIsRegVar (Param)) { /* Allocate space */ int Reg = F_AllocRegVar (CurrentFunc, Param->Type); /* Could we allocate a register? */ if (Reg < 0) { /* No register available: Convert parameter to auto */ CvtRegVarToAuto (Param); } else { /* Remember the register offset */ Param->V.R.RegOffs = Reg; /* Generate swap code */ g_swap_regvars (Param->V.R.SaveOffs, Reg, CheckedSizeOf (Param->Type)); } } /* Next parameter */ Param = Param->NextSym; } /* Need a starting curly brace */ ConsumeLCurly (); /* Make sure there is always something on the stack of local variable blocks */ CollAppend (&CurrentFunc->LocalsBlockStack, 0); /* Parse local variable declarations if any */ DeclareLocals (); /* Remember the current stack pointer. All variables allocated elsewhere ** must be dropped when doing a return from an inner block. */ CurrentFunc->TopLevelSP = StackPtr; /* Now process statements in this block */ while (CurTok.Tok != TOK_RCURLY && CurTok.Tok != TOK_CEOF) { Statement (0); } /* If this is not a void function, and not the main function in a C99 ** environment returning int, output a warning if we didn't see a return ** statement. */ if (!F_HasVoidReturn (CurrentFunc) && !F_HasReturn (CurrentFunc) && !C99MainFunc) { Warning ("Control reaches end of non-void function"); } /* If this is the main function in a C99 environment returning an int, let ** it always return zero. Note: Actual return statements jump to the return ** label defined below. ** The code is removed by the optimizer if unused. */ if (C99MainFunc) { g_getimmed (CF_INT | CF_CONST, 0, 0); } /* Output the function exit code label */ g_defcodelabel (F_GetRetLab (CurrentFunc)); /* Restore the register variables */ F_RestoreRegVars (CurrentFunc); /* Generate the exit code */ g_leave (); /* Emit references to imports/exports */ EmitExternals (); /* Emit function debug info */ F_EmitDebugInfo (); EmitDebugInfo (); /* Leave the lexical level */ LeaveFunctionLevel (); /* Eat the closing brace */ ConsumeRCurly (); /* Restore the old literal pool, remembering the one for the function */ Func->V.F.LitPool = PopLiteralPool (); /* Switch back to the old segments */ PopSegments (); /* Reset the current function pointer */ FreeFunction (CurrentFunc); CurrentFunc = 0; }
sethcoder/cc65
src/cc65/reginfo.c
/*****************************************************************************/ /* */ /* reginfo.c */ /* */ /* 6502 register tracking info */ /* */ /* */ /* */ /* (C) 2001-2003 <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* common */ #include "xmalloc.h" /* cc65 */ #include "reginfo.h" /*****************************************************************************/ /* Code */ /*****************************************************************************/ void RC_Invalidate (RegContents* C) /* Invalidate all registers */ { C->RegA = UNKNOWN_REGVAL; C->RegX = UNKNOWN_REGVAL; C->RegY = UNKNOWN_REGVAL; C->SRegLo = UNKNOWN_REGVAL; C->SRegHi = UNKNOWN_REGVAL; C->Ptr1Lo = UNKNOWN_REGVAL; C->Ptr1Hi = UNKNOWN_REGVAL; C->Tmp1 = UNKNOWN_REGVAL; } void RC_InvalidateZP (RegContents* C) /* Invalidate all ZP registers */ { C->SRegLo = UNKNOWN_REGVAL; C->SRegHi = UNKNOWN_REGVAL; C->Ptr1Lo = UNKNOWN_REGVAL; C->Ptr1Hi = UNKNOWN_REGVAL; C->Tmp1 = UNKNOWN_REGVAL; } static void RC_Dump1 (FILE* F, const char* Desc, short Val) /* Dump one register value */ { if (RegValIsKnown (Val)) { fprintf (F, "%s=$%02X ", Desc, Val); } else { fprintf (F, "%s=$XX ", Desc); } } void RC_Dump (FILE* F, const RegContents* RC) /* Dump the contents of the given RegContents struct */ { RC_Dump1 (F, "A", RC->RegA); RC_Dump1 (F, "X", RC->RegX); RC_Dump1 (F, "Y", RC->RegY); RC_Dump1 (F, "SREG", RC->SRegLo); RC_Dump1 (F, "SREG+1", RC->SRegHi); RC_Dump1 (F, "PTR1", RC->Ptr1Lo); RC_Dump1 (F, "PTR1+1", RC->Ptr1Hi); RC_Dump1 (F, "TMP1", RC->Tmp1); fprintf (F, "\n"); } RegInfo* NewRegInfo (const RegContents* RC) /* Allocate a new register info, initialize and return it. If RC is not ** a NULL pointer, it is used to initialize both, the input and output ** registers. If the pointer is NULL, all registers are set to unknown. */ { /* Allocate memory */ RegInfo* RI = xmalloc (sizeof (RegInfo)); /* Initialize the registers */ if (RC) { RI->In = *RC; RI->Out = *RC; RI->Out2 = *RC; } else { RC_Invalidate (&RI->In); RC_Invalidate (&RI->Out); RC_Invalidate (&RI->Out2); } /* Return the new struct */ return RI; } void FreeRegInfo (RegInfo* RI) /* Free a RegInfo struct */ { xfree (RI); } void DumpRegInfo (const char* Desc, const RegInfo* RI) /* Dump the register info for debugging */ { fprintf (stdout, "%s:\n", Desc); fprintf (stdout, "In: "); RC_Dump (stdout, &RI->In); fprintf (stdout, "Out: "); RC_Dump (stdout, &RI->Out); }
sethcoder/cc65
src/cc65/stmt.c
/*****************************************************************************/ /* */ /* stmt.c */ /* */ /* Parse a statement */ /* */ /* */ /* */ /* (C) 1998-2010, <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ #include <stdio.h> #include <string.h> /* common */ #include "coll.h" #include "xmalloc.h" /* cc65 */ #include "asmcode.h" #include "asmlabel.h" #include "codegen.h" #include "datatype.h" #include "error.h" #include "expr.h" #include "function.h" #include "global.h" #include "goto.h" #include "litpool.h" #include "loadexpr.h" #include "locals.h" #include "loop.h" #include "pragma.h" #include "scanner.h" #include "stackptr.h" #include "stmt.h" #include "swstmt.h" #include "symtab.h" #include "testexpr.h" #include "typeconv.h" /*****************************************************************************/ /* Helper functions */ /*****************************************************************************/ static int CheckLabelWithoutStatement (void) /* Called from Statement() after a label definition. Will check for a ** following closing curly brace. This means that a label is not followed ** by a statement which is required by the standard. Output an error if so. */ { if (CurTok.Tok == TOK_RCURLY) { Error ("Label at end of compound statement"); return 1; } else { return 0; } } static void CheckTok (token_t Tok, const char* Msg, int* PendingToken) /* Helper function for Statement. Will check for Tok and print Msg if not ** found. If PendingToken is NULL, it will the skip the token, otherwise ** it will store one to PendingToken. */ { if (CurTok.Tok != Tok) { Error ("%s", Msg); } else if (PendingToken) { *PendingToken = 1; } else { NextToken (); } } static void CheckSemi (int* PendingToken) /* Helper function for Statement. Will check for a semicolon and print an ** error message if not found (plus some error recovery). If PendingToken is ** NULL, it will the skip the token, otherwise it will store one to ** PendingToken. ** This function is a special version of CheckTok with the addition of the ** error recovery. */ { int HaveToken = (CurTok.Tok == TOK_SEMI); if (!HaveToken) { Error ("';' expected"); /* Try to be smart about errors */ if (CurTok.Tok == TOK_COLON || CurTok.Tok == TOK_COMMA) { HaveToken = 1; } } if (HaveToken) { if (PendingToken) { *PendingToken = 1; } else { NextToken (); } } } static void SkipPending (int PendingToken) /* Skip the pending token if we have one */ { if (PendingToken) { NextToken (); } } /*****************************************************************************/ /* Code */ /*****************************************************************************/ static int IfStatement (void) /* Handle an 'if' statement */ { unsigned Label1; unsigned TestResult; int GotBreak; /* Skip the if */ NextToken (); /* Generate a jump label and parse the condition */ Label1 = GetLocalLabel (); TestResult = TestInParens (Label1, 0); /* Parse the if body */ GotBreak = Statement (0); /* Else clause present? */ if (CurTok.Tok != TOK_ELSE) { g_defcodelabel (Label1); /* Since there's no else clause, we're not sure, if the a break ** statement is really executed. */ return 0; } else { /* Generate a jump around the else branch */ unsigned Label2 = GetLocalLabel (); g_jump (Label2); /* Skip the else */ NextToken (); /* If the if expression was always true, the code in the else branch ** is never executed. Output a warning if this is the case. */ if (TestResult == TESTEXPR_TRUE) { Warning ("Unreachable code"); } /* Define the target for the first test */ g_defcodelabel (Label1); /* Total break only if both branches had a break. */ GotBreak &= Statement (0); /* Generate the label for the else clause */ g_defcodelabel (Label2); /* Done */ return GotBreak; } } static void DoStatement (void) /* Handle the 'do' statement */ { /* Get the loop control labels */ unsigned LoopLabel = GetLocalLabel (); unsigned BreakLabel = GetLocalLabel (); unsigned ContinueLabel = GetLocalLabel (); /* Skip the while token */ NextToken (); /* Add the loop to the loop stack */ AddLoop (BreakLabel, ContinueLabel); /* Define the loop label */ g_defcodelabel (LoopLabel); /* Parse the loop body */ Statement (0); /* Output the label for a continue */ g_defcodelabel (ContinueLabel); /* Parse the end condition */ Consume (TOK_WHILE, "'while' expected"); TestInParens (LoopLabel, 1); ConsumeSemi (); /* Define the break label */ g_defcodelabel (BreakLabel); /* Remove the loop from the loop stack */ DelLoop (); } static void WhileStatement (void) /* Handle the 'while' statement */ { int PendingToken; CodeMark CondCodeStart; /* Start of condition evaluation code */ CodeMark CondCodeEnd; /* End of condition evaluation code */ CodeMark Here; /* "Here" location of code */ /* Get the loop control labels */ unsigned LoopLabel = GetLocalLabel (); unsigned BreakLabel = GetLocalLabel (); unsigned CondLabel = GetLocalLabel (); /* Skip the while token */ NextToken (); /* Add the loop to the loop stack. In case of a while loop, the condition ** label is used for continue statements. */ AddLoop (BreakLabel, CondLabel); /* We will move the code that evaluates the while condition to the end of ** the loop, so generate a jump here. */ g_jump (CondLabel); /* Remember the current position */ GetCodePos (&CondCodeStart); /* Test the loop condition */ TestInParens (LoopLabel, 1); /* Remember the end of the condition evaluation code */ GetCodePos (&CondCodeEnd); /* Define the head label */ g_defcodelabel (LoopLabel); /* Loop body */ Statement (&PendingToken); /* Emit the while condition label */ g_defcodelabel (CondLabel); /* Move the test code here */ GetCodePos (&Here); MoveCode (&CondCodeStart, &CondCodeEnd, &Here); /* Exit label */ g_defcodelabel (BreakLabel); /* Eat remaining tokens that were delayed because of line info ** correctness */ SkipPending (PendingToken); /* Remove the loop from the loop stack */ DelLoop (); } static void ReturnStatement (void) /* Handle the 'return' statement */ { ExprDesc Expr; NextToken (); if (CurTok.Tok != TOK_SEMI) { /* Evaluate the return expression */ hie0 (&Expr); /* If we return something in a void function, print an error and ** ignore the value. Otherwise convert the value to the type of the ** return. */ if (F_HasVoidReturn (CurrentFunc)) { Error ("Returning a value in function with return type void"); } else { /* Convert the return value to the type of the function result */ TypeConversion (&Expr, F_GetReturnType (CurrentFunc)); /* Load the value into the primary */ LoadExpr (CF_NONE, &Expr); } } else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) { Error ("Function '%s' must return a value", F_GetFuncName (CurrentFunc)); } /* Mark the function as having a return statement */ F_ReturnFound (CurrentFunc); /* Cleanup the stack in case we're inside a block with locals */ g_space (StackPtr - F_GetTopLevelSP (CurrentFunc)); /* Output a jump to the function exit code */ g_jump (F_GetRetLab (CurrentFunc)); } static void BreakStatement (void) /* Handle the 'break' statement */ { LoopDesc* L; /* Skip the break */ NextToken (); /* Get the current loop descriptor */ L = CurrentLoop (); /* Check if we are inside a loop */ if (L == 0) { /* Error: No current loop */ Error ("'break' statement not within loop or switch"); return; } /* Correct the stack pointer if needed */ g_space (StackPtr - L->StackPtr); /* Jump to the exit label of the loop */ g_jump (L->BreakLabel); } static void ContinueStatement (void) /* Handle the 'continue' statement */ { LoopDesc* L; /* Skip the continue */ NextToken (); /* Get the current loop descriptor */ L = CurrentLoop (); if (L) { /* Search for a loop that has a continue label. */ do { if (L->ContinueLabel) { break; } L = L->Next; } while (L); } /* Did we find it? */ if (L == 0) { Error ("'continue' statement not within a loop"); return; } /* Correct the stackpointer if needed */ g_space (StackPtr - L->StackPtr); /* Jump to next loop iteration */ g_jump (L->ContinueLabel); } static void ForStatement (void) /* Handle a 'for' statement */ { ExprDesc lval1; ExprDesc lval3; int HaveIncExpr; CodeMark IncExprStart; CodeMark IncExprEnd; int PendingToken; /* Get several local labels needed later */ unsigned TestLabel = GetLocalLabel (); unsigned BreakLabel = GetLocalLabel (); unsigned IncLabel = GetLocalLabel (); unsigned BodyLabel = GetLocalLabel (); /* Skip the FOR token */ NextToken (); /* Add the loop to the loop stack. A continue jumps to the start of the ** the increment condition. */ AddLoop (BreakLabel, IncLabel); /* Skip the opening paren */ ConsumeLParen (); /* Parse the initializer expression */ if (CurTok.Tok != TOK_SEMI) { Expression0 (&lval1); } ConsumeSemi (); /* Label for the test expressions */ g_defcodelabel (TestLabel); /* Parse the test expression */ if (CurTok.Tok != TOK_SEMI) { Test (BodyLabel, 1); g_jump (BreakLabel); } else { g_jump (BodyLabel); } ConsumeSemi (); /* Remember the start of the increment expression */ GetCodePos (&IncExprStart); /* Label for the increment expression */ g_defcodelabel (IncLabel); /* Parse the increment expression */ HaveIncExpr = (CurTok.Tok != TOK_RPAREN); if (HaveIncExpr) { Expression0 (&lval3); } /* Jump to the test */ g_jump (TestLabel); /* Remember the end of the increment expression */ GetCodePos (&IncExprEnd); /* Skip the closing paren */ ConsumeRParen (); /* Loop body */ g_defcodelabel (BodyLabel); Statement (&PendingToken); /* If we had an increment expression, move the code to the bottom of ** the loop. In this case we don't need to jump there at the end of ** the loop body. */ if (HaveIncExpr) { CodeMark Here; GetCodePos (&Here); MoveCode (&IncExprStart, &IncExprEnd, &Here); } else { /* Jump back to the increment expression */ g_jump (IncLabel); } /* Skip a pending token if we have one */ SkipPending (PendingToken); /* Declare the break label */ g_defcodelabel (BreakLabel); /* Remove the loop from the loop stack */ DelLoop (); } static int CompoundStatement (void) /* Compound statement. Allow any number of statements inside braces. The ** function returns true if the last statement was a break or return. */ { int GotBreak; /* Remember the stack at block entry */ int OldStack = StackPtr; unsigned OldBlockStackSize = CollCount (&CurrentFunc->LocalsBlockStack); /* Enter a new lexical level */ EnterBlockLevel (); /* Parse local variable declarations if any */ DeclareLocals (); /* Now process statements in this block */ GotBreak = 0; while (CurTok.Tok != TOK_RCURLY) { if (CurTok.Tok != TOK_CEOF) { GotBreak = Statement (0); } else { break; } } /* Clean up the stack. */ if (!GotBreak) { g_space (StackPtr - OldStack); } /* If the segment had autoinited variables, let's pop it of a stack ** of such blocks. */ if (OldBlockStackSize != CollCount (&CurrentFunc->LocalsBlockStack)) { CollPop (&CurrentFunc->LocalsBlockStack); } StackPtr = OldStack; /* Emit references to imports/exports for this block */ EmitExternals (); /* Leave the lexical level */ LeaveBlockLevel (); return GotBreak; } int Statement (int* PendingToken) /* Statement parser. Returns 1 if the statement does a return/break, returns ** 0 otherwise. If the PendingToken pointer is not NULL, the function will ** not skip the terminating token of the statement (closing brace or ** semicolon), but store true if there is a pending token, and false if there ** is none. The token is always checked, so there is no need for the caller to ** check this token, it must be skipped, however. If the argument pointer is ** NULL, the function will skip the token. */ { ExprDesc Expr; int GotBreak; CodeMark Start, End; /* Assume no pending token */ if (PendingToken) { *PendingToken = 0; } /* Check for a label. A label is always part of a statement, it does not ** replace one. */ while (CurTok.Tok == TOK_IDENT && NextTok.Tok == TOK_COLON) { /* Handle the label */ DoLabel (); if (CheckLabelWithoutStatement ()) { return 0; } } switch (CurTok.Tok) { case TOK_LCURLY: NextToken (); GotBreak = CompoundStatement (); CheckTok (TOK_RCURLY, "'{' expected", PendingToken); return GotBreak; case TOK_IF: return IfStatement (); case TOK_WHILE: WhileStatement (); break; case TOK_DO: DoStatement (); break; case TOK_SWITCH: SwitchStatement (); break; case TOK_RETURN: ReturnStatement (); CheckSemi (PendingToken); return 1; case TOK_BREAK: BreakStatement (); CheckSemi (PendingToken); return 1; case TOK_CONTINUE: ContinueStatement (); CheckSemi (PendingToken); return 1; case TOK_FOR: ForStatement (); break; case TOK_GOTO: GotoStatement (); CheckSemi (PendingToken); return 1; case TOK_SEMI: /* Ignore it */ CheckSemi (PendingToken); break; case TOK_PRAGMA: DoPragma (); break; case TOK_CASE: CaseLabel (); CheckLabelWithoutStatement (); break; case TOK_DEFAULT: DefaultLabel (); CheckLabelWithoutStatement (); break; default: /* Remember the current code position */ GetCodePos (&Start); /* Actual statement */ ExprWithCheck (hie0, &Expr); /* Load the result only if it is an lvalue and the type is ** marked as volatile. Otherwise the load is useless. */ if (ED_IsLVal (&Expr) && IsQualVolatile (Expr.Type)) { LoadExpr (CF_NONE, &Expr); } /* If the statement didn't generate code, and is not of type ** void, emit a warning. */ GetCodePos (&End); if (CodeRangeIsEmpty (&Start, &End) && !IsTypeVoid (Expr.Type) && IS_Get (&WarnNoEffect)) { Warning ("Statement has no effect"); } CheckSemi (PendingToken); } return 0; }
sethcoder/cc65
src/cc65/loadexpr.c
<reponame>sethcoder/cc65 /*****************************************************************************/ /* */ /* loadexpr.c */ /* */ /* Load an expression into the primary register */ /* */ /* */ /* */ /* (C) 2004-2009, <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* cc65 */ #include "codegen.h" #include "error.h" #include "exprdesc.h" #include "global.h" #include "loadexpr.h" /*****************************************************************************/ /* Code */ /*****************************************************************************/ static void LoadConstant (unsigned Flags, ExprDesc* Expr) /* Load the primary register with some constant value. */ { switch (ED_GetLoc (Expr)) { case E_LOC_ABS: /* Number constant */ g_getimmed (Flags | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0); break; case E_LOC_GLOBAL: /* Global symbol, load address */ g_getimmed ((Flags | CF_EXTERNAL) & ~CF_CONST, Expr->Name, Expr->IVal); break; case E_LOC_STATIC: case E_LOC_LITERAL: /* Static symbol or literal, load address */ g_getimmed ((Flags | CF_STATIC) & ~CF_CONST, Expr->Name, Expr->IVal); break; case E_LOC_REGISTER: /* Register variable. Taking the address is usually not ** allowed. */ if (IS_Get (&AllowRegVarAddr) == 0) { Error ("Cannot take the address of a register variable"); } g_getimmed ((Flags | CF_REGVAR) & ~CF_CONST, Expr->Name, Expr->IVal); break; case E_LOC_STACK: g_leasp (Expr->IVal); break; default: Internal ("Unknown constant type: %04X", Expr->Flags); } } void LoadExpr (unsigned Flags, struct ExprDesc* Expr) /* Load an expression into the primary register if it is not already there. */ { if (ED_IsLVal (Expr)) { /* Dereferenced lvalue. If this is a bit field its type is unsigned. ** But if the field is completely contained in the lower byte, we will ** throw away the high byte anyway and may therefore load just the ** low byte. */ if (ED_IsBitField (Expr)) { Flags |= (Expr->BitOffs + Expr->BitWidth <= CHAR_BITS)? CF_CHAR : CF_INT; Flags |= CF_UNSIGNED; } else { Flags |= TypeOf (Expr->Type); } if (ED_NeedsTest (Expr)) { Flags |= CF_TEST; } switch (ED_GetLoc (Expr)) { case E_LOC_ABS: /* Absolute: numeric address or const */ g_getstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0); break; case E_LOC_GLOBAL: /* Global variable */ g_getstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal); break; case E_LOC_STATIC: case E_LOC_LITERAL: /* Static variable or literal in the literal pool */ g_getstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal); break; case E_LOC_REGISTER: /* Register variable */ g_getstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal); break; case E_LOC_STACK: /* Value on the stack */ g_getlocal (Flags, Expr->IVal); break; case E_LOC_PRIMARY: /* The primary register - just test if necessary */ if (Flags & CF_TEST) { g_test (Flags); } break; case E_LOC_EXPR: /* Reference to address in primary with offset in Expr */ g_getind (Flags, Expr->IVal); break; default: Internal ("Invalid location in LoadExpr: 0x%04X", ED_GetLoc (Expr)); } /* Handle bit fields. The actual type may have been casted or ** converted, so be sure to always use unsigned ints for the ** operations. */ if (ED_IsBitField (Expr)) { unsigned F = CF_INT | CF_UNSIGNED | CF_CONST | (Flags & CF_TEST); /* Shift right by the bit offset */ g_asr (F, Expr->BitOffs); /* And by the width if the field doesn't end on an int boundary */ if (Expr->BitOffs + Expr->BitWidth != CHAR_BITS && Expr->BitOffs + Expr->BitWidth != INT_BITS) { g_and (F, (0x0001U << Expr->BitWidth) - 1U); } } /* Expression was tested */ ED_TestDone (Expr); } else { /* An rvalue */ if (ED_IsLocExpr (Expr)) { if (Expr->IVal != 0) { /* We have an expression in the primary plus a constant ** offset. Adjust the value in the primary accordingly. */ Flags |= TypeOf (Expr->Type); g_inc (Flags | CF_CONST, Expr->IVal); } } else { /* Constant of some sort, load it into the primary */ LoadConstant (Flags, Expr); } /* Are we testing this value? */ if (ED_NeedsTest (Expr)) { /* Yes, force a test */ Flags |= TypeOf (Expr->Type); g_test (Flags); ED_TestDone (Expr); } } }
sethcoder/cc65
libsrc/common/_afailed.c
/* ** _afailed.c ** ** 1998-06-06, <NAME> ** 2015-03-13, <NAME> */ #include <stdio.h> #include <stdlib.h> void __fastcall__ _afailed (char* file, unsigned line) { fprintf (stderr, "ASSERTION FAILED IN %s(%u)\n", file, line); exit (2); }
sethcoder/cc65
include/em.h
/*****************************************************************************/ /* */ /* em.h */ /* */ /* API for extended memory access */ /* */ /* */ /* */ /* (C) 2002-2012, <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ #ifndef _EM_H #define _EM_H /*****************************************************************************/ /* Definitions */ /*****************************************************************************/ /* Size of an extended memory page */ #define EM_PAGE_SIZE 256 /* Error codes */ #define EM_ERR_OK 0 /* No error */ #define EM_ERR_NO_DRIVER 1 /* No driver available */ #define EM_ERR_CANNOT_LOAD 2 /* Error loading driver */ #define EM_ERR_INV_DRIVER 3 /* Invalid driver */ #define EM_ERR_NO_DEVICE 4 /* Device (hardware) not found */ #define EM_ERR_INSTALLED 5 /* A driver is already installed */ /* Parameters for the em_copy_... functions. NOTE: The first seven bytes ** have the same order and alignment as needed for the Commodore REU, so ** don't change the order without changing the assembler file that defines ** the struct offsets and the code in the REU driver. */ struct em_copy { void* buf; /* Memory buffer to copy from or to */ unsigned char offs; /* Offset into page */ unsigned page; /* Starting page to copy from or to */ unsigned count; /* Number of bytes to copy */ unsigned char unused; /* Make the size 8 bytes */ }; /*****************************************************************************/ /* Functions */ /*****************************************************************************/ unsigned char __fastcall__ em_load_driver (const char* driver); /* Load and install an extended memory driver. Return an error code. */ unsigned char em_unload (void); /* Uninstall, then unload the currently loaded driver. */ unsigned char __fastcall__ em_install (void* driver); /* Install an already loaded driver. Return an error code. */ unsigned char em_uninstall (void); /* Uninstall the currently loaded driver and return an error code. ** Note: This call does not free allocated memory. */ unsigned em_pagecount (void); /* Return the total number of 256 byte pages available in extended memory. */ void* __fastcall__ em_map (unsigned page); /* Unmap the current page from memory and map a new one. The function returns ** a pointer to the location of the page in memory. Note: Without calling ** em_commit, the old contents of the memory window may be lost! */ void* __fastcall__ em_use (unsigned page); /* Tell the driver that the memory window is associated with a given page. ** This call is very similar to em_map. The difference is that the driver ** does not necessarily transfer the current contents of the extended ** memory into the returned window. If you're going to just write to the ** window and the current contents of the window are invalid or no longer ** use, this call may perform better than em_map. */ void em_commit (void); /* Commit changes in the memory window to extended storage. If the contents ** of the memory window have been changed, these changes may be lost if ** em_map, em_copyfrom or em_copyto are called without calling em_commit ** first. Note: Not calling em_commit does not mean that the changes are ** discarded, it does just mean that some drivers will discard the changes. */ void __fastcall__ em_copyfrom (const struct em_copy* copy_data); /* Copy from extended into linear memory. Note: This may invalidate the ** currently mapped page. */ void __fastcall__ em_copyto (const struct em_copy* copy_data); /* Copy from linear into extended memory. Note: This may invalidate the ** currently mapped page. */ /* End of em.h */ #endif
sethcoder/cc65
src/ld65/xex.c
<filename>src/ld65/xex.c /*****************************************************************************/ /* */ /* xex.c */ /* */ /* Module to handle the Atari XEX binary format */ /* */ /* */ /* */ /* (C) 2018 <NAME> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ #include <stdio.h> #include <string.h> #include <errno.h> /* common */ #include "alignment.h" #include "print.h" #include "xmalloc.h" /* ld65 */ #include "xex.h" #include "config.h" #include "exports.h" #include "expr.h" #include "error.h" #include "global.h" #include "fileio.h" #include "lineinfo.h" #include "memarea.h" #include "segments.h" #include "spool.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* Linked list of memory area initialization addresses */ typedef struct XexInitAd { MemoryArea *InitMem; Import *InitAd; struct XexInitAd *next; } XexInitAd; struct XexDesc { unsigned Undef; /* Count of undefined externals */ FILE* F; /* Output file */ const char* Filename; /* Name of output file */ Import* RunAd; /* Run Address */ XexInitAd* InitAds; /* List of Init Addresses */ unsigned long HeadPos; /* Position in the file of current header */ unsigned long HeadEnd; /* End address of current header */ unsigned long HeadSize; /* Last header size, can be removed if zero */ }; /*****************************************************************************/ /* Code */ /*****************************************************************************/ XexDesc* NewXexDesc (void) /* Create a new XEX format descriptor */ { /* Allocate memory for a new XexDesc struct */ XexDesc* D = xmalloc (sizeof (XexDesc)); /* Initialize the fields */ D->Undef = 0; D->F = 0; D->Filename = 0; D->RunAd = 0; D->InitAds = 0; D->HeadPos = 0; D->HeadEnd = 0; D->HeadSize = 0; /* Return the created struct */ return D; } void FreeXexDesc (XexDesc* D) /* Free a XEX format descriptor */ { xfree (D); } void XexSetRunAd (XexDesc* D, Import *RunAd) /* Set the RUNAD export */ { D->RunAd = RunAd; } XexInitAd* XexSearchInitMem(XexDesc* D, MemoryArea *InitMem) { XexInitAd* I; for (I=D->InitAds; I != 0; I=I->next) { if (I->InitMem == InitMem) return I; } return NULL; } int XexAddInitAd (XexDesc* D, MemoryArea *InitMem, Import *InitAd) /* Sets and INITAD for the given memory area */ { XexInitAd* I; /* Search for repeated entry */ if (XexSearchInitMem (D, InitMem)) return 1; I = xmalloc (sizeof (XexInitAd)); I->InitAd = InitAd; I->InitMem = InitMem; I->next = D->InitAds; D->InitAds = I; return 0; } static unsigned XexWriteExpr (ExprNode* E, int Signed, unsigned Size, unsigned long Offs attribute ((unused)), void* Data) /* Called from SegWrite for an expression. Evaluate the expression, check the ** range and write the expression value to the file. */ { /* There's a predefined function to handle constant expressions */ return SegWriteConstExpr (((XexDesc*)Data)->F, E, Signed, Size); } static void PrintNumVal (const char* Name, unsigned long V) /* Print a numerical value for debugging */ { Print (stdout, 2, " %s = 0x%lx\n", Name, V); } static void XexStartSegment (XexDesc *D, unsigned long Addr, unsigned long Size) { /* Skip segment without size */ if (!Size) return; /* Store current position */ unsigned long Pos = ftell (D->F); unsigned long End = Addr + Size - 1; /* See if last header can be expanded into this one */ if (D->HeadPos && ((D->HeadEnd + 1) == Addr)) { /* Expand current header */ D->HeadEnd = End; D->HeadSize += Size; fseek (D->F, D->HeadPos + 2, SEEK_SET); Write16 (D->F, End); /* Seek to old position */ fseek (D->F, Pos, SEEK_SET); } else { if (D->HeadSize == 0) { /* Last header had no data, replace */ Pos = D->HeadPos; fseek (D->F, Pos, SEEK_SET); } /* If we are at start of file, write XEX heder */ if (Pos == 0) Write16 (D->F, 0xFFFF); /* Writes a new segment header */ D->HeadPos = ftell (D->F); D->HeadEnd = End; D->HeadSize = Size; Write16 (D->F, Addr); Write16 (D->F, End); } } static void XexFakeSegment (XexDesc *D, unsigned long Addr) { /* See if last header can be expanded into this one, we are done */ if (D->HeadPos && ((D->HeadEnd + 1) == Addr)) return; /* If we are at start of file, write XEX heder */ if (ftell (D->F) == 0) Write16 (D->F, 0xFFFF); /* Writes a new (invalid) segment header */ D->HeadPos = ftell (D->F); D->HeadEnd = Addr - 1; D->HeadSize = 0; Write16 (D->F, Addr); Write16 (D->F, D->HeadEnd); } static unsigned long XexWriteMem (XexDesc* D, MemoryArea* M) /* Write the segments of one memory area to a file */ { unsigned I; /* Store initial position to get total file size */ unsigned long StartPos = ftell (D->F); /* Always write a segment header for each memory area */ D->HeadPos = 0; /* Get the start address and size of this memory area */ unsigned long Addr = M->Start; /* Walk over all segments in this memory area */ for (I = 0; I < CollCount (&M->SegList); ++I) { int DoWrite; /* Get the segment */ SegDesc* S = CollAtUnchecked (&M->SegList, I); /* Keep the user happy */ Print (stdout, 1, " ATARI EXE Writing `%s'\n", GetString (S->Name)); /* Writes do only occur in the load area and not for BSS segments */ DoWrite = (S->Flags & SF_BSS) == 0 && /* No BSS segment */ S->Load == M && /* LOAD segment */ S->Seg->Dumped == 0; /* Not already written */ /* If this is the run memory area, we must apply run alignment. If ** this is not the run memory area but the load memory area (which ** means that both are different), we must apply load alignment. ** Beware: DoWrite may be true even if this is the run memory area, ** because it may be also the load memory area. */ if (S->Run == M) { /* Handle ALIGN and OFFSET/START */ if (S->Flags & SF_ALIGN) { /* Align the address */ unsigned long NewAddr = AlignAddr (Addr, S->RunAlignment); if (DoWrite || (M->Flags & MF_FILL) != 0) { XexStartSegment (D, Addr, NewAddr - Addr); WriteMult (D->F, M->FillVal, NewAddr - Addr); PrintNumVal ("SF_ALIGN", NewAddr - Addr); } Addr = NewAddr; } else if (S->Flags & (SF_OFFSET | SF_START)) { unsigned long NewAddr = S->Addr; if (S->Flags & SF_OFFSET) { /* It's an offset, not a fixed address, make an address */ NewAddr += M->Start; } if (DoWrite || (M->Flags & MF_FILL) != 0) { /* "overwrite" segments are not supported */ if (S->Flags & SF_OVERWRITE) { Error ("ATARI file format does not support overwrite for segment '%s'.", GetString (S->Name)); } else { XexStartSegment (D, Addr, NewAddr - Addr); WriteMult (D->F, M->FillVal, NewAddr-Addr); PrintNumVal ("SF_OFFSET", NewAddr - Addr); } } Addr = NewAddr; } } else if (S->Load == M) { /* Handle ALIGN_LOAD */ if (S->Flags & SF_ALIGN_LOAD) { /* Align the address */ unsigned long NewAddr = AlignAddr (Addr, S->LoadAlignment); if (DoWrite || (M->Flags & MF_FILL) != 0) { XexStartSegment (D, Addr, NewAddr - Addr); WriteMult (D->F, M->FillVal, NewAddr - Addr); PrintNumVal ("SF_ALIGN_LOAD", NewAddr - Addr); } Addr = NewAddr; } } /* Now write the segment to disk if it is not a BSS type segment and ** if the memory area is the load area. */ if (DoWrite) { /* Start a segment with only one byte, will fix later */ XexFakeSegment (D, Addr); unsigned long P = ftell (D->F); SegWrite (D->Filename, D->F, S->Seg, XexWriteExpr, D); unsigned long Size = ftell (D->F) - P; /* Fix segment size */ XexStartSegment (D, Addr, Size); PrintNumVal ("Wrote", Size); } else if (M->Flags & MF_FILL) { XexStartSegment (D, Addr, S->Seg->Size); WriteMult (D->F, S->Seg->FillVal, S->Seg->Size); PrintNumVal ("Filled", (unsigned long) S->Seg->Size); } /* If this was the load memory area, mark the segment as dumped */ if (S->Load == M) { S->Seg->Dumped = 1; } /* Calculate the new address */ Addr += S->Seg->Size; } /* If a fill was requested, fill the remaining space */ if ((M->Flags & MF_FILL) != 0 && M->FillLevel < M->Size) { unsigned long ToFill = M->Size - M->FillLevel; Print (stdout, 2, " Filling 0x%lx bytes with 0x%02x\n", ToFill, M->FillVal); XexStartSegment (D, Addr, ToFill); WriteMult (D->F, M->FillVal, ToFill); M->FillLevel = M->Size; } /* If the last segment is empty, remove */ if (D->HeadSize == 0 && D->HeadPos) { fseek (D->F, D->HeadPos, SEEK_SET); } return ftell (D->F) - StartPos; } static int XexUnresolved (unsigned Name attribute ((unused)), void* D) /* Called if an unresolved symbol is encountered */ { /* Unresolved symbols are an error in XEX format. Bump the counter ** and return zero telling the caller that the symbol is indeed ** unresolved. */ ((XexDesc*) D)->Undef++; return 0; } void XexWriteTarget (XexDesc* D, struct File* F) /* Write a XEX output file */ { unsigned I; /* Place the filename in the control structure */ D->Filename = GetString (F->Name); /* Check for unresolved symbols. The function XexUnresolved is called ** if we get an unresolved symbol. */ D->Undef = 0; /* Reset the counter */ CheckUnresolvedImports (XexUnresolved, D); if (D->Undef > 0) { /* We had unresolved symbols, cannot create output file */ Error ("%u unresolved external(s) found - cannot create output file", D->Undef); } /* Open the file */ D->F = fopen (D->Filename, "wb"); if (D->F == 0) { Error ("Cannot open `%s': %s", D->Filename, strerror (errno)); } /* Keep the user happy */ Print (stdout, 1, "Opened `%s'...\n", D->Filename); /* Dump all memory areas */ for (I = 0; I < CollCount (&F->MemoryAreas); ++I) { /* Get this entry */ MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, I); /* See if we have an init address for this area */ XexInitAd* I = XexSearchInitMem (D, M); Print (stdout, 1, " ATARI EXE Dumping `%s'\n", GetString (M->Name)); if (XexWriteMem (D, M) && I) { Write16 (D->F, 0x2E2); Write16 (D->F, 0x2E3); Write16 (D->F, GetExportVal (I->InitAd->Exp)); } } /* Write RUNAD at file end */ if (D->RunAd) { Write16 (D->F, 0x2E0); Write16 (D->F, 0x2E1); Write16 (D->F, GetExportVal (D->RunAd->Exp)); } /* Close the file */ if (fclose (D->F) != 0) { Error ("Cannot write to `%s': %s", D->Filename, strerror (errno)); } /* Reset the file and filename */ D->F = 0; D->Filename = 0; }
sethcoder/cc65
testcode/lib/clock-test.c
<gh_stars>1-10 /* Clock test program * * 25-Sep-2018, <EMAIL> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <errno.h> #ifdef __CC65__ #include <conio.h> #include <cc65.h> #endif /* #ifdef __CC65__ */ static void print_time(void) { struct tm *cur_tm; time_t cur_time = time(NULL); if (cur_time == -1) { printf("time() failed: %s\n", strerror(errno)); return; } cur_tm = localtime(&cur_time); printf("time: %s\n", asctime(cur_tm)); // DEBUG: printf("mday=%d mon=%d year=%d\nhour=%d min=%d sec=%d\n", cur_tm->tm_mday, cur_tm->tm_mon, cur_tm->tm_year, cur_tm->tm_hour, cur_tm->tm_min, cur_tm->tm_sec); } int main(int argc, char **argv) { char c = 0; int s; struct tm cur_time; struct timespec new_time; #ifdef __CC65__ /* if DOS will automatically clear the screen after the program exits, wait for a keypress... */ if (doesclrscrafterexit()) atexit((void (*)(void))cgetc); #endif if (argc <= 1) { print_time(); return 0; } if (argc != 3 || strcasecmp(*(argv + 1), "set")) { printf("usage: CLOCKTST [set DD-MM-YY-HH-MM-SS]\n"); return 1; } memset(&cur_time, 0, sizeof(cur_time)); s = sscanf(*(argv + 2), "%d-%d-%d-%d-%d-%d", &cur_time.tm_mday, &cur_time.tm_mon, &cur_time.tm_year, &cur_time.tm_hour, &cur_time.tm_min, &cur_time.tm_sec); if (s != 6 || cur_time.tm_year > 99 /* other input values aren't being verified... */) { printf("invalid time/date format\n"); return 1; } --cur_time.tm_mon; if (cur_time.tm_year < 79) cur_time.tm_year += 100; /* adjust century */ memset(&new_time, 0, sizeof(new_time)); new_time.tv_sec = mktime(&cur_time); printf("\nyou are about to set the time to\n--> %s\n\nContinue (y/n)?", ctime(&new_time.tv_sec)); while (c != 'y' && c != 'Y' && c != 'n' && c != 'N') { #ifdef __CC65__ c = cgetc(); #else c = getchar(); #endif } printf("%c\n", c); if (c == 'n' || c == 'N') { printf("user abort\n"); return 0; } s = clock_settime(CLOCK_REALTIME, &new_time); if (s) { printf("clock_settime() failed: %s\n", strerror(errno)); return 1; } printf("time set!\n"); //DEBUG test begin print_time(); //DEBUG test end return 0; } /* Local Variables: */ /* c-file-style: "cpg" */ /* c-basic-offset: 4 */ /* End: */
sethcoder/cc65
samples/enumdevdir.c
<gh_stars>1-10 /* ** Enumerate devices, directories and files. ** ** 2012-10-15, <NAME> (<EMAIL>) ** */ #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <device.h> #include <dirent.h> #include <cc65.h> void printdir (char *newdir) { char olddir[FILENAME_MAX]; char curdir[FILENAME_MAX]; DIR *dir; struct dirent *ent; char *subdirs = NULL; unsigned dirnum = 0; unsigned num; getcwd (olddir, sizeof (olddir)); if (chdir (newdir)) { /* If chdir() fails we just print the ** directory name - as done for files. */ printf (" Dir %s\n", newdir); return; } /* We call getcwd() in order to print the ** absolute pathname for a subdirectory. */ getcwd (curdir, sizeof (curdir)); printf (" Dir %s:\n", curdir); /* Calling opendir() always with "." avoids ** fiddling around with pathname separators. */ dir = opendir ("."); while (ent = readdir (dir)) { if (_DE_ISREG (ent->d_type)) { printf (" File %s\n", ent->d_name); continue; } /* We defer handling of subdirectories until we're done with the ** current one as several targets don't support other disk i/o ** while reading a directory (see cc65 readdir() doc for more). */ if (_DE_ISDIR (ent->d_type)) { subdirs = realloc (subdirs, FILENAME_MAX * (dirnum + 1)); strcpy (subdirs + FILENAME_MAX * dirnum++, ent->d_name); } } closedir (dir); for (num = 0; num < dirnum; ++num) { printdir (subdirs + FILENAME_MAX * num); } free (subdirs); chdir (olddir); } void main (void) { unsigned char device; char devicedir[FILENAME_MAX]; /* Calling getfirstdevice()/getnextdevice() does _not_ turn on the motor ** of a drive-type device and does _not_ check for a disk in the drive. */ device = getfirstdevice (); while (device != INVALID_DEVICE) { printf ("Device %d:\n", device); /* Calling getdevicedir() _does_ check for a (formatted) disk in a ** floppy-disk-type device and returns NULL if that check fails. */ if (getdevicedir (device, devicedir, sizeof (devicedir))) { printdir (devicedir); } else { printf (" N/A\n"); } device = getnextdevice (device); } if (doesclrscrafterexit ()) { getchar (); } }
sethcoder/cc65
src/cc65/funcdesc.c
<gh_stars>1-10 /*****************************************************************************/ /* */ /* funcdesc.c */ /* */ /* Function descriptor structure for the cc65 C compiler */ /* */ /* */ /* */ /* (C) 2000 <NAME> */ /* <NAME> */ /* D-70597 Stuttgart */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* common */ #include "xmalloc.h" /* cc65 */ #include "funcdesc.h" /*****************************************************************************/ /* Code */ /*****************************************************************************/ FuncDesc* NewFuncDesc (void) /* Create a new symbol table with the given name */ { /* Create a new function descriptor */ FuncDesc* F = (FuncDesc*) xmalloc (sizeof (FuncDesc)); /* Nullify the fields */ F->Flags = 0; F->SymTab = 0; F->TagTab = 0; F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; F->WrappedCall = 0; F->WrappedCallData = 0; /* Return the new struct */ return F; } void FreeFuncDesc (FuncDesc* F) /* Free a function descriptor */ { /* Free the structure */ xfree (F); }
sethcoder/cc65
include/atari5200.h
/*****************************************************************************/ /* */ /* atari5200.h */ /* */ /* Atari 5200 system specific definitions */ /* */ /* */ /* */ /* (C) 2014 <NAME> <<EMAIL>> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ #ifndef _ATARI5200_H #define _ATARI5200_H /* Check for errors */ #if !defined(__ATARI5200__) # error This module may only be used when compiling for the Atari 5200! #endif /* no support for dynamically loadable drivers */ #define DYN_DRV 0 /* the addresses of the static drivers */ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */ /* Masks for joy_read */ #define JOY_UP_MASK 0x01 #define JOY_DOWN_MASK 0x02 #define JOY_LEFT_MASK 0x04 #define JOY_RIGHT_MASK 0x08 #define JOY_BTN_1_MASK 0x10 /* Character codes */ #define CH_ULCORNER 0x0B /* '+' sign */ #define CH_URCORNER 0x0B #define CH_LLCORNER 0x0B #define CH_LRCORNER 0x0B #define CH_HLINE 0x0D /* dash */ #define CH_VLINE 0x01 /* exclamation mark */ /* get_tv return values */ #define AT_NTSC 0 #define AT_PAL 1 /* Define hardware */ #include <_gtia.h> #define GTIA_READ (*(struct __gtia_read*)0xC000) #define GTIA_WRITE (*(struct __gtia_write*)0xC000) #include <_pokey.h> #define POKEY_READ (*(struct __pokey_read*)0xE800) #define POKEY_WRITE (*(struct __pokey_write*)0xE800) #include <_antic.h> #define ANTIC (*(struct __antic*)0xD400) /* conio color defines */ #define COLOR_WHITE 0x00 #define COLOR_RED 0x01 #define COLOR_GREEN 0x02 #define COLOR_BLACK 0x03 /* The following #define will cause the matching function calls in conio.h ** to be overlaid by macros with the same names, saving the function call ** overhead. */ #define _bordercolor(color) 0 /* End of atari5200.h */ #endif
sethcoder/cc65
src/cc65/shiftexpr.c
<filename>src/cc65/shiftexpr.c /*****************************************************************************/ /* */ /* shiftexpr.c */ /* */ /* Parse the << and >> operators */ /* */ /* */ /* */ /* (C) 2004-2006 <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ /* cc65 */ #include "asmcode.h" #include "codegen.h" #include "datatype.h" #include "error.h" #include "expr.h" #include "exprdesc.h" #include "loadexpr.h" #include "scanner.h" #include "shiftexpr.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /*****************************************************************************/ /* Code */ /*****************************************************************************/ void ShiftExpr (struct ExprDesc* Expr) /* Parse the << and >> operators. */ { ExprDesc Expr2; CodeMark Mark1; CodeMark Mark2; token_t Tok; /* The operator token */ Type* EffType; /* Effective lhs type */ Type* ResultType; /* Type of the result */ unsigned ExprBits; /* Bits of the lhs operand */ unsigned GenFlags; /* Generator flags */ unsigned ltype; int rconst; /* Operand is a constant */ /* Evaluate the lhs */ ExprWithCheck (hie8, Expr); while (CurTok.Tok == TOK_SHL || CurTok.Tok == TOK_SHR) { /* All operators that call this function expect an int on the lhs */ if (!IsClassInt (Expr->Type)) { Error ("Integer expression expected"); ED_MakeConstAbsInt (Expr, 1); } /* Remember the operator token, then skip it */ Tok = CurTok.Tok; NextToken (); /* Get the type of the result */ ResultType = EffType = IntPromotion (Expr->Type); /* Prepare the code generator flags */ GenFlags = TypeOf (ResultType); /* Calculate the number of bits the lhs operand has */ ExprBits = SizeOf (ResultType) * 8; /* Get the lhs on stack */ GetCodePos (&Mark1); ltype = TypeOf (Expr->Type); if (ED_IsConstAbs (Expr)) { /* Constant value */ GetCodePos (&Mark2); g_push (ltype | CF_CONST, Expr->IVal); } else { /* Value not constant */ LoadExpr (CF_NONE, Expr); GetCodePos (&Mark2); g_push (ltype, 0); } /* Get the right hand side */ ExprWithCheck (hie8, &Expr2); /* Check the type of the rhs */ if (!IsClassInt (Expr2.Type)) { Error ("Integer expression expected"); ED_MakeConstAbsInt (&Expr2, 1); } /* Check for a constant right side expression */ rconst = ED_IsConstAbs (&Expr2); if (!rconst) { /* Not constant, load into the primary */ LoadExpr (CF_NONE, &Expr2); } else { /* The rhs is a constant numeric value. */ GenFlags |= CF_CONST; /* Remove the code that pushes the rhs onto the stack. */ RemoveCode (&Mark2); /* If the shift count is greater or equal than the bit count of ** the operand, the behaviour is undefined according to the ** standard. */ if (Expr2.IVal < 0 || Expr2.IVal >= (long) ExprBits) { Warning ("Shift count too large for operand type"); Expr2.IVal &= ExprBits - 1; } /* If the shift count is zero, nothing happens */ if (Expr2.IVal == 0) { /* Result is already in Expr, remove the generated code */ RemoveCode (&Mark1); /* Done */ goto Next; } /* If the left hand side is a constant, the result is constant */ if (ED_IsConstAbs (Expr)) { /* Evaluate the result */ switch (Tok) { case TOK_SHL: Expr->IVal <<= Expr2.IVal; break; case TOK_SHR: Expr->IVal >>= Expr2.IVal; break; default: /* Shutup gcc */ break; } /* Both operands are constant, remove the generated code */ RemoveCode (&Mark1); /* Done */ goto Next; } /* If we're shifting an integer or unsigned to the right, the ** lhs has a const address, and the shift count is larger than 8, ** we can load just the high byte as a char with the correct ** signedness, and reduce the shift count by 8. If the remaining ** shift count is zero, we're done. */ if (Tok == TOK_SHR && IsTypeInt (Expr->Type) && ED_IsLVal (Expr) && (ED_IsLocConst (Expr) || ED_IsLocStack (Expr)) && Expr2.IVal >= 8) { Type* OldType; /* Increase the address by one and decrease the shift count */ ++Expr->IVal; Expr2.IVal -= 8; /* Replace the type of the expression temporarily by the ** corresponding char type. */ OldType = Expr->Type; if (IsSignUnsigned (Expr->Type)) { Expr->Type = type_uchar; } else { Expr->Type = type_schar; } /* Remove the generated load code */ RemoveCode (&Mark1); /* Generate again code for the load, this time with the new type */ LoadExpr (CF_NONE, Expr); /* Reset the type */ Expr->Type = OldType; /* If the shift count is now zero, we're done */ if (Expr2.IVal == 0) { /* Be sure to mark the value as in the primary */ goto MakeRVal; } } } /* Generate code */ switch (Tok) { case TOK_SHL: g_asl (GenFlags, Expr2.IVal); break; case TOK_SHR: g_asr (GenFlags, Expr2.IVal); break; default: break; } MakeRVal: /* We have a rvalue in the primary now */ ED_MakeRValExpr (Expr); Next: /* Set the type of the result */ Expr->Type = ResultType; } }
sethcoder/cc65
test/val/binlit.c
<filename>test/val/binlit.c static unsigned char small[256]; static unsigned big[256]; int main() { unsigned i; small[0] = 0b0; small[1] = 0b1; small[2] = 0b10; small[3] = 0b11; small[4] = 0b100; small[5] = 0b101; small[6] = 0b110; small[7] = 0b000111; small[8] = 0b1000; small[9] = 0b1001; small[10] = 0b0001010; small[11] = 0b0001011; small[12] = 0b1100; small[13] = 0b1101; small[14] = 0b1110; small[15] = 0b1111; small[16] = 0b10000; small[17] = 0b10001; small[18] = 0b00010010; small[19] = 0b00010011; small[20] = 0b00010100; small[21] = 0b00010101; small[22] = 0b10110; small[23] = 0b10111; small[24] = 0b11000; small[25] = 0b11001; small[26] = 0b11010; small[27] = 0b11011; small[28] = 0b11100; small[29] = 0b11101; small[30] = 0b11110; small[31] = 0b11111; small[32] = 0b00000000100000; small[33] = 0b00000000100001; small[34] = 0b100010; small[35] = 0b100011; small[36] = 0b100100; small[37] = 0b100101; small[38] = 0b100110; small[39] = 0b100111; small[40] = 0b101000; small[41] = 0b101001; small[42] = 0b101010; small[43] = 0b101011; small[44] = 0b101100; small[45] = 0b101101; small[46] = 0b101110; small[47] = 0b101111; small[48] = 0b110000; small[49] = 0b110001; small[50] = 0b110010; small[51] = 0b110011; small[52] = 0b110100; small[53] = 0b110101; small[54] = 0b110110; small[55] = 0b110111; small[56] = 0b111000; small[57] = 0b111001; small[58] = 0b111010; small[59] = 0b111011; small[60] = 0b111100; small[61] = 0b111101; small[62] = 0b111110; small[63] = 0b111111; small[64] = 0b1000000; small[65] = 0b1000001; small[66] = 0b1000010; small[67] = 0b1000011; small[68] = 0b1000100; small[69] = 0b1000101; small[70] = 0b1000110; small[71] = 0b1000111; small[72] = 0b1001000; small[73] = 0b1001001; small[74] = 0b1001010; small[75] = 0b1001011; small[76] = 0b1001100; small[77] = 0b1001101; small[78] = 0b1001110; small[79] = 0b1001111; small[80] = 0b1010000; small[81] = 0b1010001; small[82] = 0b1010010; small[83] = 0b1010011; small[84] = 0b1010100; small[85] = 0b1010101; small[86] = 0b1010110; small[87] = 0b1010111; small[88] = 0b1011000; small[89] = 0b1011001; small[90] = 0b1011010; small[91] = 0b1011011; small[92] = 0b1011100; small[93] = 0b1011101; small[94] = 0b1011110; small[95] = 0b1011111; small[96] = 0b1100000; small[97] = 0b1100001; small[98] = 0b1100010; small[99] = 0b1100011; small[100] = 0b1100100; small[101] = 0b1100101; small[102] = 0b1100110; small[103] = 0b1100111; small[104] = 0b1101000; small[105] = 0b1101001; small[106] = 0b1101010; small[107] = 0b1101011; small[108] = 0b1101100; small[109] = 0b1101101; small[110] = 0b1101110; small[111] = 0b1101111; small[112] = 0b1110000; small[113] = 0b1110001; small[114] = 0b1110010; small[115] = 0b1110011; small[116] = 0b1110100; small[117] = 0b1110101; small[118] = 0b1110110; small[119] = 0b1110111; small[120] = 0b1111000; small[121] = 0b1111001; small[122] = 0b1111010; small[123] = 0b1111011; small[124] = 0b1111100; small[125] = 0b1111101; small[126] = 0b1111110; small[127] = 0b1111111; small[128] = 0b10000000; small[129] = 0b10000001; small[130] = 0b10000010; small[131] = 0b10000011; small[132] = 0b10000100; small[133] = 0b10000101; small[134] = 0b10000110; small[135] = 0b10000111; small[136] = 0b10001000; small[137] = 0b10001001; small[138] = 0b10001010; small[139] = 0b10001011; small[140] = 0b10001100; small[141] = 0b10001101; small[142] = 0b10001110; small[143] = 0b10001111; small[144] = 0b10010000; small[145] = 0b10010001; small[146] = 0b10010010; small[147] = 0b10010011; small[148] = 0b10010100; small[149] = 0b10010101; small[150] = 0b10010110; small[151] = 0b10010111; small[152] = 0b10011000; small[153] = 0b10011001; small[154] = 0b10011010; small[155] = 0b10011011; small[156] = 0b10011100; small[157] = 0b10011101; small[158] = 0b10011110; small[159] = 0b10011111; small[160] = 0b10100000; small[161] = 0b10100001; small[162] = 0b10100010; small[163] = 0b10100011; small[164] = 0b10100100; small[165] = 0b10100101; small[166] = 0b10100110; small[167] = 0b10100111; small[168] = 0b10101000; small[169] = 0b10101001; small[170] = 0b10101010; small[171] = 0b10101011; small[172] = 0b10101100; small[173] = 0b10101101; small[174] = 0b10101110; small[175] = 0b10101111; small[176] = 0b10110000; small[177] = 0b10110001; small[178] = 0b10110010; small[179] = 0b10110011; small[180] = 0b10110100; small[181] = 0b10110101; small[182] = 0b10110110; small[183] = 0b10110111; small[184] = 0b10111000; small[185] = 0b10111001; small[186] = 0b10111010; small[187] = 0b10111011; small[188] = 0b10111100; small[189] = 0b10111101; small[190] = 0b10111110; small[191] = 0b10111111; small[192] = 0b11000000; small[193] = 0b11000001; small[194] = 0b11000010; small[195] = 0b11000011; small[196] = 0b11000100; small[197] = 0b11000101; small[198] = 0b11000110; small[199] = 0b11000111; small[200] = 0b11001000; small[201] = 0b11001001; small[202] = 0b11001010; small[203] = 0b11001011; small[204] = 0b11001100; small[205] = 0b11001101; small[206] = 0b11001110; small[207] = 0b11001111; small[208] = 0b11010000; small[209] = 0b11010001; small[210] = 0b11010010; small[211] = 0b11010011; small[212] = 0b11010100; small[213] = 0b11010101; small[214] = 0b11010110; small[215] = 0b11010111; small[216] = 0b11011000; small[217] = 0b11011001; small[218] = 0b11011010; small[219] = 0b11011011; small[220] = 0b11011100; small[221] = 0b11011101; small[222] = 0b11011110; small[223] = 0b11011111; small[224] = 0b11100000; small[225] = 0b11100001; small[226] = 0b11100010; small[227] = 0b11100011; small[228] = 0b11100100; small[229] = 0b11100101; small[230] = 0b11100110; small[231] = 0b11100111; small[232] = 0b11101000; small[233] = 0b11101001; small[234] = 0b11101010; small[235] = 0b11101011; small[236] = 0b11101100; small[237] = 0b11101101; small[238] = 0b11101110; small[239] = 0b11101111; small[240] = 0b11110000; small[241] = 0b11110001; small[242] = 0b11110010; small[243] = 0b11110011; small[244] = 0b11110100; small[245] = 0b11110101; small[246] = 0b11110110; small[247] = 0b11110111; small[248] = 0b11111000; small[249] = 0b11111001; small[250] = 0b11111010; small[251] = 0b11111011; small[252] = 0b11111100; small[253] = 0b11111101; small[254] = 0b11111110; small[255] = 0b11111111; for (i = 0; i < 256; i++) { if (small[i] != i) return 1; } big[0] = 0b1111111100000000; big[1] = 0b1111111100000001; big[2] = 0b1111111100000010; big[3] = 0b1111111100000011; big[4] = 0b1111111100000100; big[5] = 0b1111111100000101; big[6] = 0b1111111100000110; big[7] = 0b1111111100000111; big[8] = 0b1111111100001000; big[9] = 0b1111111100001001; big[10] = 0b1111111100001010; big[11] = 0b1111111100001011; big[12] = 0b1111111100001100; big[13] = 0b1111111100001101; big[14] = 0b1111111100001110; big[15] = 0b1111111100001111; big[16] = 0b1111111100010000; big[17] = 0b1111111100010001; big[18] = 0b1111111100010010; big[19] = 0b1111111100010011; big[20] = 0b1111111100010100; big[21] = 0b1111111100010101; big[22] = 0b1111111100010110; big[23] = 0b1111111100010111; big[24] = 0b1111111100011000; big[25] = 0b1111111100011001; big[26] = 0b1111111100011010; big[27] = 0b1111111100011011; big[28] = 0b1111111100011100; big[29] = 0b1111111100011101; big[30] = 0b1111111100011110; big[31] = 0b1111111100011111; big[32] = 0b1111111100100000; big[33] = 0b1111111100100001; big[34] = 0b1111111100100010; big[35] = 0b1111111100100011; big[36] = 0b1111111100100100; big[37] = 0b1111111100100101; big[38] = 0b1111111100100110; big[39] = 0b1111111100100111; big[40] = 0b1111111100101000; big[41] = 0b1111111100101001; big[42] = 0b1111111100101010; big[43] = 0b1111111100101011; big[44] = 0b1111111100101100; big[45] = 0b1111111100101101; big[46] = 0b1111111100101110; big[47] = 0b1111111100101111; big[48] = 0b1111111100110000; big[49] = 0b1111111100110001; big[50] = 0b1111111100110010; big[51] = 0b1111111100110011; big[52] = 0b1111111100110100; big[53] = 0b1111111100110101; big[54] = 0b1111111100110110; big[55] = 0b1111111100110111; big[56] = 0b1111111100111000; big[57] = 0b1111111100111001; big[58] = 0b1111111100111010; big[59] = 0b1111111100111011; big[60] = 0b1111111100111100; big[61] = 0b1111111100111101; big[62] = 0b1111111100111110; big[63] = 0b1111111100111111; big[64] = 0b1111111101000000; big[65] = 0b1111111101000001; big[66] = 0b1111111101000010; big[67] = 0b1111111101000011; big[68] = 0b1111111101000100; big[69] = 0b1111111101000101; big[70] = 0b1111111101000110; big[71] = 0b1111111101000111; big[72] = 0b1111111101001000; big[73] = 0b1111111101001001; big[74] = 0b1111111101001010; big[75] = 0b1111111101001011; big[76] = 0b1111111101001100; big[77] = 0b1111111101001101; big[78] = 0b1111111101001110; big[79] = 0b1111111101001111; big[80] = 0b1111111101010000; big[81] = 0b1111111101010001; big[82] = 0b1111111101010010; big[83] = 0b1111111101010011; big[84] = 0b1111111101010100; big[85] = 0b1111111101010101; big[86] = 0b1111111101010110; big[87] = 0b1111111101010111; big[88] = 0b1111111101011000; big[89] = 0b1111111101011001; big[90] = 0b1111111101011010; big[91] = 0b1111111101011011; big[92] = 0b1111111101011100; big[93] = 0b1111111101011101; big[94] = 0b1111111101011110; big[95] = 0b1111111101011111; big[96] = 0b1111111101100000; big[97] = 0b1111111101100001; big[98] = 0b1111111101100010; big[99] = 0b1111111101100011; big[100] = 0b1111111101100100; big[101] = 0b1111111101100101; big[102] = 0b1111111101100110; big[103] = 0b1111111101100111; big[104] = 0b1111111101101000; big[105] = 0b1111111101101001; big[106] = 0b1111111101101010; big[107] = 0b1111111101101011; big[108] = 0b1111111101101100; big[109] = 0b1111111101101101; big[110] = 0b1111111101101110; big[111] = 0b1111111101101111; big[112] = 0b1111111101110000; big[113] = 0b1111111101110001; big[114] = 0b1111111101110010; big[115] = 0b1111111101110011; big[116] = 0b1111111101110100; big[117] = 0b1111111101110101; big[118] = 0b1111111101110110; big[119] = 0b1111111101110111; big[120] = 0b1111111101111000; big[121] = 0b1111111101111001; big[122] = 0b1111111101111010; big[123] = 0b1111111101111011; big[124] = 0b1111111101111100; big[125] = 0b1111111101111101; big[126] = 0b1111111101111110; big[127] = 0b1111111101111111; big[128] = 0b1111111110000000; big[129] = 0b1111111110000001; big[130] = 0b1111111110000010; big[131] = 0b1111111110000011; big[132] = 0b1111111110000100; big[133] = 0b1111111110000101; big[134] = 0b1111111110000110; big[135] = 0b1111111110000111; big[136] = 0b1111111110001000; big[137] = 0b1111111110001001; big[138] = 0b1111111110001010; big[139] = 0b1111111110001011; big[140] = 0b1111111110001100; big[141] = 0b1111111110001101; big[142] = 0b1111111110001110; big[143] = 0b1111111110001111; big[144] = 0b1111111110010000; big[145] = 0b1111111110010001; big[146] = 0b1111111110010010; big[147] = 0b1111111110010011; big[148] = 0b1111111110010100; big[149] = 0b1111111110010101; big[150] = 0b1111111110010110; big[151] = 0b1111111110010111; big[152] = 0b1111111110011000; big[153] = 0b1111111110011001; big[154] = 0b1111111110011010; big[155] = 0b1111111110011011; big[156] = 0b1111111110011100; big[157] = 0b1111111110011101; big[158] = 0b1111111110011110; big[159] = 0b1111111110011111; big[160] = 0b1111111110100000; big[161] = 0b1111111110100001; big[162] = 0b1111111110100010; big[163] = 0b1111111110100011; big[164] = 0b1111111110100100; big[165] = 0b1111111110100101; big[166] = 0b1111111110100110; big[167] = 0b1111111110100111; big[168] = 0b1111111110101000; big[169] = 0b1111111110101001; big[170] = 0b1111111110101010; big[171] = 0b1111111110101011; big[172] = 0b1111111110101100; big[173] = 0b1111111110101101; big[174] = 0b1111111110101110; big[175] = 0b1111111110101111; big[176] = 0b1111111110110000; big[177] = 0b1111111110110001; big[178] = 0b1111111110110010; big[179] = 0b1111111110110011; big[180] = 0b1111111110110100; big[181] = 0b1111111110110101; big[182] = 0b1111111110110110; big[183] = 0b1111111110110111; big[184] = 0b1111111110111000; big[185] = 0b1111111110111001; big[186] = 0b1111111110111010; big[187] = 0b1111111110111011; big[188] = 0b1111111110111100; big[189] = 0b1111111110111101; big[190] = 0b1111111110111110; big[191] = 0b1111111110111111; big[192] = 0b1111111111000000; big[193] = 0b1111111111000001; big[194] = 0b1111111111000010; big[195] = 0b1111111111000011; big[196] = 0b1111111111000100; big[197] = 0b1111111111000101; big[198] = 0b1111111111000110; big[199] = 0b1111111111000111; big[200] = 0b1111111111001000; big[201] = 0b1111111111001001; big[202] = 0b1111111111001010; big[203] = 0b1111111111001011; big[204] = 0b1111111111001100; big[205] = 0b1111111111001101; big[206] = 0b1111111111001110; big[207] = 0b1111111111001111; big[208] = 0b1111111111010000; big[209] = 0b1111111111010001; big[210] = 0b1111111111010010; big[211] = 0b1111111111010011; big[212] = 0b1111111111010100; big[213] = 0b1111111111010101; big[214] = 0b1111111111010110; big[215] = 0b1111111111010111; big[216] = 0b1111111111011000; big[217] = 0b1111111111011001; big[218] = 0b1111111111011010; big[219] = 0b1111111111011011; big[220] = 0b1111111111011100; big[221] = 0b1111111111011101; big[222] = 0b1111111111011110; big[223] = 0b1111111111011111; big[224] = 0b1111111111100000; big[225] = 0b1111111111100001; big[226] = 0b1111111111100010; big[227] = 0b1111111111100011; big[228] = 0b1111111111100100; big[229] = 0b1111111111100101; big[230] = 0b1111111111100110; big[231] = 0b1111111111100111; big[232] = 0b1111111111101000; big[233] = 0b1111111111101001; big[234] = 0b1111111111101010; big[235] = 0b1111111111101011; big[236] = 0b1111111111101100; big[237] = 0b1111111111101101; big[238] = 0b1111111111101110; big[239] = 0b1111111111101111; big[240] = 0b1111111111110000; big[241] = 0b1111111111110001; big[242] = 0b1111111111110010; big[243] = 0b1111111111110011; big[244] = 0b1111111111110100; big[245] = 0b1111111111110101; big[246] = 0b1111111111110110; big[247] = 0b1111111111110111; big[248] = 0b1111111111111000; big[249] = 0b1111111111111001; big[250] = 0b1111111111111010; big[251] = 0b1111111111111011; big[252] = 0b1111111111111100; big[253] = 0b1111111111111101; big[254] = 0b1111111111111110; big[255] = 0b1111111111111111; for (i = 0; i < 256; i++) { if (big[i] != i + 65280U) return 1; } return 0; }
sethcoder/cc65
testcode/lib/atari/sys.c
<filename>testcode/lib/atari/sys.c /* ** testprogram for _sys() function on Atari ** ** 17-Sep-2013, <EMAIL> ** ** uses PUTCHR IOCB function to display a string */ #include <atari.h> #include <6502.h> #include <conio.h> static struct regs regs; static struct __iocb *iocb = &IOCB; /* use IOCB #0 */ static char message[] = "I'm the sys test text\n"; int main(void) { /* setup IOCB for CIO call */ iocb->buffer = message; iocb->buflen = sizeof(message) - 1; iocb->command = IOCB_PUTCHR; /* setup input registers */ regs.x = 0; /* IOCB #0 */ regs.pc = 0xe456; /* CIOV */ /* call CIO */ _sys(&regs); if (regs.y != 1) cprintf("CIO error 0x%02\r\n", regs.y); cgetc(); return 0; }
sethcoder/cc65
testcode/lib/pce/conio.c
#include <pce.h> #include <conio.h> #include <time.h> #include <joystick.h> #include <string.h> #include <stdlib.h> static int datavar = 10; void main(void) { int stackvar = 42; int i, j; clock_t clk; char* p; unsigned char xsize, ysize, n, nn; joy_install(&joy_static_stddrv); clrscr(); screensize(&xsize, &ysize); cputs("hello world"); cputsxy(0, 2, "colors:" ); for (i = 0; i < 16; ++i) { textcolor(i); cputc('X'); } textcolor(1); gotoxy(0,4); cprintf("datavar: %02x\n\r", datavar); cprintf("stackvar: %02x\n\r", stackvar); j = joy_count(); gotoxy(0,9); cprintf("Found %d Joysticks.", j); for (i = 0; i < 4; ++i) { gotoxy(0, 16 + i); p = malloc(16); memcpy(p, "0123456789abcdef", 16); cprintf("alloc'ed at: %04p - %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p, p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7], p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15] ); } memcpy(p, main, i = 0); /* test that a zero length doesn't copy 64K */ gotoxy(0,ysize - 1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } for (i = 0; i < (xsize * 5); ++i) { cputc('#'); } gotoxy(0,ysize - 1 - ((256 + xsize) / xsize)); for (i = 0; i < 256; ++i) { if ((i != '\n') && (i != '\r')) { cputc(i); } } i = get_tv(); gotoxy(30,0); cputs("TV Mode: "); switch(i) { case TV_NTSC: cputs("NTSC"); break; case TV_PAL: cputs("PAL"); break; case TV_OTHER: cputs("OTHER"); break; } cprintf(" %dx%d", xsize, ysize); for(;;) { gotoxy(13,4); cprintf("%02x", datavar); gotoxy(13,5); cprintf("%02x", stackvar); ++datavar; ++stackvar; gotoxy(0,7); clk = clock(); cprintf("clock: %08lx", clk); for (i = 0; i < 4; ++i) { gotoxy(0, 11 + i); j = joy_read (i); cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s%-6s%-6s", i, j, JOY_UP(j)? " up " : " ---- ", JOY_DOWN(j)? " down " : " ---- ", JOY_LEFT(j)? " left " : " ---- ", JOY_RIGHT(j)? "right " : " ---- ", JOY_BTN_I(j)? "btn I " : " ---- ", JOY_BTN_II(j)? "btn II" : " ---- ", JOY_SELECT(j)? "select" : " ---- ", JOY_RUN(j)? " run " : " ---- "); } gotoxy(xsize - 10, 3); nn = (n >> 5) & 1; revers(nn); cputc(nn ? 'R' : ' '); cputs(" revers"); revers(0); if ((n & 0x1f) == 0x00) { nn = p[15]; ((char*)memmove(p + 1, p, 15))[-1] = nn; gotoxy(22, 19); cprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p[0],p[1],p[ 2],p[ 3],p[ 4],p[ 5],p[ 6],p[ 7], p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]); } waitvsync(); ++n; } }
sethcoder/cc65
testcode/lib/shift-test.c
<reponame>sethcoder/cc65<filename>testcode/lib/shift-test.c #include <stdio.h> #include <stdlib.h> static unsigned UnsignedShiftLeft1 (unsigned Val) /* Shift an unsigned left by 1 */ { __AX__ = Val; asm ("stx tmp1"); asm ("asl a"); asm ("rol tmp1"); asm ("ldx tmp1"); return __AX__; } static unsigned UnsignedShiftRight1 (unsigned Val) /* Shift an unsigned right by 1 */ { __AX__ = Val; asm ("stx tmp1"); asm ("lsr tmp1"); asm ("ror a"); asm ("ldx tmp1"); return __AX__; } static int SignedShiftRight1 (int Val) /* Shift a signed right by 1 */ { __AX__ = Val; asm ("stx tmp1"); asm ("cpx #$80"); asm ("ror tmp1"); asm ("ror a"); asm ("ldx tmp1"); return __AX__; } static void TestUnsignedLeftShift (void) /* Test left shift. This is identical for signed and unsigned ints */ { unsigned L, R, V; printf ("Testing unsigned left shift:\n"); L = 0; do { V = L; for (R = 0; R < 16; ++R) { /* Check it */ if ((L << R) != V) { fprintf (stderr, "Failed: %u << %u != %u (%u)\n", L, R, V, L << R); exit (1); } V = UnsignedShiftLeft1 (V); } if ((L & 0xFF) == 0) { printf ("%04X ", L); } } while (++L != 0); printf ("\n"); } static void TestUnsignedRightShift (void) /* Test unsigned right shift. */ { unsigned L, R, V; printf ("Testing unsigned right shift:\n"); L = 0; do { V = L; for (R = 0; R < 16; ++R) { /* Check it */ if ((L >> R) != V) { fprintf (stderr, "Failed: %u >> %u != %u (%u)\n", L, R, V, L >> R); exit (1); } V = UnsignedShiftRight1 (V); } if ((L & 0xFF) == 0) { printf ("%04X ", L); } } while (++L != 0); printf ("\n"); } static void TestSignedRightShift (void) /* Test signed right shift. */ { int L, R, V; printf ("Testing signed right shift:\n"); L = 0; do { V = L; for (R = 0; R < 16; ++R) { /* Check it */ if ((L >> R) != V) { fprintf (stderr, "Failed: %d >> %d != %d (%d)\n", L, R, V, L >> R); exit (1); } V = SignedShiftRight1 (V); } if ((L & 0xFF) == 0) { printf ("%04X ", L); } } while (++L != 0); printf ("\n"); } int main (void) { TestUnsignedLeftShift (); TestUnsignedRightShift (); TestSignedRightShift (); printf ("\nOk!\n"); return 0; }
sethcoder/cc65
src/common/tgttrans.c
<filename>src/common/tgttrans.c<gh_stars>1-10 /*****************************************************************************/ /* */ /* tgttrans.c */ /* */ /* Character set translation */ /* */ /* */ /* */ /* (C) 2000-2012, <NAME> */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: <EMAIL> */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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. */ /* */ /*****************************************************************************/ #include <string.h> /* common */ #include "check.h" #include "target.h" #include "tgttrans.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* Translation table actually used. Default is no translation */ static unsigned char Tab[256] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, }; /*****************************************************************************/ /* Code */ /*****************************************************************************/ void TgtTranslateInit (void) /* Initialize the translation tables */ { /* Copy the translation for the selected target */ memcpy (Tab, GetTargetProperties (Target)->CharMap, sizeof (Tab)); } int TgtTranslateChar (int C) /* Translate one character from the source character set into the target ** system character set. */ { /* Translate */ return Tab[C & 0xFF]; } void TgtTranslateBuf (void* Buf, unsigned Len) /* Translate a buffer of the given length from the source character set into ** the target system character set. */ { /* Translate */ unsigned char* B = (unsigned char*)Buf; while (Len--) { *B = Tab[*B]; ++B; } } void TgtTranslateStrBuf (StrBuf* Buf) /* Translate a string buffer from the source character set into the target ** system character set. */ { TgtTranslateBuf (SB_GetBuf (Buf), SB_GetLen (Buf)); } void TgtTranslateSet (unsigned Index, unsigned char C) /* Set the translation code for the given character */ { CHECK (Index < sizeof (Tab)); Tab[Index] = C; }
sethcoder/cc65
samples/geos/geosver.c
<reponame>sethcoder/cc65 #include <geos.h> #include <conio.h> // Let's define the window we're operating struct window wholeScreen = {0, SC_PIX_HEIGHT-1, 0, SC_PIX_WIDTH-1}; void main (void) { unsigned char os = get_ostype(); unsigned char *machine = NULL; unsigned char *version = NULL; unsigned char good = 1; SetPattern(0); InitDrawWindow(&wholeScreen); Rectangle(); gotoxy(0, 4); if (os == GEOS4) { machine = "plus4"; version = "GEOS v3.5"; } else { if ((os & GEOS128) == GEOS128) { machine = "c128"; } else { machine = "c64"; } os &= 0x7f; if (os == GEOS_V10) { version = "GEOS v1.0"; } else if (os == GEOS_V11) { version = "GEOS v1.1"; } else if (os == GEOS_V12) { version = "GEOS v1.2"; } else if (os == GEOS_V13) { version = "GEOS v1.3"; } else if (os == GEOS_V15) { version = "GEOS v1.5"; } else if (os == GEOS_V20) { version = "GEOS v2.0"; } else if (os == MEGAPATCH3) { version = "MegaPatch 3"; } else if (os == GATEWAY) { version = "GateWay"; } else if ((os & WHEELS) == WHEELS) { version = "Wheels"; } else { version = "Unknown GEOS version"; good = 0; } } if (good) { cprintf("%s (%s)", version, machine); } else { cprintf("%s (%s) (%d)", version, machine, os); } Sleep(10*50); return; }
sethcoder/cc65
testcode/compiler/pptest1.c
<gh_stars>1-10 #define hash_hash # ## # #define mkstr(a) # a #define in_between(a) mkstr(a) #define join(c, d) in_between(c hash_hash d) char p[] = join(x, y); // Comment
sethcoder/cc65
include/geos/gstruct.h
/* GEOS structs by Maciej 'YTM/Elysium' Witkowiak */ /* apart from initializing data, structures below can be used to speed up access to data and let cc65 to generate better code e.g. if you have menu defined as TopMenu and you want to change the number of menu items use: ((struct menu*)&TopMenu)->number=newNumber; This will be translated into single lda/sta pair */ #ifndef _GSTRUCT_H #define _GSTRUCT_H typedef void (*void_func) (void); struct s_date { /* system date & time */ char s_year; char s_month; char s_day; char s_hour; char s_minutes; char s_seconds; }; struct tr_se { /* track and sector */ char track; char sector; }; struct fileheader { /* header block (like fileHeader) */ struct tr_se n_block; char icon_desc[3]; char icon_pic[63]; char dostype; char type; char structure; unsigned load_address; unsigned end_address; unsigned exec_address; char class_name[19]; char column_flag; char author[63]; char note[96]; }; #ifdef __GEOS_CBM__ struct f_date { /* date in filedesctiptor */ char f_year; char f_month; char f_day; char f_hour; char f_minute; }; struct filehandle { /* filehandle in directory sectors */ char dostype; /* or in dirEntryBuf */ struct tr_se n_block; char name[16]; struct tr_se header; char structure; char type; struct f_date date; unsigned size; }; #else /* #ifdef __GEOS_CBM__ */ struct f_date { /* date in filedesctiptor */ unsigned f_day:5; unsigned f_month:4; unsigned f_year:7; char f_minute; char f_hour; }; struct filehandle { /* filehandle in directory sectors */ unsigned name_len:4; /* or in dirEntryBuf */ unsigned structure:4; char name[15]; char type; struct tr_se n_block; unsigned size; char byte_size[3]; struct f_date date; char version; char min_version; char access; struct tr_se header; struct f_date mod_date; struct tr_se dir_head; }; #endif /* #ifdef __GEOS_CBM__ */ struct pixel { /* describes point */ unsigned x; char y; }; struct fontdesc { /* describes font */ char baseline; char width; char height; char *index_tbl; char *data_ptr; }; struct window { /* describes screen region */ char top; char bot; unsigned left; unsigned right; }; struct VLIR_info { /* VLIR information */ char curRecord; /* currently only used in VLIR */ char usedRecords; /* as system info (curRecord is mainly of your interest */ char fileWritten; unsigned fileSize; }; struct process { /* process info, declare table of that type */ unsigned pointer; /* (like: struct process proctab[2]=... */ unsigned jiffies; /* last entry HAVE TO BE {0,0} */ }; struct iconpic { /* icon/encoded bitmap description */ char *pic_ptr; /* ptr to a photo scrap (or encoded bitmap) */ char x; /* position in cards (*8 pixels) */ char y; char width; /* in cards */ char heigth; /* in lines (pixels) */ }; struct icondef { /* icon definition for DoIcons */ char *pic_ptr; /* ptr to a photo scrap (or encoded bitmap) */ char x; /* position in cards (*8 pixels) */ char y; char width; /* of icon (in cards) */ char heigth; /* of icon in lines (pixels) */ unsigned proc_ptr; /* pointer to function handling that icon */ }; struct icontab { char number; /* number of declared icons */ struct pixel mousepos; /* position of mouse after DoIcons */ struct icondef tab[]; /* table of size declared by icontab.number */ }; struct menuitem { char *name; char type; void *rest; /* may be ptr to function, or ptr to struct menu (submenu) */ }; struct menu { struct window size; char number; struct menuitem items[]; }; struct inittab { /* use struct inittab mytab[n] for initram */ unsigned ptr; /* ptr to 1st byte */ char number; /* number of following bytes */ char values[]; /* actual string of bytes */ }; #endif
sethcoder/cc65
testcode/compiler/pptest3.c
<reponame>sethcoder/cc65<gh_stars>1-10 #define str(s) # s #define xstr(s) str(s) #define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ x ## s, x ## t) #define INCFILE(n) vers ## n // Comment #define glue(a,b) a ## b #define xglue(a,b) glue(a,b) #define HIGHLOW "hello" #define LOW LOW ", world" debug (1, 2); fputs (str (strncmp("abc\0d", "abc", '\4') // Comment == 0) str (: @\n), s); glue (HIGH, LOW); xglue (HIGH, LOW);
sethcoder/cc65
test/val/rotate6.c
/* !!DESCRIPTION!! Shift bytes left and right by a variable. !!ORIGIN!! SDCC regression tests !!LICENCE!! GPL, read COPYING.GPL */ #include <stdio.h> #include <limits.h> unsigned char success=0; unsigned char failures=0; unsigned char dummy=0; #ifdef SUPPORT_BIT_TYPES bit bit0 = 0; #endif #ifdef SIZEOF_INT_16BIT #if defined(__LINUX__) || defined(LINUX) signed short aint0 = 0; signed short aint1 = 0; #else signed int aint0 = 0; signed int aint1 = 0; #endif #else signed int aint0 = 0; signed int aint1 = 0; #endif signed char achar0 = 0; signed char achar1 = 0; signed char achar2 = 0; signed char achar3 = 0; void done() { dummy++; } void shift_right_var(void) { achar0 >>= achar1; } void shift_left_var(void) { achar0 <<= achar1; } void shift_int_left_var(void) { aint0 <<= achar1; } void shift_int_right_var(void) { aint0 >>= achar1; } void shift_int_right_var2(void) { aint0 = aint1 >> achar1; } void shift_int_left_var2(void) { aint0 = aint1 << achar1; } int main (void) { char i; achar0 = 1; achar1 = 1; shift_left_var(); if(achar0 !=2) failures++; printf("failures: %d\n",failures); achar0 = 1; achar1 = 1; achar2 = 1; for(i=0; i<7; i++) { shift_left_var(); achar2 <<= 1; if(achar2 != achar0) failures++; } printf("failures: %d\n",failures); achar1 = 4; achar0 = 0xf0; shift_right_var(); if(((unsigned char)achar0) != 0xff) failures++; printf("failures: %d\n",failures); aint0 = 1; aint1 = 1; achar1 = 1; for(i=0; i<15; i++) { shift_int_left_var(); aint1 <<= 1; if(aint0 != aint1) failures++; } printf("failures: %d\n",failures); aint0 = 0x4000; aint1 = 0x4000; for(i=0; i<15; i++) { shift_int_right_var(); aint1 >>= 1; if(aint0 != aint1) failures++; } printf("failures: %d\n",failures); aint0 = -0x4000; aint1 = -0x4000; for(i=0; i<15; i++) { shift_int_right_var(); aint1 >>= 1; if(aint0 != aint1) failures++; } printf("failures: %d\n",failures); aint1 = 0xf000; achar1 = 10; shift_int_right_var2(); if(((unsigned short)aint0) != 0xfffc) failures++; printf("failures: %d\n",failures); aint1 = aint0; shift_int_left_var2(); if(((unsigned short)aint0) != 0xf000) failures++; success=failures; done(); printf("failures: %d\n",failures); return failures; }