libena 0.4.18-dev.9021
QE C++ library
Loading...
Searching...
No Matches
cxxwrap.hpp
Go to the documentation of this file.
1
20#ifndef LIBENA_BIND_CXXWRAP_HPP
21#define LIBENA_BIND_CXXWRAP_HPP
22
23#include <libqe/bind/cxxwrap.hpp>
24#include <jlcxx/stl.hpp>
25#include <jlcxx/tuple.hpp>
26
27#include <libena/rotation.hpp>
28#include <libena/positions.hpp>
29#include <libena/ccd.hpp>
30
31#include <cstdint>
32#include <string>
33#include <tuple>
34#include <vector>
35
36namespace qe {
37namespace bind {
38namespace jl {
39
40inline std::vector<double> pack(const arma::vec& v) {
41 return std::vector<double>(v.memptr(), v.memptr() + v.n_elem);
42}
43
46using NodePositionsTuple = std::tuple<
47 std::vector<double>, int32_t, int32_t,
48 std::vector<double>, int32_t, int32_t,
49 std::vector<double>, int32_t, int32_t,
50 std::vector<double>, int32_t, int32_t>;
51
53 auto n = [](const arma::mat& m) { return static_cast<int32_t>(m.n_rows); };
54 auto c = [](const arma::mat& m) { return static_cast<int32_t>(m.n_cols); };
55 return {pack(r.nodes), n(r.nodes), c(r.nodes),
56 pack(r.centroids), n(r.centroids), c(r.centroids),
57 pack(r.weights), n(r.weights), c(r.weights),
58 pack(r.points), n(r.points), c(r.points)};
59}
60
62using MovedNodesTuple = std::tuple<
63 std::vector<double>, int32_t, int32_t,
64 std::vector<double>, int32_t, int32_t>;
65
67 auto n = [](const arma::mat& m) { return static_cast<int32_t>(m.n_rows); };
68 auto c = [](const arma::mat& m) { return static_cast<int32_t>(m.n_cols); };
69 return {pack(r.nodes), n(r.nodes), c(r.nodes),
70 pack(r.centroids), n(r.centroids), c(r.centroids)};
71}
72
74using RotationTuple = std::tuple<
75 std::vector<double>, int32_t, int32_t,
76 std::vector<double>,
77 std::vector<std::string>>;
78
80 return {pack(r.rotation),
81 static_cast<int32_t>(r.rotation.n_rows),
82 static_cast<int32_t>(r.rotation.n_cols),
84 r.column_names};
85}
86
89using CCDTuple = std::tuple<
90 int32_t, int32_t,
91 std::vector<double>, std::vector<double>, std::vector<double>,
92 std::vector<double>, std::vector<double>>;
93
95 return {static_cast<int32_t>(r.window_size),
96 static_cast<int32_t>(r.peak_lag),
99}
100
101} // namespace jl
102} // namespace bind
103} // namespace qe
104
105#endif // LIBENA_BIND_CXXWRAP_HPP
Cross-Covariance Decay (CCD) window-size estimation.
NodePositionsTuple to_tuple(const qe::NodePositions &r)
Definition cxxwrap.hpp:52
std::tuple< int32_t, int32_t, std::vector< double >, std::vector< double >, std::vector< double >, std::vector< double >, std::vector< double > > CCDTuple
Definition cxxwrap.hpp:92
std::tuple< std::vector< double >, int32_t, int32_t, std::vector< double >, int32_t, int32_t, std::vector< double >, int32_t, int32_t, std::vector< double >, int32_t, int32_t > NodePositionsTuple
Definition cxxwrap.hpp:50
std::tuple< std::vector< double >, int32_t, int32_t, std::vector< double >, std::vector< std::string > > RotationTuple
(rotation, rows, cols, eigenvalues, column_names)
Definition cxxwrap.hpp:77
std::tuple< std::vector< double >, int32_t, int32_t, std::vector< double >, int32_t, int32_t > MovedNodesTuple
(nodes, rows, cols, centroids, rows, cols)
Definition cxxwrap.hpp:64
std::vector< double > pack(const arma::vec &v)
Definition cxxwrap.hpp:40
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