FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

/*************************************************************************** * Copyright (c) 2016, Johan Mabille and Sylvain Corlay * * * * Distributed under the terms of the BSD 3-Clause License. * * * * The full license is in the file LICENSE, distributed with this software. * ****************************************************************************/ #include #include "xtensor/xmath.hpp" #include "xtensor/xarray.hpp" #define FORCE_IMPORT_ARRAY #include "xtensor-python/pyarray.hpp" #include "xtensor-python/pytensor.hpp" #include "xtensor-python/pyvectorize.hpp" namespace py = pybind11; using complex_t = std::complex; // Examples double example1(xt::pyarray& m) { return m(0); } xt::pyarray example2(xt::pyarray& m) { return m + 2; } // Readme Examples double readme_example1(xt::pyarray& m) { auto sines = xt::sin(m); return std::accumulate(sines.cbegin(), sines.cend(), 0.0); } double readme_example2(double i, double j) { return std::sin(i) - std::cos(j); } auto complex_overload(const xt::pyarray& a) { return a; } auto no_complex_overload(const xt::pyarray& a) { return a; } auto complex_overload_reg(const std::complex& a) { return a; } auto no_complex_overload_reg(const double& a) { return a; } // Vectorize Examples int add(int i, int j) { return i + j; } template std::string typestring() { return "Unknown"; } template std::string typestring() { return "uint8"; } template std::string typestring() { return "int8"; } template std::string typestring() { return "uint16"; } template std::string typestring() { return "int16"; } template std::string typestring() { return "uint32"; } template std::string typestring() { return "int32"; } template std::string typestring() { return "uint64"; } template std::string typestring() { return "int64"; } template inline std::string int_overload(xt::pyarray& m) { return typestring(); } void dump_numpy_constant() { std::cout

Back | FazBrowse Home | New Git URL