7 #ifndef CT_RXNPATH_GROUP
8 #define CT_RXNPATH_GROUP
22 Group() : m_sign(-999) { }
23 Group(
size_t n) : m_sign(0) {
26 Group(
const std::vector<int>& elnumbers) :
27 m_comp(elnumbers), m_sign(0) {
30 Group(
const std::vector<size_t>& elnumbers) :
31 m_comp(elnumbers.size()), m_sign(0) {
32 for (
size_t i = 0; i < elnumbers.size(); i++) {
33 m_comp[i] = int(elnumbers[i]);
38 m_comp(g.m_comp), m_sign(g.m_sign) { }
52 verifyInputs(*
this, other);
53 for (
size_t m = 0; m < m_comp.size(); m++) {
54 m_comp[m] -= other.m_comp[m];
58 void operator+=(
const Group& other) {
59 verifyInputs(*
this, other);
60 for (
size_t m = 0; m < m_comp.size(); m++) {
61 m_comp[m] += other.m_comp[m];
65 void operator*=(
int a) {
66 for (
size_t m = 0; m < m_comp.size(); m++) {
71 bool operator==(
const Group& other)
const {
72 verifyInputs(*
this, other);
73 for (
size_t m = 0; m < m_comp.size(); m++) {
74 if (m_comp[m] != other.m_comp[m]) {
80 friend Group operator-(
const Group& g1,
const Group& g2) {
86 friend Group operator+(
const Group& g1,
const Group& g2) {
92 friend void verifyInputs(
const Group& g1,
const Group& g2) {
114 return (m_sign != -999);
116 bool operator!()
const {
117 return (m_sign == -999);
122 size_t size()
const {
123 return m_comp.size();
129 for (
size_t m = 0; m < m_comp.size(); m++) {
130 sum += std::abs(m_comp[m]);
136 if (m_comp.empty()) {
142 std::ostream& fmt(std::ostream& s,
const std::vector<std::string>& esymbols)
const;
144 friend std::ostream& operator<<(std::ostream& s,
148 std::vector<int> m_comp;
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
bool valid() const
True if all non-zero atom numbers have the same sign.
Class Group is an internal class used by class ReactionPath.
int nAtoms() const
Number of atoms in the group (>= 0)
void operator-=(const Group &other)
Decrement the atom numbers by those in group 'other'.
int nAtoms(size_t m) const
Number of atoms of element m (positive or negative)