version 1.15 | version 1.16 |
---|
| |
return value_to_bin_scalar(actual_value[i] ? cv[i]->actual_value() : cv[i]->value(), i); | return value_to_bin_scalar(actual_value[i] ? cv[i]->actual_value() : cv[i]->value(), i); |
} | } |
| |
| /// \brief Report the bin corresponding to the current value of variable i |
| /// and assign first or last bin if out of boundaries |
| inline int current_bin_scalar_bound(int const i) const |
| { |
| return value_to_bin_scalar_bound(actual_value[i] ? cv[i]->actual_value() : cv[i]->value(), i); |
| } |
| |
/// \brief Report the bin corresponding to the current value of item iv in variable i | /// \brief Report the bin corresponding to the current value of item iv in variable i |
inline int current_bin_scalar(int const i, int const iv) const | inline int current_bin_scalar(int const i, int const iv) const |
{ | { |
| |
return (int) std::floor( (value.real_value - lower_boundaries[i].real_value) / widths[i] ); | return (int) std::floor( (value.real_value - lower_boundaries[i].real_value) / widths[i] ); |
} | } |
| |
| /// \brief Use the lower boundary and the width to report which bin |
| /// the provided value is in and assign first or last bin if out of boundaries |
| inline int value_to_bin_scalar_bound(colvarvalue const &value, const int i) const |
| { |
| int bin_index = std::floor( (value.real_value - lower_boundaries[i].real_value) / widths[i] ); |
| if (bin_index < 0) bin_index=0; |
| if (bin_index >=int(nx[i])) bin_index=int(nx[i])-1; |
| return (int) bin_index; |
| } |
| |
/// \brief Same as the standard version, but uses another grid definition | /// \brief Same as the standard version, but uses another grid definition |
inline int value_to_bin_scalar(colvarvalue const &value, | inline int value_to_bin_scalar(colvarvalue const &value, |
colvarvalue const &new_offset, | colvarvalue const &new_offset, |
| |
data[i] *= a; | data[i] *= a; |
} | } |
| |
| /// \brief Assign all zero elements a scalar constant (fast loop) |
| inline void remove_zeros(cvm::real const &a) |
| { |
| for (size_t i = 0; i < nt; i++) |
| if(data[i]==0) data[i] = a; |
| } |
| |
| |
/// \brief Get the bin indices corresponding to the provided values of | /// \brief Get the bin indices corresponding to the provided values of |
/// the colvars | /// the colvars |
| |
return index; | return index; |
} | } |
| |
| /// \brief Get the bin indices corresponding to the provided values of |
| /// the colvars and assign first or last bin if out of boundaries |
| inline std::vector<int> const get_colvars_index_bound() const |
| { |
| std::vector<int> index = new_index(); |
| for (size_t i = 0; i < nd; i++) { |
| index[i] = current_bin_scalar_bound(i); |
| } |
| return index; |
| } |
| |
/// \brief Get the minimal distance (in number of bins) from the | /// \brief Get the minimal distance (in number of bins) from the |
/// boundaries; a negative number is returned if the given point is | /// boundaries; a negative number is returned if the given point is |
/// off-grid | /// off-grid |
| |
{ | { |
// write the header | // write the header |
os << "object 1 class gridpositions counts"; | os << "object 1 class gridpositions counts"; |
int icv; | size_t icv; |
for (icv = 0; icv < number_of_colvars(); icv++) { | for (icv = 0; icv < number_of_colvars(); icv++) { |
os << " " << number_of_points(icv); | os << " " << number_of_points(icv); |
} | } |
| |
| |
/// \brief Return the log-gradient from finite differences | /// \brief Return the log-gradient from finite differences |
/// on the *same* grid for dimension n | /// on the *same* grid for dimension n |
inline const cvm::real log_gradient_finite_diff( const std::vector<int> &ix0, | inline cvm::real log_gradient_finite_diff(const std::vector<int> &ix0, |
int n = 0) | int n = 0) |
{ | { |
cvm::real A0, A1; | cvm::real A0, A1; |
| |
/// \brief Return the lowest value | /// \brief Return the lowest value |
cvm::real minimum_value() const; | cvm::real minimum_value() const; |
| |
| /// \brief Return the lowest positive value |
| cvm::real minimum_pos_value() const; |
| |
/// \brief Calculates the integral of the map (uses widths if they are defined) | /// \brief Calculates the integral of the map (uses widths if they are defined) |
cvm::real integral() const; | cvm::real integral() const; |
| |