libqe 0.2.6-dev.9001
QE C++ library
Loading...
Searching...
No Matches
nanobind.hpp File Reference

Armadillo ↔ numpy conversion helpers for nanobind (Python) bindings. More...

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <armadillo>
#include <algorithm>
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Namespaces

namespace  qe
 
namespace  qe::bind
 
namespace  qe::bind::py
 

Typedefs

using qe::bind::py::NpMat = ::nanobind::ndarray< double, ::nanobind::ndim< 2 >, ::nanobind::c_contig, ::nanobind::device::cpu >
 
using qe::bind::py::NpVec = ::nanobind::ndarray< double, ::nanobind::ndim< 1 >, ::nanobind::c_contig, ::nanobind::device::cpu >
 
using qe::bind::py::NpIMat = ::nanobind::ndarray< int32_t, ::nanobind::ndim< 2 >, ::nanobind::c_contig, ::nanobind::device::cpu >
 

Functions

arma::mat qe::bind::py::to_mat (NpMat arr)
 
arma::rowvec qe::bind::py::to_rowvec (NpVec arr)
 
arma::vec qe::bind::py::to_vec (NpVec arr)
 
arma::imat qe::bind::py::to_imat (NpIMat arr)
 
inline ::nanobind::ndarray<::nanobind::numpy, double, ::nanobind::ndim< 2 > > qe::bind::py::from_mat (const arma::mat &m)
 
inline ::nanobind::ndarray<::nanobind::numpy, double, ::nanobind::ndim< 1 > > qe::bind::py::from_rowvec (const arma::rowvec &v)
 
inline ::nanobind::ndarray<::nanobind::numpy, double, ::nanobind::ndim< 1 > > qe::bind::py::from_vec (const arma::vec &v)
 
inline ::nanobind::ndarray<::nanobind::numpy, int64_t, ::nanobind::ndim< 2 > > qe::bind::py::from_umat (const arma::umat &m)
 
inline ::nanobind::ndarray<::nanobind::numpy, int64_t, ::nanobind::ndim< 1 > > qe::bind::py::from_uvec (const arma::uvec &v)
 

Detailed Description

Armadillo ↔ numpy conversion helpers for nanobind (Python) bindings.

Armadillo stores matrices in column-major order; numpy defaults to row-major. Every helper copies on the boundary so callers never see stale memory, and every returned array is freshly allocated and owned by Python.

Requires nanobind; never included by libqe.hpp. Bindings typically using namespace qe::bind::py; after including it.