You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,79 @@ These features were finally added to eigenpy with a lot of developer effort. Thi
13
13
14
14
## Features
15
15
16
+
**nanoeigenpy** provides the following features for helping you bind features from Eigen to Python:
17
+
16
18
- bindings for Eigen's [Geometry module](https://libeigen.gitlab.io/docs/group__Geometry__Module.html) - quaternions, angle-axis representations...
17
19
- bindings for Eigen's matrix dense and sparse decompositions and solvers
18
20
21
+
## Example usage
22
+
23
+
The features included in **nanoeigenpy** are distributed in a Python module which can be imported, or through standalone headers which can be included in your own Python bindings code using a CMake target.
24
+
25
+
### Using the nanoeigenpy headers (with CMake)
26
+
27
+
To directly use the tools in **nanoeigenpy**'s headers, link to it in CMake (or whichever build tool you have, but only CMake support is planned so far).
In the case above, **nanoeigenpy**'s Python extension module already includes bindings for `Eigen::Quaternion` with the `double` scalar type (AKA `Eigen::Quaterniond`). Then, we can simply get nanobind to import it in our extension module:
57
+
58
+
```cpp
59
+
#include <Eigen/Geometry>
60
+
61
+
namespace nb = nanobind;
62
+
63
+
void f(const Eigen::Quaterniond &quat) {
64
+
// ...
65
+
}
66
+
67
+
NB_MODULE(my_ext, m) {
68
+
// import nanoeigenpy's module **here**
69
+
nb::module_::import_("nanoeigenpy");
70
+
m.def("f", f, nb::arg("quat"));
71
+
}
72
+
```
73
+
74
+
Alternatively, Python code which uses our extension `my_ext` can also bring in **nanoeigenpy**:
75
+
76
+
```python
77
+
import nanoeigenpy
78
+
from nanoeigenpy import Quaternion
79
+
from my_ext import f
80
+
81
+
quat = Quaternion(0., 1., 0., 0.)
82
+
f(quat)
83
+
```
84
+
85
+
> [!NOTE]
86
+
> If you have a specific scalar type (e.g. `float16`) with which you want to use `Eigen::Quaternion`, or matrix solvers, or other features in **nanoeigenpy**, you should refer to the first approach and use **nanoeigenpy** from C++ directly.
87
+
88
+
19
89
## Installation
20
90
21
91
### Dependencies
@@ -28,3 +98,11 @@ These features were finally added to eigenpy with a lot of developer effort. Thi
28
98
```bash
29
99
conda install -c conda-forge nanobind eigen # or mamba install
30
100
```
101
+
102
+
#### Building
103
+
104
+
```bash
105
+
cmake -S . -B build/ -DCMAKE_INSTALL_PREFIX=<your-prefix># prefix can be e.g. $CONDA_PREFIX
0 commit comments