libena 0.4.18-dev.9021
QE C++ library
Loading...
Searching...
No Matches
nanobind.hpp
Go to the documentation of this file.
1
14#ifndef LIBENA_BIND_NANOBIND_HPP
15#define LIBENA_BIND_NANOBIND_HPP
16
17#include <libqe/bind/nanobind.hpp>
18
19#include <libena/rotation.hpp>
20#include <libena/positions.hpp>
21#include <libena/ccd.hpp>
22
23namespace qe {
24namespace bind {
25namespace py {
26
28inline ::nanobind::dict to_dict(const qe::NodePositions& r) {
29 ::nanobind::dict out;
30 out["nodes"] = from_mat(r.nodes);
31 out["centroids"] = from_mat(r.centroids);
32 out["weights"] = from_mat(r.weights);
33 out["points"] = from_mat(r.points);
34 return out;
35}
36
38inline ::nanobind::dict to_dict(const qe::MovedNodes& r) {
39 ::nanobind::dict out;
40 out["nodes"] = from_mat(r.nodes);
41 out["centroids"] = from_mat(r.centroids);
42 return out;
43}
44
46inline ::nanobind::dict to_dict(const qe::RotationResult& r) {
47 ::nanobind::list names;
48 for (const std::string& s : r.column_names)
49 names.append(::nanobind::str(s.c_str(), s.size()));
50 ::nanobind::dict out;
51 out["rotation"] = from_mat(r.rotation);
52 out["eigenvalues"] = from_vec(r.eigenvalues);
53 out["column_names"] = names;
54 return out;
55}
56
59inline ::nanobind::dict to_dict(const qe::CCDResult& r) {
60 ::nanobind::dict out;
61 out["window_size"] = r.window_size;
62 out["peak_lag"] = r.peak_lag;
63 out["lag"] = from_vec(r.lag);
64 out["frob"] = from_vec(r.frob);
65 out["frob_sq_unbiased"] = from_vec(r.frob_sq_unbiased);
66 out["frob_unbiased_signed"] = from_vec(r.frob_unbiased_signed);
67 out["total_weight"] = from_vec(r.total_weight);
68 return out;
69}
70
71} // namespace py
72} // namespace bind
73} // namespace qe
74
75#endif // LIBENA_BIND_NANOBIND_HPP
Cross-Covariance Decay (CCD) window-size estimation.
inline ::nanobind::dict to_dict(const qe::NodePositions &r)
{nodes, centroids, weights, points}
Definition nanobind.hpp:28
Definition cxxwrap.hpp:36
ENA node-position solvers for undirected and directed networks, the points-to-centroids correlation (...
Rotation routines for Epistemic Network Analysis (ENA): SVD, deflation, orthogonal-SVD,...
Result of a CCD window-size estimation.
Definition ccd.hpp:32
arma::vec frob_unbiased_signed
sign * sqrt(|corrected sq|) per lag.
Definition ccd.hpp:38
arma::vec total_weight
Pooled overlap weight per lag.
Definition ccd.hpp:39
int window_size
Estimated half-life lag window size (>= 1).
Definition ccd.hpp:33
arma::vec frob_sq_unbiased
Noise-corrected squared Frobenius norm per lag.
Definition ccd.hpp:37
arma::vec lag
Evaluated lags, 0..max_window.
Definition ccd.hpp:35
arma::vec frob
Uncorrected pooled Frobenius norm per lag.
Definition ccd.hpp:36
int peak_lag
Lag of the peak corrected cross-covariance norm.
Definition ccd.hpp:34
Result of move_nodes_to_unit_circle.
Definition positions.hpp:47
arma::mat nodes
Moved node locations, n_codes × n_dims.
Definition positions.hpp:48
arma::mat centroids
Centroids recomputed from the moved nodes, n_units × n_dims.
Definition positions.hpp:49
Aggregated result returned by every node-position solver.
Definition positions.hpp:35
arma::mat points
Input rotated points echoed back unchanged, n_units × n_dims.
Definition positions.hpp:39
arma::mat nodes
Solved node locations, n_codes × n_dims.
Definition positions.hpp:36
arma::mat centroids
Per-unit centroids projected onto the node space, n_units × n_dims.
Definition positions.hpp:37
arma::mat weights
Normalised half-edge weight per unit per node, n_units × n_codes.
Definition positions.hpp:38
Aggregated result returned by every rotation routine.
Definition rotation.hpp:33
arma::vec eigenvalues
Length-p vector of sdev^2 values, matching rENA's convention.
Definition rotation.hpp:35
std::vector< std::string > column_names
Axis labels, e.g. "MR1", "SVD2", "GMR1".
Definition rotation.hpp:36
arma::mat rotation
p x p orthogonal matrix; column j is rotation axis j.
Definition rotation.hpp:34