This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include "cpp_test_sum_.h" | |
| using namespace std; | |
| namespace cpp_test_sum{ | |
| // Constructor | |
| cppTestSum::cppTestSum(int n_iter) | |
| : | |
| n_iter(n_iter), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef CPPTESTSUM_H | |
| #define CPPTESTSUM_H | |
| #include <vector> | |
| using namespace std; | |
| namespace cpp_test_sum{ | |
| class cppTestSum{ | |
| public: | |
| int n_iter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <fstream> | |
| #include <string> | |
| #include <sstream> | |
| #include <vector> | |
| #include <iostream> | |
| #include <math.h> | |
| #include <ctime> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from tradingrrl import TradingRRL, plot_hist | |
| def main(): | |
| fname = "USDJPY30.csv" | |
| init_t = 6000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from distutils.core import setup | |
| from distutils.extension import Extension | |
| from Cython.Distutils import build_ext | |
| import numpy | |
| setup( | |
| cmdclass = {'build_ext': build_ext}, | |
| ext_modules = [ | |
| Extension("tradingrrl", sources=["tradingrrl.pyx"], include_dirs=[numpy.get_include()],) | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| #cython: boundscheck=False | |
| #cython: wraparound=False | |
| #cython: nonecheck=False | |
| import numpy as np | |
| cimport numpy as np | |
| cimport cython | |
| ctypedef np.float64_t DOUBLE_t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import py_test_sum | |
| import cy_test_sum | |
| n_iter = 10000000 | |
| #--- Python sum | |
| py_ts = py_test_sum.TestSum(n_iter) | |
| tic = time.clock() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from distutils.core import setup | |
| from distutils.extension import Extension | |
| from Cython.Distutils import build_ext | |
| import numpy | |
| setup( | |
| cmdclass = {'build_ext': build_ext}, | |
| ext_modules = [ | |
| Extension("cy_test_sum", sources=["cy_test_sum.pyx"], include_dirs=[numpy.get_include()],) | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| cimport numpy as np | |
| cimport cython | |
| ctypedef np.float64_t DOUBLE_t | |
| cdef class TestSum(object): | |
| cdef public int n_iter | |
| cdef public np.ndarray sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| class TestSum(object): | |
| def __init__(self, n_iter): | |
| self.n_iter = n_iter | |
| self.sum = np.zeros(n_iter) | |
| def calc_sum(self): | |
| for i in range(1, self.n_iter): |