Miscellaneous Library, read Encoder etc.

Dependents:   My_Libraries

Committer:
altb
Date:
Mon Mar 04 11:03:51 2019 +0000
Revision:
0:3312872854c4
New Lib Folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
altb 0:3312872854c4 1 #include "PolynomialCharacteristics.h"
altb 0:3312872854c4 2 #include "math.h"
altb 0:3312872854c4 3 using namespace std;
altb 0:3312872854c4 4 PolynomialCharacteristics::PolynomialCharacteristics(float *P,uint8_t degree,float ll, float ul){ // standard lin characteristics
altb 0:3312872854c4 5 this->P = (float*)malloc(degree*sizeof(float));
altb 0:3312872854c4 6 for(int k=0;k<=degree;k++)
altb 0:3312872854c4 7 this->P[k] =P[k];
altb 0:3312872854c4 8 this->degree = degree;
altb 0:3312872854c4 9 this->llim = ll;
altb 0:3312872854c4 10 this->ulim = ul;
altb 0:3312872854c4 11
altb 0:3312872854c4 12 }
altb 0:3312872854c4 13
altb 0:3312872854c4 14 PolynomialCharacteristics::~PolynomialCharacteristics() {}
altb 0:3312872854c4 15
altb 0:3312872854c4 16
altb 0:3312872854c4 17 float PolynomialCharacteristics::evaluate(float x)
altb 0:3312872854c4 18 {
altb 0:3312872854c4 19 float dum = 0.0;
altb 0:3312872854c4 20 for(int k=0;k<=degree;k++)
altb 0:3312872854c4 21 dum = P[k]*pow(x,(float)k);
altb 0:3312872854c4 22 if(dum > this->ulim)
altb 0:3312872854c4 23 dum = this->ulim;
altb 0:3312872854c4 24 if(dum < this->llim)
altb 0:3312872854c4 25 dum = this->llim;
altb 0:3312872854c4 26 return dum;
altb 0:3312872854c4 27 }