Skip to content
Snippets Groups Projects
Plus.cpp 1.73 KiB
Newer Older
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
Nick Draper's avatar
Nick Draper committed

Nick Draper's avatar
Nick Draper committed
#include <cmath>
#include "MantidAlgorithms/Plus.h"
#include "MantidAPI/WorkspaceIterator.h"
Nick Draper's avatar
Nick Draper committed

using namespace Mantid::API;
using namespace Mantid::Kernel;

namespace Mantid
{
  namespace Algorithms
  {
    // Register the class into the algorithm factory
    DECLARE_ALGORITHM(Plus)

Nick Draper's avatar
Nick Draper committed
    // Get a reference to the logger
    Logger& Plus::g_log = Logger::get("Plus");

    /** Performs the plus operation using Iterators and the std::tranform function.
    * @param it_in1 The const iterator to the lhs data item
    * @param it_in2 The const iterator to the rhs data item
    * @param it_out The output iterator to the new workspace
    void Plus::performBinaryOperation(API::MatrixWorkspace::const_iterator it_in1, API::MatrixWorkspace::const_iterator it_in2,
        API::MatrixWorkspace::iterator it_out)
Nick Draper's avatar
Nick Draper committed
    {
      std::transform(it_in1.begin(),it_in1.end(),it_in2.begin(),it_out.begin(),Plus_fn(this,it_in1.end() - it_in1.begin()));
Nick Draper's avatar
Nick Draper committed
    }

    /** Performs the addition with Gaussian errors within the transform function
Nick Draper's avatar
Nick Draper committed
    * @param a The LocatedData ref of the first workspace data item
    * @param b The LocatedData ref of the second workspace data item
    * @returns A LocatedData ref of the result with Gaussian errors
Nick Draper's avatar
Nick Draper committed
    */
Nick Draper's avatar
Nick Draper committed
    LocatedDataValue&
      Plus::Plus_fn::operator() (const ILocatedData& a,const ILocatedData& b)
    {
Nick Draper's avatar
Nick Draper committed
      //copy the values from lhs
      result = a;
      //use the error helper to correct the changed values in result
      //if (m_progress++ % m_progress_step == 0) report_progress();
Nick Draper's avatar
Nick Draper committed
      return result;
Nick Draper's avatar
Nick Draper committed
    }
  }
}