/* * IndexedPartialCharges.hpp * * Created on: Jun 12, 2016 * Author: heber */ #ifndef INDEXEDPARTIALCHARGES_HPP_ #define INDEXEDPARTIALCHARGES_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "Fragmentation/Summation/SetValues/IndexedValue.hpp" #include "Fragmentation/Summation/ZeroInstance.hpp" struct partial_charge_t { //!> typedef for a single charge typedef double charge_t; charge_t charge; /** Default constructor for a partial charge. */ partial_charge_t() : charge(0.) {} /** Constructor for a partial charge. * * \param _charge new partial charge */ partial_charge_t(const double &_charge) : charge(_charge) {} /** Assignment operator for the charge. * * \param _charge new partial charge */ partial_charge_t& operator()(const double &_charge) { charge = _charge; return *this; } /** Sum operator. * * \param _charge new partial charge */ partial_charge_t& operator+=(const double &_charge) { charge += _charge; return *this; } /** Subtraction operator. * * \param _charge new partial charge */ partial_charge_t& operator-=(const double &_charge) { charge -= _charge; return *this; } /** Comparator for partial charge. * * \param other other charge instance */ bool operator==(const partial_charge_t &other) const { return charge == other.charge; } bool operator!=(const partial_charge_t &other) const { return !operator==(other); } bool operator<(const partial_charge_t &other) const { return charge < other.charge; } /** Summation operator for two force vectors. * * \param other other charge * \param prefactor prefactor to use in summation (e.g. -1 gives a subtraction) */ void superposeOtherIndexedVectors(const partial_charge_t &other, const double prefactor) { charge = charge + prefactor * other.charge; } // make output operator friend friend std::ostream & operator<<(std::ostream &ost, const partial_charge_t &other); }; std::ostream & operator<<(std::ostream &ost, const partial_charge_t &other); struct IndexedPartialCharges : public IndexedValue { public: IndexedPartialCharges( const typename IndexedValue::indices_t &_indices, const typename IndexedValue::values_t &_charges) : IndexedValue(_indices, _charges) {} IndexedPartialCharges() {} }; template T ZeroInstance(); template<> IndexedPartialCharges ZeroInstance< IndexedPartialCharges >(); template<> partial_charge_t ZeroInstance< partial_charge_t >(); #endif /* INDEXEDPARTIALCHARGES_HPP_ */