/*
 * Project: MoleCuilder
 * Description: creates and alters molecular systems
 * Copyright (C)  2012 University of Bonn. All rights reserved.
 * 
 *
 *   This file is part of MoleCuilder.
 *
 *    MoleCuilder is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    MoleCuilder is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with MoleCuilder.  If not, see .
 */
/*
 * MPQCCommandJob_MPQCData.cpp
 *
 *  Created on: Feb 08, 2012
 *      Author: heber
 */
// include config.h
#ifdef HAVE_CONFIG_H
#include 
#endif
#include "CodePatterns/MemDebug.hpp"
#include "MPQCCommandJob_MPQCData.hpp"
#include 
#include 
#include "CodePatterns/Log.hpp"
#include "LinearAlgebra/defs.hpp"
/** Constructor for class MPQCData.
 *
 */
MPQCData::MPQCData() :
    energy(0.)
{}
/** Destructor for class MPQCData.
 *
 */
MPQCData::~MPQCData()
{}
/** Comparator for class MPQCData.
 *
 */
bool MPQCData::operator==(const MPQCData &other) const
{
  if (fabs(energy - other.energy) > std::numeric_limits::epsilon()) {
    LOG(1, "INFO: Energy's in MPQCData differ: "
        << energy << " != " << other.energy << ".");
    return false;
  }
  if (forces.size() != other.forces.size()) {
    LOG(1, "INFO: Forces's in MPQCData differ in size: "
        << forces.size() << " != " << other.forces.size() << ".");
    return false;
  }
  for (size_t i = 0; i < forces.size(); ++i)
    for (size_t index = 0; index < NDIM; ++index)
      if (fabs(forces[i][index] - other.forces[i][index]) > std::numeric_limits::epsilon()) {
        LOG(1, "INFO: " << index << "th component of force of particle "
            << i << " in MPQCData differ: " << forces[i][index]
            << " != " << other.forces[i][index] << ".");
        return false;
      }
  return true;
}
std::ostream & operator<<(std::ostream &ost, const MPQCData &data)
{
  ost << "Energy: " << data.energy << "\t";
  ost << "Forces: " << data.forces;
  return ost;
}