mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[shared] Change name: StorageExpressionModel::expression --> expressionReduced
This commit is contained in:
@@ -42,7 +42,7 @@ float GraphController::interestingXRange() {
|
||||
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
|
||||
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
|
||||
ExpiringPointer<StorageCartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
|
||||
float fRange = f->expression(myApp->localContext()).characteristicXRange(*(myApp->localContext()), Poincare::Preferences::sharedPreferences()->angleUnit());
|
||||
float fRange = f->expressionReduced(myApp->localContext()).characteristicXRange(*(myApp->localContext()), Poincare::Preferences::sharedPreferences()->angleUnit());
|
||||
if (!std::isnan(fRange)) {
|
||||
characteristicRange = fRange > characteristicRange ? fRange : characteristicRange;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ Poincare::Expression::Coordinate2D IntersectionGraphController::computeNewPointO
|
||||
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
|
||||
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i);
|
||||
if (record != m_record) {
|
||||
Poincare::Expression e = functionStore()->modelForRecord(record)->expression(context);
|
||||
Poincare::Expression e = functionStore()->modelForRecord(record)->expressionReduced(context);
|
||||
Poincare::Expression::Coordinate2D intersection = functionStore()->modelForRecord(m_record)->nextIntersectionFrom(start, step, max, context, e);
|
||||
if ((std::isnan(result.abscissa) || std::fabs(intersection.abscissa-start) < std::fabs(result.abscissa-start)) && !std::isnan(intersection.abscissa)) {
|
||||
m_intersectedRecord = record;
|
||||
|
||||
@@ -85,7 +85,7 @@ void StorageCartesianFunction::setDisplayDerivative(bool display) {
|
||||
}
|
||||
|
||||
double StorageCartesianFunction::approximateDerivative(double x, Poincare::Context * context) const {
|
||||
Poincare::Derivative derivative = Poincare::Derivative::Builder(expression(context).clone(), Symbol(Symbol::SpecialSymbols::UnknownX), Poincare::Float<double>(x)); // derivative takes ownership of Poincare::Float<double>(x) and the clone of expression
|
||||
Poincare::Derivative derivative = Poincare::Derivative::Builder(expressionReduced(context).clone(), Symbol(Symbol::SpecialSymbols::UnknownX), Poincare::Float<double>(x)); // derivative takes ownership of Poincare::Float<double>(x) and the clone of expression
|
||||
/* TODO: when we approximate derivative, we might want to simplify the
|
||||
* derivative here. However, we might want to do it once for all x (to avoid
|
||||
* lagging in the derivative table. */
|
||||
@@ -94,7 +94,7 @@ double StorageCartesianFunction::approximateDerivative(double x, Poincare::Conte
|
||||
|
||||
double StorageCartesianFunction::sumBetweenBounds(double start, double end, Poincare::Context * context) const {
|
||||
// TODO: this does not work yet because integral does not understand UnknownX
|
||||
Poincare::Integral integral = Poincare::Integral::Builder(expression(context).clone(), Symbol(Symbol::SpecialSymbols::UnknownX), Poincare::Float<double>(start), Poincare::Float<double>(end)); // Integral takes ownership of args
|
||||
Poincare::Integral integral = Poincare::Integral::Builder(expressionReduced(context).clone(), Symbol(Symbol::SpecialSymbols::UnknownX), Poincare::Float<double>(start), Poincare::Float<double>(end)); // Integral takes ownership of args
|
||||
/* TODO: when we approximate integral, we might want to simplify the integral
|
||||
* here. However, we might want to do it once for all x (to avoid lagging in
|
||||
* the derivative table. */
|
||||
@@ -103,22 +103,22 @@ double StorageCartesianFunction::sumBetweenBounds(double start, double end, Poin
|
||||
|
||||
Expression::Coordinate2D StorageCartesianFunction::nextMinimumFrom(double start, double step, double max, Context * context) const {
|
||||
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};
|
||||
return expression(context).nextMinimum(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
return expressionReduced(context).nextMinimum(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
}
|
||||
|
||||
Expression::Coordinate2D StorageCartesianFunction::nextMaximumFrom(double start, double step, double max, Context * context) const {
|
||||
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};
|
||||
return expression(context).nextMaximum(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
return expressionReduced(context).nextMaximum(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
}
|
||||
|
||||
double StorageCartesianFunction::nextRootFrom(double start, double step, double max, Context * context) const {
|
||||
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};
|
||||
return expression(context).nextRoot(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
return expressionReduced(context).nextRoot(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
}
|
||||
|
||||
Expression::Coordinate2D StorageCartesianFunction::nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Expression e) const {
|
||||
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};
|
||||
return expression(context).nextIntersection(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit(), e);
|
||||
return expressionReduced(context).nextIntersection(unknownX, start, step, max, *context, Preferences::sharedPreferences()->angleUnit(), e);
|
||||
}
|
||||
|
||||
StorageCartesianFunction::CartesianFunctionRecordData * StorageCartesianFunction::recordData() const {
|
||||
|
||||
@@ -30,12 +30,12 @@ void StorageExpressionModel::text(char * buffer, size_t bufferSize) const {
|
||||
|
||||
bool StorageExpressionModel::isCircularlyDefined(Poincare::Context * context) const {
|
||||
if (m_circular == -1) {
|
||||
m_circular = Expression::ExpressionWithoutSymbols(expression(context), *context).isUninitialized();
|
||||
m_circular = Expression::ExpressionWithoutSymbols(expressionReduced(context), *context).isUninitialized();
|
||||
}
|
||||
return m_circular;
|
||||
}
|
||||
|
||||
Expression StorageExpressionModel::expression(Poincare::Context * context) const {
|
||||
Expression StorageExpressionModel::expressionReduced(Poincare::Context * context) const {
|
||||
if (m_expression.isUninitialized()) {
|
||||
assert(!isNull());
|
||||
Ion::Storage::Record::Data recordData = value();
|
||||
@@ -47,6 +47,7 @@ Expression StorageExpressionModel::expression(Poincare::Context * context) const
|
||||
Expression StorageExpressionModel::expressionWithSymbol() const {
|
||||
assert(!isNull());
|
||||
Ion::Storage::Record::Data recordData = value();
|
||||
/* A new Expression has to be created at each call (because it might be tempered with after calling) */
|
||||
return Expression::ExpressionFromAddress(expressionAddressForValue(recordData), expressionSizeForValue(recordData));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class StorageExpressionModel : public Ion::Storage::Record {
|
||||
public:
|
||||
StorageExpressionModel(Ion::Storage::Record record);
|
||||
void text(char * buffer, size_t bufferSize) const;
|
||||
Poincare::Expression expression(Poincare::Context * context) const;
|
||||
Poincare::Expression expressionReduced(Poincare::Context * context) const;
|
||||
Poincare::Expression expressionWithSymbol() const;
|
||||
Poincare::Layout layout();
|
||||
/* TODO This comment will be true when Sequence inherits from this class
|
||||
|
||||
@@ -73,7 +73,7 @@ T StorageFunction::templatedApproximateAtAbscissa(T x, Poincare::Context * conte
|
||||
return NAN;
|
||||
}
|
||||
const char unknownX[2] = {Poincare::Symbol::UnknownX, 0};
|
||||
return expression(context).approximateWithValueForSymbol(unknownX, x, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
return expressionReduced(context).approximateWithValueForSymbol(unknownX, x, *context, Preferences::sharedPreferences()->angleUnit());
|
||||
}
|
||||
|
||||
StorageFunction::FunctionRecordData * StorageFunction::recordData() const {
|
||||
|
||||
Reference in New Issue
Block a user