29template <
typename T,
typename U>
44 std::vector<std::vector<double>>
vals;
60template<
typename T,
typename U>
61std::map<T, U>
zip(
const std::vector<T>& ids,
const std::vector<U>& vals) {
62 if (ids.size() != vals.size())
63 throw std::invalid_argument(
"Index and value vector sizes don't match.");
65 std::map<T, U> indexed;
66 for (
size_t i = 0; i < ids.size(); i++) {
67 indexed.emplace(ids.at(i), vals.at(i));
88std::map<T, std::map<T, double>>
zip(
const std::vector<T>& ids,
const std::vector<std::vector<double>>& vals) {
90 throw std::invalid_argument(
"No values to zip.");
92 if (ids.size() != vals.size() || ids.size() != vals.at(0).size())
93 throw std::invalid_argument(
"Index and value sizes don't match or value matrix is not square.");
95 std::map<T, std::map<T, double>> indexed;
96 for (
size_t i = 0; i < ids.size(); i++) {
97 std::map<T, double> row;
98 for (
size_t j = 0; j < ids.size(); j++) {
99 row.emplace(ids[j], vals[i][j]);
101 indexed.emplace(ids[i], std::move(row));
119 std::vector<BinnedObservableId> ids;
120 std::vector<double> vals;
122 for (
auto& [
id, obs_values]: indexed) {
123 for (
auto& obs_val : obs_values) {
126 binned_id.
p = obs_val.bin.value_or(std::pair<double, double> {0., 0.});
127 ids.emplace_back(binned_id);
128 vals.emplace_back(obs_val.value);
149std::map<T, std::map<T, double>>
zip(
const std::vector<T>& ids,
const RealMatrix& vals) {
150 if (ids.size() != vals.rows() || ids.size() != vals.cols())
151 throw std::invalid_argument(
"Index and value sizes don't match or value matrix is not square.");
153 std::map<T, std::map<T, double>> indexed;
154 for (
size_t i = 0; i < ids.size(); i++) {
155 std::map<T, double> row;
156 for (
size_t j = 0; j < ids.size(); j++) {
157 row.emplace(ids[j], vals.unchecked_at(i, j));
159 indexed.emplace(ids[i], std::move(row));
175template<
typename T,
typename U>
180 for (
auto& [
id, v]: indexed) {
181 ids.emplace_back(
id);
182 vals.emplace_back(v);
200 std::vector<std::vector<double>> vals;
202 for (
auto& [
id, row]: indexed) {
203 ids.emplace_back(
id);
204 std::vector<double> row_vals;
205 for (
auto& [_, v] : row) {
206 row_vals.emplace_back(v);
208 vals.emplace_back(std::move(row_vals));
Utilities for identifying observables together with numerical bins.
UnzipResult1D< BinnedObservableId, double > flatten(std::map< ObservableId, std::vector< ObservableValue > > indexed)
Flattens observable values into binned observable ids and values.
std::map< T, U > zip(const std::vector< T > &ids, const std::vector< U > &vals)
Builds a map from parallel id and value vectors.
UnzipResult1D< T, U > unzip(const std::map< T, U > &indexed)
Splits a map into parallel id and value vectors.
Lightweight dense real-matrix utilities built on top of STL storage and GSL backends.
double T(double x)
Wilson coefficient T(x).
Identifies an observable together with a numerical bin.
std::pair< double, double > p
Result of converting a one-dimensional indexed map to dense vectors.
std::vector< U > vals
Values associated with ids.
std::vector< T > ids
Ids in map iteration order.
Result of converting a square indexed matrix to dense vectors.
std::vector< T > ids
Row and column ids in map iteration order.
std::vector< std::vector< double > > vals
Dense square matrix values.