version 1.14 | version 1.15 |
---|
| |
// -*- c++ -*- | // -*- c++ -*- |
| |
| // This file is part of the Collective Variables module (Colvars). |
| // The original version of Colvars and its updates are located at: |
| // https://github.com/colvars/colvars |
| // Please update all Colvars source files before making any changes. |
| // If you wish to distribute your changes, please submit them to the |
| // Colvars repository at GitHub. |
| |
#ifndef COLVARVALUE_H | #ifndef COLVARVALUE_H |
#define COLVARVALUE_H | #define COLVARVALUE_H |
| |
| |
{} | {} |
| |
/// \brief Copy constructor from rvector base type (Note: this sets | /// \brief Copy constructor from rvector base type (Note: this sets |
/// automatically a type \link type_3vector \endlink , if you want a | /// by default a type \link type_3vector \endlink , if you want a |
/// \link type_unit3vector \endlink you must set it explicitly) | /// \link type_unit3vector \endlink you must set it explicitly) |
inline colvarvalue(cvm::rvector const &v) | inline colvarvalue(cvm::rvector const &v, Type vti = type_3vector) |
: value_type(type_3vector), rvector_value(v) | |
{} | |
| |
/// \brief Copy constructor from rvector base type (additional | |
/// argument to make possible to choose a \link type_unit3vector | |
/// \endlink | |
inline colvarvalue(cvm::rvector const &v, Type const &vti) | |
: value_type(vti), rvector_value(v) | : value_type(vti), rvector_value(v) |
{} | {} |
| |
/// \brief Copy constructor from quaternion base type | /// \brief Copy constructor from quaternion base type |
inline colvarvalue(cvm::quaternion const &q) | inline colvarvalue(cvm::quaternion const &q, Type vti = type_quaternion) |
: value_type(type_quaternion), quaternion_value(q) | : value_type(vti), quaternion_value(q) |
{} | {} |
| |
| /// Copy constructor from vector1d base type |
| colvarvalue(cvm::vector1d<cvm::real> const &v, Type vti = type_vector); |
| |
/// Copy constructor from another \link colvarvalue \endlink | /// Copy constructor from another \link colvarvalue \endlink |
colvarvalue(colvarvalue const &x); | colvarvalue(colvarvalue const &x); |
| |
/// Copy constructor from vector1d base type | |
colvarvalue(cvm::vector1d<cvm::real> const &v, Type const &vti); | |
| |
| |
/// Set to the null value for the data type currently defined | /// Set to the null value for the data type currently defined |
void reset(); | void reset(); |
| |
return std::sqrt(this->norm2()); | return std::sqrt(this->norm2()); |
} | } |
| |
/// \brief Return the value whose scalar product with this value is | |
/// 1 | |
inline colvarvalue inverse() const; | |
| |
/// Square distance between this \link colvarvalue \endlink and another | /// Square distance between this \link colvarvalue \endlink and another |
cvm::real dist2(colvarvalue const &x2) const; | cvm::real dist2(colvarvalue const &x2) const; |
| |
| |
} | } |
} | } |
| |
inline colvarvalue::colvarvalue(cvm::vector1d<cvm::real> const &v, Type const &vti) | inline colvarvalue::colvarvalue(cvm::vector1d<cvm::real> const &v, Type vti) |
{ | { |
if ((vti != type_vector) && (v.size() != num_dimensions(vti))) { | if ((vti != type_vector) && (v.size() != num_dimensions(vti))) { |
cvm::error("Error: trying to initialize a variable of type \""+type_desc(vti)+ | cvm::error("Error: trying to initialize a variable of type \""+type_desc(vti)+ |
| |
} | } |
| |
if (vt1 != type_notset) { | if (vt1 != type_notset) { |
| if (((vt1 == type_unit3vector) && |
| (vt2 == type_unit3vectorderiv)) || |
| ((vt2 == type_unit3vector) && |
| (vt1 == type_unit3vectorderiv)) || |
| ((vt1 == type_quaternion) && |
| (vt2 == type_quaternionderiv)) || |
| ((vt2 == type_quaternion) && |
| (vt1 == type_quaternionderiv))) { |
| return COLVARS_OK; |
| } else { |
if (vt1 != vt2) { | if (vt1 != vt2) { |
cvm::error("Trying to assign a colvar value with type \""+ | cvm::error("Trying to assign a colvar value with type \""+ |
type_desc(vt2)+"\" to one with type \""+ | type_desc(vt2)+"\" to one with type \""+ |
| |
return COLVARS_ERROR; | return COLVARS_ERROR; |
} | } |
} | } |
| } |
return COLVARS_OK; | return COLVARS_OK; |
} | } |
| |