
#include "Numerics.hpp"

Numerics::Numerics()
{

}

Numerics::~Numerics()
{

}


void Numerics::readInput(json input)
{

	if (input.find("maxIterations") != input.end())
		maxIterations = input.at("maxIterations").get<int>();
	else
		maxIterations = 50;
	if (input.find("relaxFactor") != input.end())
		relaxationFactor = input.at("relaxFactor").get<float>();
	else
		relaxationFactor = 0.4;
	if (input.find("tolerance") != input.end())
		tolerance = input.at("tolerance").get<float>();
	else
		tolerance = 0.001;

	if (input.find("algorithm") != input.end())
	{
		std::string algo_ = input.at("algorithm").get<std::string>();
			if (algo_ == "accurate")
				algorithm = ALGO::Accurate;
			else if (algo_ == "fast")
				algorithm = ALGO::Fast;
			else if (algo_ == "auto")
				algorithm = ALGO::Automatic;
	}
	else
		algorithm = ALGO::Automatic;

}

Numerics::ALGO Numerics::getAlgorithm()
{
	return algorithm;
}


unsigned int Numerics::getMaxIterations()
{
	return maxIterations;
}

float Numerics::getRelaxationFactor()
{
	return relaxationFactor; 
}

float Numerics::getTolerance()
{
	return tolerance;
}