Select Git revision
paralellseriel.cpp
paralellseriel.cpp 3.42 KiB
#include "componant/paralellseriel.h"
#include "componant/componant.h"
using namespace eis;
Parallel::Parallel(std::vector<Componant*> componantsIn): componants(componantsIn)
{
}
Parallel::Parallel(const Parallel& in)
{
operator=(in);
}
void Parallel::operator=(const Parallel& in)
{
componants.clear();
componants.reserve(in.componants.size());
for(Componant* componant : in.componants)
componants.push_back(copy(componant));
}
Parallel::~Parallel()
{
for(Componant* componant : componants)
delete componant;
}
std::complex<fvalue> Parallel::execute(fvalue omega)
{
std::complex<fvalue> accum(0,0);
for(Componant* componant : componants)
{
accum += std::complex<fvalue>(1,0)/componant->execute(omega);
}
return std::complex<fvalue>(1,0)/accum;
}
char Parallel::getComponantChar() const
{
return staticGetComponantChar();
}
std::string Parallel::getComponantString(bool currentValue) const
{
std::string out("(");
for(Componant* componant : componants)
out.append(componant->getComponantString(currentValue));
out.push_back(')');
return out;
}
bool Parallel::compileable()
{
for(Componant* componant : componants)
{
if(!componant->compileable())
return false;
}
return true;
}
std::string Parallel::getCode(std::vector<std::string>& parameters)
{
std::string out = "std::complex<fvalue>(1,0)/(";
for(Componant* componant : componants)
{
out += "std::complex<fvalue>(1,0)/(" + componant->getCode(parameters) + ") + ";
}
out.pop_back();