GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pybind11_cpp_python/cpp_call_python_numpy/example.cpp at master · ZQPei/pybind11_cpp_python Expand file tree/ Copy pathexample.cppMore file actions 23 lines (18 loc) · 666 Bytes / Copy pathexample.cppFile metadata and controls23 lines (18 loc) · 666 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include <pybind11/embed.h> #include <pybind11/eigen.h> #include <Eigen/LU> #include <iostream> namespace py = pybind11; int main(){ py::scoped_interpreter guard{}; // you should have eigen installed first py::module m = py::module::import("algo"); Eigen::MatrixXd a = Eigen::MatrixXd::Random(3,3); std::cout<<"a[0,0] = "<<a(0,0)<<std::endl; std::cout<<"det of a = "<<a.determinant()<<std::endl; std::cout<<"inv of a = "<<a.inverse()<<std::endl; // in pybind11, eigen MatrixXd type will convert to python numpy ndarray automaticly py::print("det of a =",m.attr("det")(a)); py::print(m.attr("inv")(a)); return 0; } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |