UnPComp2013/SistemasdeControle — pull request #1 by Flaviohmm (2014-12-19 21:17:41+00:00)
Title: Create bisseccao.cpp

#include "bisseccao.h"
#include

template
void bisseccao::setInterval(UsedType a, UsedType b)
{
this->a = a;
this->b = b;
this->fa = this->f->sim(a);
this->fb = this->f->sim(b);

if(this->fa * this->fb > 0)
std::cout << "\nNão foi possível encontrar raíz no intervalo dado." << std::endl;
}

template
UsedType bisseccao::zeroFind()
{
unsigned n = 1;

while(this->fa * this->fb < 0)
{
this->c = (this->a + this->b) / 2;
this->fc = this->f->sim(c);

if(std::abs(this->fc) < this->tolerance || n > this->nMaxIterarion)
break;

if(this->fa * this->fc < 0)
{
this->b = this->c;
this->fb = this->fc;
}
else if(this->fb * this->fc < 0)
{
this->a = this->c;
this->fa = this->fc;
}
}

return this->c;
}

template class bisseccao;
template class bisseccao;