
#if !defined(_HARKLIB_TENSOR_H_INCLUDED)
#define _HARKLIB_TENSOR_H_INCLUDED 1

#include <cmath>
#include <complex>
#include <vector>
#include <type_traits>

#include "hark-lib/hark-lib.h"
#include "hark-lib/object.h"

//#include "common.h"

//#include "Object.h"
//#include "ObjectParser.h"
//#include "misc.h"

namespace hark
{
    template<typename T>
    struct is_complex : std::false_type {};

    template<typename T>
    struct is_complex<std::complex<T> > : std::true_type {};

    template<typename T>
    class Tensor : public object
    {
    public:
        std::vector<int> vsize;
        std::vector<T> data;

        Tensor() {}

        Tensor(const Tensor &tensor) {
            vsize.resize(tensor.vsize.size());
            for(size_t i = 0; i < tensor.vsize.size(); i++){
                vsize[i] = tensor.vsize[i];
            }
            data.resize(tensor.data.size());
            for(size_t i = 0; i < tensor.data.size(); i++){
                data[i] = tensor.data[i];
            }
        }

        ~Tensor() {
        }

        bool iscomplex(){
            return is_complex<T>::value;
        }

        virtual std::ostream& write(std::ostream &os) const
        {
            bool not_first = false;
            os << "{"
               << "vsize: [";
            for(auto &it: this->vsize){
                if(not_first){ os << ", "; }
                os << it;
                not_first = true;
            }
            os << "], data: [";
            not_first = false;
            for(auto &it: this->data){
                if(not_first){ os << ", "; }
                os << it;
                not_first = true;
            }
            os << "]}";
            return os;
        }
    };
} // namespace hark

#endif /* #if !defined(_HARKLIB_TENSOR_H_INCLUDED) */

/* end of file */
