#ifndef CVEC_H
#define CVEC_H
#include<complex>
typedef std::complex<double> Creal;
// test
class Cvec {
public:
	int size = 0;
	Creal* vec = NULL;
public:

	Cvec();
	// initialize Cvec with length n
	Cvec(const int n);
	// initialize Cvec with properties of Cvec in
	Cvec(const Cvec& in);
	// initialize Cvce with values start to end with step dx_in
	Cvec(double start, double dx_in, double end);
	// initialize Cvce with values start to end with step dx_in
	Cvec(int start, double dx_in, int end);
	~Cvec();

	void init(int n);
	// print Cvec entries
	void print();
	// give size of Cvec
	int get_size() const;
	// change vector entries
	void set_vec(double start, double dx_in, double end);

	// set all entries of Cvec to "in" (real part) and zero imaginary part
	Cvec& operator=(const double& in);
	// set all entries to "in" (real and imaginary)
	Cvec& operator=(const Creal& in);
	// replace Cvec with corresponding entries of "in" 
	Cvec& operator=(const Cvec& in);

	// addition of Cvec and "in"
	Cvec operator+(const Cvec& in);
	// addition of every entry of Cvec with "in" (real part)
	Cvec operator+(const double& in);
	// addition of every entry of Cvec with "in" (real and imag part)
	Cvec operator+(const Creal& in);

	// subtraction of vector "in" from Cvec
	Cvec operator-(const Cvec& in);
	// subtraction of "in" from every entry (real part)
	Cvec operator-(const double& in);
	// subtraction of "in" from every entry (real and imag part)
	Cvec operator-(const Creal& in);

	// divide every entry of Cvec by corresponding (complex) entry of vector "in"
	Cvec operator/(const Cvec& in);
	// divide every entry of Cvec by (complex) "in"
	Cvec operator/(const Creal& in);
	// divide every entry of Cvec by (real)"in"
	Cvec operator/(const double& in);

	// multiply every entry of Cvec with corresponding entry of "in"
	Cvec operator*(const Cvec& in);
	// multiply every entry of Cvec with (complex) "in"
	Cvec operator*(const Creal& in);
	// multiply every entry of Cvec with (real) "in"
	Cvec operator*(const double& in);

	// addition of every entry of "in" to corresponding entry of Cvec
	Cvec operator+=(const Cvec& in);
	// addition of (real) "in" to every entry of Cvec
	Cvec operator+=(const double& in);
	// addition of (complex) "in" to every entry of Cvec
	Cvec operator+=(const Creal& in);

	// subtraction of every entry of "in" from corresponding entry of Cvec
	Cvec operator-=(const Cvec& in);
	// subtraction of (real) "in" from every entry of Cvec
	Cvec operator-=(const double& in);
	// subtraction of (complex) "in" from every entry of Cvec
	Cvec operator-=(const Creal& in);

	// division of every entry of Cvec by corresponding entry of "in"
	Cvec operator/=(const Cvec& in);
	// division of every entry of Cvec by (complex) "in"
	Cvec operator/=(const Creal& in);
	// division of every entry of Cvec by (real) "in"
	Cvec operator/=(const double& in);

	// multiplication of every entry of Cvec with corresponding entry of "in"
	Cvec operator*=(const Cvec& in);
	// multiplication of every entry of Cvec with (complex) "in"
	Cvec operator*=(const Creal& in);
	// multiplication of every entry of Cvec with (real) "in"
	Cvec operator*=(const double& in);

	// addition of (real) "d" and every entry of Cvec
	friend Cvec operator+(const double& d, const Cvec& vin) {
		Cvec out(vin.size);
		for (int i = 0; i < vin.size; i++) out.vec[i] = vin.vec[i] + d;
		return out;
	};

	// i-th component of vector
	Creal& operator[](int i);
	// i-th component of vector
	Creal& operator[](int i) const;

	// save vector as binary code with name "filename"
	void save(std::string filename);

	void read(std::string filename);
};


#endif