mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/sequence] Cap the sum of terms to a maximum number of terms
Change-Id: Ib9abcdc92cef5e4e188a81c319b20be2c8b7ab72
This commit is contained in:
@@ -274,6 +274,9 @@ float Sequence::evaluateAtAbscissa(float x, Poincare::Context * context) const {
|
||||
|
||||
float Sequence::sumOfTermsBetweenAbscissa(float start, float end, Context * context) {
|
||||
float result = 0.0f;
|
||||
if (end-start > k_maxNumberOfTermsInSum) {
|
||||
return NAN;
|
||||
}
|
||||
for (float i = roundf(start); i <= roundf(end); i = i + 1.0f) {
|
||||
result += evaluateAtAbscissa(i, context);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
float sumOfTermsBetweenAbscissa(float start, float end, Poincare::Context * context);
|
||||
private:
|
||||
constexpr static int k_maxRecurrentRank = 10000;
|
||||
constexpr static float k_maxNumberOfTermsInSum = 100000.0f;
|
||||
char symbol() const override;
|
||||
Type m_type;
|
||||
char m_firstInitialConditionText[TextField::maxBufferSize()];
|
||||
|
||||
Reference in New Issue
Block a user