14 #include "backend/Storage.hpp"
35 Histogram(
const unsigned long long &Nbins,
const double &min_val,
const double &max_val);
41 this->bins = rhs.
bins;
42 this->vars = rhs.
vars.clone();
43 this->x = rhs.
x.clone();
50 this->bins = rhs.
bins;
51 this->vars = rhs.
vars.clone();
52 this->x = rhs.
x.clone();
60 memset(this->vars.data(), 0,
sizeof(
double) * this->vars.size());
65 std::vector<T> tmp = data;
66 std::sort(tmp.begin(), tmp.end());
73 for (
unsigned long long i = 0; i < tmp.size(); i++) {
74 while (cntr <= this->
bins) {
75 if (tmp[i] < curr_x) {
77 vars.at<
double>(cntr - 1) += 1;
122 Histogram2d(
const unsigned long long &Nbinx,
const unsigned long long &Nbiny,
123 const double &min_x,
const double &max_x,
const double &min_y,
124 const double &max_y);
128 this->minx = rhs.
minx;
129 this->maxx = rhs.
maxx;
130 this->miny = rhs.
miny;
131 this->maxy = rhs.
maxy;
132 this->binx = rhs.
binx;
133 this->biny = rhs.
biny;
134 this->vars = rhs.
vars.clone();
135 this->x = rhs.
x.clone();
136 this->y = rhs.
y.clone();
141 this->minx = rhs.
minx;
142 this->maxx = rhs.
maxx;
143 this->miny = rhs.
miny;
144 this->maxy = rhs.
maxy;
145 this->binx = rhs.
binx;
146 this->biny = rhs.
biny;
147 this->vars = rhs.
vars.clone();
148 this->x = rhs.
x.clone();
149 this->y = rhs.
y.clone();
157 memset(this->vars.data(), 0,
sizeof(
double) * this->vars.size());
161 void accumulate(
const std::vector<T> &data_x,
const std::vector<T> &data_y) {
164 data_x.size() != data_y.size(),
165 "[ERROR][Histogram2d::accumulate] data_x and data_y should have same size!%s",
"\n");
173 for (
unsigned long long i = 0; i < data_x.size(); i++) {
174 nx = floor(data_x[i] / dx);
175 ny = floor(data_y[i] / dy);
176 vars.at<
double>(ny *
binx + nx) += 1;
202 std::vector<cytnx_uint64>
size() {
203 return std::vector<cytnx_uint64>({this->x.size(), this->y.size()});
2D, real value histogram
Definition stat.hpp:105
uint64_t binx
Definition stat.hpp:109
double minx
Definition stat.hpp:107
uint64_t biny
Definition stat.hpp:109
Storage & get_x()
Definition stat.hpp:188
double maxy
Definition stat.hpp:108
void clear_vars()
Definition stat.hpp:155
double miny
Definition stat.hpp:107
std::vector< cytnx_uint64 > size()
Definition stat.hpp:202
const Storage & get_x() const
Definition stat.hpp:184
Storage & get_y()
Definition stat.hpp:197
Histogram2d(const unsigned long long &Nbinx, const unsigned long long &Nbiny, const double &min_x, const double &max_x, const double &min_y, const double &max_y)
initialize a histogram
double total_count
Definition stat.hpp:117
cytnx::Storage y
Definition stat.hpp:112
cytnx::Storage vars
Definition stat.hpp:110
cytnx::Storage x
Definition stat.hpp:111
const Storage & get_y() const
Definition stat.hpp:193
void accumulate(const std::vector< T > &data_x, const std::vector< T > &data_y)
Definition stat.hpp:161
double maxx
Definition stat.hpp:108
1D, real value histogram
Definition stat.hpp:19
cytnx::Storage x
Definition stat.hpp:25
cytnx::Storage vars
Definition stat.hpp:24
void clear_vars()
Definition stat.hpp:58
const Storage & get_x() const
Definition stat.hpp:91
Histogram(const unsigned long long &Nbins, const double &min_val, const double &max_val)
initialize a histogram
uint64_t bins
Definition stat.hpp:23
double min
Definition stat.hpp:21
double total_count
Definition stat.hpp:30
void accumulate(const std::vector< T > &data)
Definition stat.hpp:64
cytnx_uint64 size()
Definition stat.hpp:100
double max
Definition stat.hpp:22
Storage & get_x()
Definition stat.hpp:95
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:16
Helper function to print vector with ODT:
Definition Accessor.hpp:12
uint64_t cytnx_uint64
Definition Type.hpp:55