#include"Operator.h"
#include<iostream>
#include<math.h>

Operator::Operator(){}

Operator::Operator(const Ctridiag& in) {
	this->init(in.diag.get_size());
	diag = in.diag;
	sub = in.sub;
	sup = in.sup;
}

Operator::~Operator(){}

void Operator::init(int n) {
	this->diag = Cvec(n);
	this->sub = Cvec(n - 1);
	this->sup = Cvec(n - 1);
}

Operator Operator::operator=(Cvec& in) {
	if (sub.size == 0) {
		sub.init(in.size - 1);
		sub = 0;
		sup.init(in.size - 1);
		sup = 0;
	}
	diag = in;
	return *this;
}
Operator Operator::operator=(Ctridiag& in) {
	diag = in.diag;
	sub = in.sub;
	sup = in.sup;
	return *this;
}


Operator Operator::operator/=(double& in) {
	sub = sub / in;
	diag = diag / in;
	sup = sup / in;
	return *this;
}

Operator Operator::operator+=(const Operator& in) {
	
	sub = sub + in.sub;
	diag = diag + in.diag;
	sup = sup + in.sup;

	return *this;
}