GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pybind11_cpp_python/cpp_call_python_numpy/example.cpp at master · ZQPei/pybind11_cpp_python

Expand file tree

/

example.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
23 lines (18 loc) · 666 Bytes
/

example.cpp

Copy path

File metadata and controls

23 lines (18 loc) · 666 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.