MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
Histogram.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <string>
18
19#include "datatypes.hpp"
20
21namespace mrmd
22{
23namespace data
24{
26{
27 Histogram(const std::string& label, const real_t minArg, const real_t maxArg, idx_t numBinsArg)
28 : min(minArg),
29 max(maxArg),
34 {
35 }
36
42 {
43 auto bin = idx_c((val - min) * inverseBinSize);
44 if (bin < 0) bin = -1;
45 if (bin >= numBins) bin = -1;
46 return bin;
47 }
48
49 const real_t min;
50 const real_t max;
55
57};
58
60
66std::ostream& operator<<(std::ostream& os, const data::Histogram& hist);
67
68} // namespace data
69} // namespace mrmd
std::ostream & operator<<(std::ostream &os, const data::Histogram &hist)
Overload for writing to console/files.
Definition Histogram.cpp:66
data::Histogram gradient(const data::Histogram &input)
Definition Histogram.cpp:37
Definition BerendsenBarostat.cpp:18
Kokkos::View< real_t * > ScalarView
Definition datatypes.hpp:159
KOKKOS_INLINE_FUNCTION constexpr idx_t idx_c(const T &val)
Definition datatypes.hpp:93
int64_t idx_t
Definition datatypes.hpp:91
double real_t
Definition datatypes.hpp:99
KOKKOS_INLINE_FUNCTION constexpr real_t real_c(T t)
Definition datatypes.hpp:114
Definition Array.hpp:21
Definition Histogram.hpp:26
const idx_t numBins
Definition Histogram.hpp:51
const real_t inverseBinSize
Definition Histogram.hpp:53
ScalarView data
Definition Histogram.hpp:54
Histogram(const std::string &label, const real_t minArg, const real_t maxArg, idx_t numBinsArg)
Definition Histogram.hpp:27
Histogram & operator+=(const Histogram &rhs)
Definition Histogram.cpp:23
const real_t min
Definition Histogram.hpp:49
const real_t binSize
Definition Histogram.hpp:52
KOKKOS_INLINE_FUNCTION idx_t getBin(const real_t &val) const
Definition Histogram.hpp:41
const real_t max
Definition Histogram.hpp:50