
#include <cmath>
#include <complex>
#include <algorithm>
#include <iostream>

#include "hark-lib/node/CMConjEachElement.h"

namespace hark
{
namespace node
{
    CMConjEachElement::CMConjEachElement():
        NodeDef("CMConjEachElement")
    {
        *this
            << Terminal::in("INPUTCM")
            >> Terminal::out("OUTPUTCM");
    }

    void
    CMConjEachElement::reset()
    {
    }

    void
    CMConjEachElement::initialize(InputDataBundle &input)
    {
    }

    bool
    CMConjEachElement::operator () (size_t count, InputDataBundle &input, OutputDataBundle &output)
    {
        ////const auto &operation_flag = input["OPERATION_FLAG"].last().as<bool>();

#ifdef DEBUG
        ptime start_time;
        ptime end_time;
        start_time = microsec_clock::local_time();
#endif

        const auto &inputcm = input["INPUTCM"].last().cast<Matrix<std::complex<float> > >();

        auto out = data::create<Matrix<std::complex<float> > >(inputcm.rows(), inputcm.cols() * inputcm.cols());
        auto &outputcm = out.cast<Matrix<std::complex<float> > >();
        outputcm = inputcm.conjugate();

        output["OUTPUTCM"].push(out);

#ifdef DEBUG
        end_time = microsec_clock::local_time();
        std::cout << end_time - start_time << std::endl;
#endif

        return true;
    }
}
}

/* end of file */
