31 Histogram(
const unsigned long long &Nbins,
const double &min_val,
const double &max_val);
37 this->bins = rhs.
bins;
46 this->bins = rhs.
bins;
56 memset(this->vars.data(), 0,
sizeof(
double) * this->vars.
size());
61 std::vector<T> tmp = data;
62 std::sort(tmp.begin(), tmp.end());
69 for (
unsigned long long i = 0; i < tmp.size(); i++) {
70 while (cntr <= this->
bins) {
71 if (tmp[i] < curr_x) {
73 vars.at<
double>(cntr - 1) += 1;
118 Histogram2d(
const unsigned long long &Nbinx,
const unsigned long long &Nbiny,
119 const double &min_x,
const double &max_x,
const double &min_y,
120 const double &max_y);
124 this->minx = rhs.
minx;
125 this->maxx = rhs.
maxx;
126 this->miny = rhs.
miny;
127 this->maxy = rhs.
maxy;
128 this->binx = rhs.
binx;
129 this->biny = rhs.
biny;
137 this->minx = rhs.
minx;
138 this->maxx = rhs.
maxx;
139 this->miny = rhs.
miny;
140 this->maxy = rhs.
maxy;
141 this->binx = rhs.
binx;
142 this->biny = rhs.
biny;
153 memset(this->vars.data(), 0,
sizeof(
double) * this->vars.
size());
157 void accumulate(
const std::vector<T> &data_x,
const std::vector<T> &data_y) {
160 data_x.size() != data_y.size(),
161 "[ERROR][Histogram2d::accumulate] data_x and data_y should have same size!%s",
"\n");
169 for (
unsigned long long i = 0; i < data_x.size(); i++) {
170 nx = floor(data_x[i] / dx);
171 ny = floor(data_y[i] / dy);
172 vars.at<
double>(ny *
binx + nx) += 1;
198 std::vector<cytnx_uint64>
size() {
199 return std::vector<cytnx_uint64>({this->x.
size(), this->y.
size()});
an memeory storage with multi-type/multi-device support
Definition Storage.hpp:1051
const unsigned long long & size() const
the size ( no. of elements ) in the Storage
Definition Storage.hpp:1357
Storage clone() const
return a deep copy of the current storage.
Definition Storage.hpp:1350
2D, real value histogram
Definition stat.hpp:101
uint64_t binx
Definition stat.hpp:105
double minx
Definition stat.hpp:103
uint64_t biny
Definition stat.hpp:105
Storage & get_x()
Definition stat.hpp:184
double maxy
Definition stat.hpp:104
void clear_vars()
Definition stat.hpp:151
double miny
Definition stat.hpp:103
std::vector< cytnx_uint64 > size()
Definition stat.hpp:198
const Storage & get_x() const
Definition stat.hpp:180
Storage & get_y()
Definition stat.hpp:193
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:113
cytnx::Storage y
Definition stat.hpp:108
cytnx::Storage vars
Definition stat.hpp:106
cytnx::Storage x
Definition stat.hpp:107
const Storage & get_y() const
Definition stat.hpp:189
void accumulate(const std::vector< T > &data_x, const std::vector< T > &data_y)
Definition stat.hpp:157
double maxx
Definition stat.hpp:104
1D, real value histogram
Definition stat.hpp:15
cytnx::Storage x
Definition stat.hpp:21
cytnx::Storage vars
Definition stat.hpp:20
void clear_vars()
Definition stat.hpp:54
const Storage & get_x() const
Definition stat.hpp:87
Histogram(const unsigned long long &Nbins, const double &min_val, const double &max_val)
initialize a histogram
uint64_t bins
Definition stat.hpp:19
double min
Definition stat.hpp:17
double total_count
Definition stat.hpp:26
void accumulate(const std::vector< T > &data)
Definition stat.hpp:60
cytnx_uint64 size()
Definition stat.hpp:96
double max
Definition stat.hpp:18
Storage & get_x()
Definition stat.hpp:91
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:16
Definition Accessor.hpp:12
uint64_t cytnx_uint64
Definition Type.hpp:45