.

Dependents:  

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PolynomialCharacteristics.cpp Source File

PolynomialCharacteristics.cpp

00001 #include "PolynomialCharacteristics.h"
00002 #include "math.h"
00003 using namespace std;
00004 PolynomialCharacteristics::PolynomialCharacteristics(float *P,uint8_t degree,float ll, float ul){    // standard lin characteristics
00005     this->P = (float*)malloc(degree*sizeof(float));
00006     for(int k=0;k<=degree;k++)
00007         this->P[k] =P[k];
00008     this->degree = degree;
00009     this->llim = ll;
00010     this->ulim = ul;
00011     
00012 }
00013 
00014 PolynomialCharacteristics::~PolynomialCharacteristics() {}
00015 
00016 
00017 float PolynomialCharacteristics::evaluate(float x)
00018 {   
00019 float dum = 0.0;
00020 for(int k=0;k<=degree;k++)
00021     dum = P[k]*pow(x,(float)k);
00022 if(dum > this->ulim)
00023     dum = this->ulim;
00024 if(dum < this->llim)
00025     dum = this->llim;
00026 return dum;
00027     }