Miscellaneous Library, read Encoder etc.
PolynomialCharacteristics.cpp@1:c680da75a614, 2019-03-06 (annotated)
- Committer:
- altb
- Date:
- Wed Mar 06 14:19:10 2019 +0000
- Revision:
- 1:c680da75a614
- Parent:
- 0:3312872854c4
dropped Signal
Who changed what in which revision?
User | Revision | Line number | New 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 | } |