-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIIntrinsicGrowthFunction.h
More file actions
66 lines (44 loc) · 1009 Bytes
/
IIntrinsicGrowthFunction.h
File metadata and controls
66 lines (44 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* IIntrinsicGrowthFunction.h
*
* Created on: 18 Jun 2014
* Author: rusty
*/
#ifndef IINTRINSICGROWTHFUNCTION_H_
#define IINTRINSICGROWTHFUNCTION_H_
#include <stdlib.h>
#include <math.h>
#include <iostream>
using namespace std;
class IIntrinsicGrowthFunction{
public:
virtual double growthRate(double x) = 0;
virtual ~IIntrinsicGrowthFunction(){}
};
class ExponentialGrowthFn: public IIntrinsicGrowthFunction
{
private:
double r0;
double exp;
public:
~ExponentialGrowthFn(){
}
ExponentialGrowthFn(double _r0, double _exp=1):r0(_r0), exp(_exp){}
double growthRate(double x0){
return pow(x0,exp)*r0;
}
};
class LogisticGrowthFn: public IIntrinsicGrowthFunction
{
private:
double r0;
double carryingCapacity;
public:
~LogisticGrowthFn(){
}
LogisticGrowthFn(double _r0, double _carryingCapacity):r0(_r0),carryingCapacity(_carryingCapacity){}
double growthRate(double x0){
return x0*r0*(1-(x0/carryingCapacity));
}
};
#endif /* IINTRINSICGROWTHFUNCTION_H_ */