[shared] StorageCartesianFunction: add a method

derivativeNameWithArgument
This commit is contained in:
Émilie Feral
2018-10-12 09:37:53 +02:00
parent d30e508bcd
commit 3cedfb84e9
2 changed files with 14 additions and 0 deletions

View File

@@ -46,6 +46,19 @@ StorageCartesianFunction StorageCartesianFunction::NewModel(Ion::Storage::Record
return StorageCartesianFunction(Ion::Storage::sharedStorage()->recordNamed(nameBuffer));
}
int StorageCartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSize, char arg) {
// Fill buffer with f(x). Keep one char for derivative sign.
int numberOfChars = nameWithArgument(buffer, bufferSize-1, arg);
assert(numberOfChars < bufferSize - 1);
char * lastChar = buffer+numberOfChars;
while (*(lastChar+1) != '(' && lastChar >= buffer) {
*(lastChar+1) = *lastChar;
lastChar--;
}
*lastChar = '\'';
return numberOfChars+1;
}
bool StorageCartesianFunction::displayDerivative() const {
return recordData()->displayDerivative();
}

View File

@@ -18,6 +18,7 @@ public:
//bool operator!=(const StorageCartesianFunction & other) const { return !(*(static_cast<Record *>(this)) == static_cast<Record &>(other)); }
bool displayDerivative() const;
void setDisplayDerivative(bool display);
int derivativeNameWithArgument(char * buffer, size_t bufferSize, char arg);
double approximateDerivative(double x, Poincare::Context * context) const;
double sumBetweenBounds(double start, double end, Poincare::Context * context) const override;
Poincare::Expression::Coordinate2D nextMinimumFrom(double start, double step, double max, Poincare::Context * context) const;