Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122199965
series.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 16, 13:44
Size
629 B
Mime Type
text/x-c++
Expires
Fri, Jul 18, 13:44 (2 d)
Engine
blob
Format
Raw Data
Handle
27448683
Attached To
R9484 sp4e-homework-lars-bertil
series.hh
View Options
#ifndef SERIES_HPP
#define SERIES_HPP
#include <cmath>
class Series {
public:
unsigned int current_index = 0;
double current_value = 0.;
virtual double compute(unsigned int N) {
if (current_index <= N) {
N = N - current_index;
}
else { current_value = 0.;
current_index = 0;
}
for (int k = 0;k<N; ++k){
addIndex();
}
return current_value;
}
virtual double getAnalyticPrediction() {
return std::nan("");
}
void addIndex() {
current_index = current_index + 1;
current_value = current_value + computeValue(current_index);
}
virtual double computeValue(int k) = 0;
};
#endif
Event Timeline
Log In to Comment