gpa in double prescision

Dependencies:   mbed

Committer:
pmic
Date:
Tue Apr 10 12:25:03 2018 +0000
Revision:
28:c71b6856652e
Parent:
0:15be70d21d7c
correct new functinality

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rtlabor 0:15be70d21d7c 1 #include "LinearCharacteristics.h"
rtlabor 0:15be70d21d7c 2
rtlabor 0:15be70d21d7c 3 using namespace std;
rtlabor 0:15be70d21d7c 4
rtlabor 0:15be70d21d7c 5 LinearCharacteristics::LinearCharacteristics(float k, float offset){
rtlabor 0:15be70d21d7c 6 this->k = k;
rtlabor 0:15be70d21d7c 7 this->offset = offset;
rtlabor 0:15be70d21d7c 8 this->upper_limit = 9.99e19;
rtlabor 0:15be70d21d7c 9 this->lower_limit = -9.99e19;
rtlabor 0:15be70d21d7c 10 }
rtlabor 0:15be70d21d7c 11 LinearCharacteristics::LinearCharacteristics(float k, float offset,float lim){
rtlabor 0:15be70d21d7c 12 this->k = k;
rtlabor 0:15be70d21d7c 13 this->offset = offset;
rtlabor 0:15be70d21d7c 14 this->upper_limit = lim;
rtlabor 0:15be70d21d7c 15 this->lower_limit = -lim;
rtlabor 0:15be70d21d7c 16 }
rtlabor 0:15be70d21d7c 17 LinearCharacteristics::LinearCharacteristics(float k, float offset,float ulim,float llim){
rtlabor 0:15be70d21d7c 18 this->k = k;
rtlabor 0:15be70d21d7c 19 this->offset = offset;
rtlabor 0:15be70d21d7c 20 this->upper_limit = ulim;
rtlabor 0:15be70d21d7c 21 this->lower_limit = llim;
rtlabor 0:15be70d21d7c 22 }
rtlabor 0:15be70d21d7c 23
rtlabor 0:15be70d21d7c 24
rtlabor 0:15be70d21d7c 25 LinearCharacteristics::~LinearCharacteristics() {}
rtlabor 0:15be70d21d7c 26
rtlabor 0:15be70d21d7c 27 float LinearCharacteristics::eval(float u){
rtlabor 0:15be70d21d7c 28 float val = k * (u-offset);
rtlabor 0:15be70d21d7c 29 if(val > upper_limit)
rtlabor 0:15be70d21d7c 30 return upper_limit;
rtlabor 0:15be70d21d7c 31 else if(val < lower_limit)
rtlabor 0:15be70d21d7c 32 return lower_limit;
rtlabor 0:15be70d21d7c 33 else
rtlabor 0:15be70d21d7c 34 return val;
rtlabor 0:15be70d21d7c 35 }
rtlabor 0:15be70d21d7c 36