mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] change createLayout signature
- CreateLayout depends on the float display mode and the number of significant digits - Float display mode does not have a default value anymore
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#include "calculation.h"
|
||||
#include "calculation_store.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Calculation {
|
||||
|
||||
@@ -106,7 +109,7 @@ Expression * Calculation::input() {
|
||||
|
||||
ExpressionLayout * Calculation::createInputLayout() {
|
||||
if (input() != nullptr) {
|
||||
return input()->createLayout(PrintFloat::Mode::Decimal, Expression::ComplexFormat::Cartesian);
|
||||
return input()->createLayout(PrintFloat::Mode::Decimal, PrintFloat::k_numberOfStoredSignificantDigits);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -158,7 +161,7 @@ Expression * Calculation::exactOutput(Context * context) {
|
||||
|
||||
ExpressionLayout * Calculation::createExactOutputLayout(Context * context) {
|
||||
if (exactOutput(context) != nullptr) {
|
||||
return exactOutput(context)->createLayout();
|
||||
return PoincareHelpers::CreateLayout(exactOutput(context));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -180,7 +183,7 @@ Expression * Calculation::approximateOutput(Context * context) {
|
||||
|
||||
ExpressionLayout * Calculation::createApproximateOutputLayout(Context * context) {
|
||||
if (approximateOutput(context) != nullptr) {
|
||||
return approximateOutput(context)->createLayout();
|
||||
return PoincareHelpers::CreateLayout(approximateOutput(context));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "graph_controller_helper.h"
|
||||
#include "../../constant.h"
|
||||
#include "../../shared/poincare_helpers.h"
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
@@ -25,7 +26,7 @@ void GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(Shar
|
||||
buffer[0] = function->name()[0];
|
||||
buffer[1] = '\'';
|
||||
double y = function->approximateDerivative(cursor->x(), app->localContext());
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits);
|
||||
strlcpy(buffer+numberOfChar, space, spaceLength+1);
|
||||
buffer[k_maxDigitLegendLength+6] = 0;
|
||||
bannerView()->setLegendAtIndex(buffer, 2);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "intersection_graph_controller.h"
|
||||
#include "../app.h"
|
||||
#include "../../shared/poincare_helpers.h"
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
@@ -30,7 +31,7 @@ void IntersectionGraphController::reloadBannerView() {
|
||||
numberOfChar += legendLength;
|
||||
buffer[0] = m_function->name()[0];
|
||||
buffer[5] = m_intersectedFunction->name()[0];
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(m_cursor->y(), buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(m_cursor->y(), buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
strlcpy(buffer+numberOfChar, space, spaceLength+1);
|
||||
buffer[FunctionBannerDelegate::k_maxDigitLegendLength+legendLength] = 0;
|
||||
bannerView()->setLegendAtIndex(buffer, 1);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "tangent_graph_controller.h"
|
||||
#include "../../shared/poincare_helpers.h"
|
||||
#include "../app.h"
|
||||
|
||||
using namespace Shared;
|
||||
@@ -46,14 +47,14 @@ void TangentGraphController::reloadBannerView() {
|
||||
int legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
double y = m_function->approximateDerivative(m_cursor->x(), myApp->localContext());
|
||||
PrintFloat::convertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
m_bannerView->setLegendAtIndex(buffer, 4);
|
||||
|
||||
legend = "b=";
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
y = -y*m_cursor->x()+m_function->evaluateAtAbscissa(m_cursor->x(), myApp->localContext());
|
||||
PrintFloat::convertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
m_bannerView->setLegendAtIndex(buffer, 5);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void BatteryTestController::updateBatteryState(float batteryLevel, bool batteryC
|
||||
const char * legend = "Battery level: ";
|
||||
int legendLength = strlen(legend);
|
||||
strlcpy(bufferLevel, legend, legendLength+1);
|
||||
PrintFloat::convertFloatToText<float>(batteryLevel, bufferLevel+legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PrintFloat::convertFloatToText<float>(batteryLevel, bufferLevel+legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, PrintFloat::Mode::Decimal);
|
||||
m_view.batteryLevelTextView()->setText(bufferLevel);
|
||||
|
||||
char bufferCharging[ContentView::k_maxNumberOfCharacters + PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "calculation_controller.h"
|
||||
#include "../constant.h"
|
||||
#include "../apps_container.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include "../../poincare/src/layout/char_layout.h"
|
||||
#include "../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../poincare/src/layout/vertical_offset_layout.h"
|
||||
@@ -157,9 +158,9 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
double calculation2 = (m_store->*calculationMethods[j-1])(seriesNumber, 1);
|
||||
EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell;
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(calculation1, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(calculation1, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
myCell->setFirstText(buffer);
|
||||
PrintFloat::convertFloatToText<double>(calculation2, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(calculation2, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
myCell->setSecondText(buffer);
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +176,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
CalculPointer calculationMethods[] = {&Store::doubleCastedNumberOfPairsOfSeries, &Store::covariance, &Store::columnProductSum};
|
||||
double calculation = (m_store->*calculationMethods[j-k_totalNumberOfDoubleBufferRows-1])(seriesNumber);
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
bufferCell->setText(buffer);
|
||||
return;
|
||||
}
|
||||
@@ -206,7 +207,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
CalculPointer calculationMethods[2] = {&Store::correlationCoefficient, &Store::squaredCorrelationCoefficient};
|
||||
double calculation = (m_store->*calculationMethods[j - k_regressionCellIndex - maxNumberCoefficients - 1])(seriesNumber);
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
bufferCell->setText(buffer);
|
||||
return;
|
||||
} else {
|
||||
@@ -221,7 +222,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
return;
|
||||
} else {
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(coefficients[j - k_regressionCellIndex - 1], buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(coefficients[j - k_regressionCellIndex - 1], buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
bufferCell->setText(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "graph_controller.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include "../apps_container.h"
|
||||
#include <kandinsky/text.h>
|
||||
#include <cmath>
|
||||
@@ -125,7 +126,7 @@ void GraphController::reloadBannerView() {
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(x, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(x, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
for (int i = numberOfChar; i < k_maxLegendLength; i++) {
|
||||
buffer[numberOfChar++] = ' ';
|
||||
}
|
||||
@@ -144,7 +145,7 @@ void GraphController::reloadBannerView() {
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(y, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(y, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
for (int i = numberOfChar; i < k_maxLegendLength; i++) {
|
||||
buffer[numberOfChar++] = ' ';
|
||||
}
|
||||
@@ -182,7 +183,7 @@ void GraphController::reloadBannerView() {
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(coefficients[i], buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(coefficients[i], buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
buffer[k_maxLegendLength] = 0;
|
||||
m_bannerView.setLegendAtIndex(buffer, 4 + i);
|
||||
coefficientName++;
|
||||
@@ -196,7 +197,7 @@ void GraphController::reloadBannerView() {
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(r, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(r, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
buffer[k_maxLegendLength+10] = 0;
|
||||
m_bannerView.setLegendAtIndex(buffer, 6);
|
||||
|
||||
@@ -207,7 +208,7 @@ void GraphController::reloadBannerView() {
|
||||
legendLength = strlen(legend);
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(r2, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(r2, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
buffer[k_maxLegendLength] = 0;
|
||||
m_bannerView.setLegendAtIndex(buffer, 7);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "../../poincare/src/layout/char_layout.h"
|
||||
#include "../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../poincare/src/layout/vertical_offset_layout.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
|
||||
@@ -167,7 +168,7 @@ Poincare::ExpressionLayout * Sequence::firstInitialConditionLayout() {
|
||||
if (m_firstInitialConditionLayout == nullptr) {
|
||||
Expression * nonSimplifedExpression = Expression::parse(m_firstInitialConditionText);
|
||||
if (nonSimplifedExpression) {
|
||||
m_firstInitialConditionLayout = nonSimplifedExpression->createLayout(PrintFloat::Mode::Decimal);
|
||||
m_firstInitialConditionLayout = PoincareHelpers::CreateLayout(nonSimplifedExpression);
|
||||
delete nonSimplifedExpression;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +179,7 @@ Poincare::ExpressionLayout * Sequence::secondInitialConditionLayout() {
|
||||
if (m_secondInitialConditionLayout == nullptr) {
|
||||
Expression * nonSimplifedExpression = Expression::parse(m_secondInitialConditionText);
|
||||
if (nonSimplifedExpression) {
|
||||
m_secondInitialConditionLayout = nonSimplifedExpression->createLayout(PrintFloat::Mode::Decimal);
|
||||
m_secondInitialConditionLayout = PoincareHelpers::CreateLayout(nonSimplifedExpression);
|
||||
delete nonSimplifedExpression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "function.h"
|
||||
#include "poincare_helpers.h"
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <assert.h>
|
||||
@@ -48,7 +49,7 @@ Poincare::ExpressionLayout * ExpressionModel::layout() {
|
||||
if (m_layout == nullptr) {
|
||||
Expression * nonSimplifiedExpression = Expression::parse(m_text);
|
||||
if (nonSimplifiedExpression != nullptr) {
|
||||
m_layout = nonSimplifiedExpression->createLayout(PrintFloat::Mode::Decimal);
|
||||
m_layout = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
|
||||
delete nonSimplifiedExpression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "function_banner_delegate.h"
|
||||
#include "poincare_helpers.h"
|
||||
#include "../constant.h"
|
||||
|
||||
using namespace Poincare;
|
||||
@@ -15,7 +16,7 @@ void FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(CurveViewCursor
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
buffer[0] = symbol;
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(cursor->x(), buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(cursor->x(), buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
strlcpy(buffer+numberOfChar, space, spaceLength+1);
|
||||
buffer[k_maxDigitLegendLength+2] = 0;
|
||||
bannerView()->setLegendAtIndex(buffer, 0);
|
||||
@@ -27,7 +28,7 @@ void FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(CurveViewCursor
|
||||
strlcpy(buffer, legend, legendLength+1);
|
||||
buffer[2] = symbol;
|
||||
buffer[0] = function->name()[0];
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(cursor->y(), buffer+legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(cursor->y(), buffer+legendLength, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits);
|
||||
strlcpy(buffer+numberOfChar, space, spaceLength+1);
|
||||
buffer[k_maxDigitLegendLength+5] = 0;
|
||||
bannerView()->setLegendAtIndex(buffer, 1);
|
||||
|
||||
24
apps/shared/poincare_helpers.h
Normal file
24
apps/shared/poincare_helpers.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef SHARED_POINCARE_HELPERS_H
|
||||
#define SHARED_POINCARE_HELPERS_H
|
||||
|
||||
#include <poincare.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
namespace PoincareHelpers {
|
||||
|
||||
inline Poincare::ExpressionLayout * CreateLayout(const Poincare::Expression * e) {
|
||||
return e->createLayout(Poincare::Preferences::sharedPreferences()->displayMode(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int ConvertFloatToText(T d, char * buffer, int bufferSize, int numberOfSignificantDigits) {
|
||||
return Poincare::PrintFloat::convertFloatToText(d, buffer, bufferSize, numberOfSignificantDigits, Poincare::Preferences::sharedPreferences()->displayMode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "sum_graph_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include "poincare_helpers.h"
|
||||
#include "../../poincare/src/layout/condensed_sum_layout.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -266,7 +267,7 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl
|
||||
false);
|
||||
ExpressionLayout * childrenLayouts[3];
|
||||
strlcpy(buffer, "= ", 3);
|
||||
PrintFloat::convertFloatToText<double>(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
childrenLayouts[2] = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
childrenLayouts[1] = functionLayout;
|
||||
childrenLayouts[0] = m_sumLayout;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "text_field_delegate_app.h"
|
||||
#include "../constant.h"
|
||||
#include "../apps_container.h"
|
||||
#include "poincare_helpers.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Poincare;
|
||||
@@ -118,7 +119,7 @@ Button * ValuesController::buttonAtIndex(int index, ButtonRowController::Positio
|
||||
}
|
||||
|
||||
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
willDisplayCellAtLocationWithDisplayMode(cell, i, j, PrintFloat::Mode::Default);
|
||||
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::sharedPreferences()->displayMode());
|
||||
if (cellAtLocationIsEditable(i, j)) {
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +139,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
|
||||
// The cell is a value cell
|
||||
EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell;
|
||||
double x = m_interval->element(j-1);
|
||||
PrintFloat::convertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
myValueCell->setText(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "equation_models_parameter_controller.h"
|
||||
#include "list_controller.h"
|
||||
#include "../constant.h"
|
||||
#include <assert.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include "../i18n.h"
|
||||
@@ -22,7 +23,7 @@ EquationModelsParameterController::EquationModelsParameterController(Responder *
|
||||
m_selectableTableView.setShowsIndicators(false);
|
||||
for (int i = 0; i < k_numberOfExpressionCells; i++) {
|
||||
Poincare::Expression * e = Expression::parse(k_models[i+1]);
|
||||
m_expressionLayouts[i] = e->createLayout(Poincare::PrintFloat::Mode::Decimal, Poincare::Expression::ComplexFormat::Cartesian);
|
||||
m_expressionLayouts[i] = e->createLayout(Poincare::PrintFloat::Mode::Decimal, Constant::ShortNumberOfSignificantDigits);
|
||||
delete e;
|
||||
m_modelCells[i].setExpressionLayout(m_expressionLayouts[i]);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "equation_store.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <limits.h>
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Solver {
|
||||
|
||||
@@ -158,9 +160,9 @@ EquationStore::Error EquationStore::exactSolve(Poincare::Context * context) {
|
||||
/* Turn the results in layouts */
|
||||
for (int i = 0; i < k_maxNumberOfExactSolutions; i++) {
|
||||
if (exactSolutions[i]) {
|
||||
m_exactSolutionExactLayouts[i] = exactSolutions[i]->createLayout();
|
||||
m_exactSolutionExactLayouts[i] = PoincareHelpers::CreateLayout(exactSolutions[i]);
|
||||
Expression * approximate = exactSolutions[i]->approximate<double>(*context);
|
||||
m_exactSolutionApproximateLayouts[i] = approximate->createLayout();
|
||||
m_exactSolutionApproximateLayouts[i] = PoincareHelpers::CreateLayout(approximate);
|
||||
/* Check for identity between exact and approximate layouts */
|
||||
char exactBuffer[Shared::ExpressionModel::k_expressionBufferSize];
|
||||
char approximateBuffer[Shared::ExpressionModel::k_expressionBufferSize];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "solutions_controller.h"
|
||||
#include "app.h"
|
||||
#include "../constant.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
@@ -173,7 +174,7 @@ void SolutionsController::willDisplayCellAtLocation(HighlightCell * cell, int i,
|
||||
if (m_equationStore->type() == EquationStore::Type::Monovariable) {
|
||||
EvenOddBufferTextCell * valueCell = static_cast<EvenOddBufferTextCell *>(cell);
|
||||
char bufferValue[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(m_equationStore->approximateSolutionAtIndex(j), bufferValue, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(m_equationStore->approximateSolutionAtIndex(j), bufferValue, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
valueCell->setText(bufferValue);
|
||||
} else {
|
||||
Shared::ScrollableExactApproximateExpressionsCell * valueCell = static_cast<ScrollableExactApproximateExpressionsCell *>(cell);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "box_controller.h"
|
||||
#include "app.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include "../apps_container.h"
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
@@ -53,7 +55,7 @@ void BoxController::reloadBannerView() {
|
||||
CalculPointer calculationMethods[5] = {&Store::minValue, &Store::firstQuartile, &Store::median, &Store::thirdQuartile,
|
||||
&Store::maxValue};
|
||||
double calculation = (m_store->*calculationMethods[selectedQuantile])(selectedSeriesIndex());
|
||||
int numberOfChar = PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
int numberOfChar = PoincareHelpers::ConvertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
buffer[numberOfChar++] = ' ';
|
||||
buffer[numberOfChar] = 0;
|
||||
m_view.editableBannerView()->setLegendAtIndex(buffer, 2);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "calculation_selectable_table_view.h"
|
||||
#include "../constant.h"
|
||||
#include "../apps_container.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include <poincare.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -87,7 +88,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
double calculation = (m_store->*calculationMethods[j-1])(seriesIndex);
|
||||
EvenOddBufferTextCell * calculationCell = static_cast<EvenOddBufferTextCell *>(cell);
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
PoincareHelpers::ConvertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
calculationCell->setText(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "histogram_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include "../shared/poincare_helpers.h"
|
||||
#include "app.h"
|
||||
#include <cmath>
|
||||
#include <assert.h>
|
||||
@@ -99,7 +100,7 @@ void HistogramController::reloadBannerView() {
|
||||
// Add lower bound
|
||||
if (selectedSeriesIndex() >= 0) {
|
||||
double lowerBound = m_store->startOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex);
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(lowerBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(lowerBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
|
||||
buffer[numberOfChar++] = ';';
|
||||
@@ -107,9 +108,8 @@ void HistogramController::reloadBannerView() {
|
||||
// Add upper bound
|
||||
if (selectedSeriesIndex() >= 0) {
|
||||
double upperBound = m_store->endOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex);
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(upperBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(upperBound, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
|
||||
buffer[numberOfChar++] = '[';
|
||||
|
||||
// Padding
|
||||
@@ -128,7 +128,7 @@ void HistogramController::reloadBannerView() {
|
||||
double size = 0;
|
||||
if (selectedSeriesIndex() >= 0) {
|
||||
size = m_store->heightOfBarAtIndex(selectedSeriesIndex(), *m_selectedBarIndex);
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(size, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(size, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
// Padding
|
||||
for (int i = numberOfChar; i < k_maxLegendLength; i++) {
|
||||
@@ -145,7 +145,7 @@ void HistogramController::reloadBannerView() {
|
||||
numberOfChar += legendLength;
|
||||
if (selectedSeriesIndex() >= 0) {
|
||||
double frequency = size/m_store->sumOfOccurrences(selectedSeriesIndex());
|
||||
numberOfChar += PrintFloat::convertFloatToText<double>(frequency, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
numberOfChar += PoincareHelpers::ConvertFloatToText<double>(frequency, buffer+numberOfChar, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
// Padding
|
||||
for (int i = numberOfChar; i < k_maxLegendLength; i++) {
|
||||
|
||||
@@ -255,7 +255,7 @@ const Expression * VariableBoxController::ContentViewController::expressionForIn
|
||||
ExpressionLayout * VariableBoxController::ContentViewController::expressionLayoutForIndex(int index) {
|
||||
if (m_currentPage == Page::Matrix) {
|
||||
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
|
||||
return m_context->expressionLayoutForSymbol(&symbol);
|
||||
return m_context->expressionLayoutForSymbol(&symbol, Constant::LargeNumberOfSignificantDigits);
|
||||
}
|
||||
#if LIST_VARIABLES
|
||||
if (m_currentPage == Page::List) {
|
||||
|
||||
@@ -213,7 +213,7 @@ bool ExpressionLayoutField::handleEventWithText(const char * text, bool indentat
|
||||
m_contentView.cursor()->insertText(text);
|
||||
return true;
|
||||
}
|
||||
Poincare::ExpressionLayout * resultLayout = resultExpression->createLayout();
|
||||
Poincare::ExpressionLayout * resultLayout = resultExpression->createLayout(Poincare::Preferences::sharedPreferences()->displayMode(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits());
|
||||
delete resultExpression;
|
||||
if (currentNumberOfLayouts + resultLayout->numberOfDescendants(true) >= k_maxNumberOfLayouts) {
|
||||
delete resultLayout;
|
||||
|
||||
@@ -17,7 +17,7 @@ void ADC(const char * input) {
|
||||
constexpr int precision = 8;
|
||||
constexpr int bufferSize = Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(precision);
|
||||
char responseBuffer[bufferSize+4] = {'A', 'D', 'C', '='}; // ADC=
|
||||
Poincare::PrintFloat::convertFloatToText<float>(result, responseBuffer+4, bufferSize, precision);
|
||||
Poincare::PrintFloat::convertFloatToText<float>(result, responseBuffer+4, bufferSize, precision, Poincare::PrintFloat::Mode::Decimal);
|
||||
reply(responseBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "abs");
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
}
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
private:
|
||||
constexpr static int k_maxNValue = 300;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "binomial");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "conj");
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public:
|
||||
}
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
Expression * shallowBeautify(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "/");
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Evaluation<double> * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "=");
|
||||
}
|
||||
|
||||
@@ -248,7 +248,8 @@ public:
|
||||
bool isEqualToItsApproximationLayout(Expression * approximation, int bufferSize, int numberOfSignificantDigits, Context & context);
|
||||
|
||||
/* Layout Engine */
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode = PrintFloat::Mode::Default, ComplexFormat complexFormat = ComplexFormat::Default) const; // Returned object must be deleted
|
||||
virtual ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const = 0; // Returned object must be deleted
|
||||
//virtual int writeTextInBuffer(char * buffer, int bufferSize, PrintFloat::Mode floatDisplayMode) const = 0;
|
||||
virtual int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const = 0;
|
||||
|
||||
/* Simplification */
|
||||
@@ -315,8 +316,6 @@ private:
|
||||
virtual int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const { return -1; }
|
||||
//TODO: What should be the implementation for complex?
|
||||
virtual int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const { return 0; }
|
||||
/* Layout Engine */
|
||||
virtual ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const = 0;
|
||||
/* Simplification */
|
||||
Expression * deepBeautify(Context & context, AngleUnit angleUnit);
|
||||
Expression * deepReduce(Context & context, AngleUnit angleUnit);
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
constexpr static int k_maxOperandValue = 100;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplication */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
/* The expression recorded in global context is already a expression.
|
||||
* Otherwise, we would need the context and the angle unit to evaluate it */
|
||||
const Expression * expressionForSymbol(const Symbol * symbol) override;
|
||||
ExpressionLayout * expressionLayoutForSymbol(const Symbol * symbol);
|
||||
ExpressionLayout * expressionLayoutForSymbol(const Symbol * symbol, int numberOfSignificantDigits);
|
||||
void setExpressionForSymbolName(const Expression * expression, const Symbol * symbol, Context & context) override;
|
||||
static constexpr uint16_t k_maxNumberOfScalarExpressions = 26;
|
||||
static constexpr uint16_t k_maxNumberOfListExpressions = 10;
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, AngleUnit angleUnit);
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "int");
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ class LayoutEngine {
|
||||
|
||||
public:
|
||||
/* Expression to ExpressionLayout */
|
||||
static ExpressionLayout * createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
static ExpressionLayout * createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char * operatorName);
|
||||
static ExpressionLayout * createInfixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
static ExpressionLayout * createPrefixLayout(const Expression * expression, PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
|
||||
/* Create special layouts */
|
||||
static ExpressionLayout * createParenthesedLayout(ExpressionLayout * layout, bool cloneLayout);
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "log");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace Poincare {
|
||||
class Multiplication;
|
||||
|
||||
class Matrix : public DynamicHierarchy {
|
||||
template<typename T> friend class MatrixComplex;
|
||||
template<typename T> friend class MatrixComplex;
|
||||
friend class GlobalContext;
|
||||
public:
|
||||
Matrix(MatrixData * matrixData); // pilfer the operands of matrixData
|
||||
Matrix(const Expression * const * operands, int numberOfRows, int numberOfColumns, bool cloneOperands = true);
|
||||
@@ -41,7 +42,7 @@ private:
|
||||
// Row canonize the array in place
|
||||
template<typename T> static void ArrayRowCanonize(T * array, int numberOfRows, int numberOfColumns, T * c = nullptr);
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Evaluation<double> * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Evaluation */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "root");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "");
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
private:
|
||||
constexpr static int k_maxNValue = 100;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
/* Property */
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace PrintFloat {
|
||||
enum class Mode {
|
||||
Decimal = 0,
|
||||
Scientific = 1,
|
||||
Default = 2
|
||||
};
|
||||
constexpr static int bufferSizeForFloatsWithPrecision(int numberOfSignificantDigits) {
|
||||
// The wors case is -1.234E-38
|
||||
@@ -53,7 +52,7 @@ namespace PrintFloat {
|
||||
* ConvertFloatToText return the number of characters that have been written
|
||||
* in buffer (excluding the last \O character) */
|
||||
template <class T>
|
||||
int convertFloatToText(T d, char * buffer, int bufferSize, int numberOfSignificantDigits, Mode mode = Mode::Default);
|
||||
int convertFloatToText(T d, char * buffer, int bufferSize, int numberOfSignificantDigits, Mode mode);
|
||||
template <class T>
|
||||
static int convertFloatToTextPrivate(T f, char * buffer, int numberOfSignificantDigits, Mode mode);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
private:
|
||||
Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
static int NaturalOrder(const Rational & i, const Rational & j);
|
||||
private:
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Evaluation<double> * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Poincare {
|
||||
class Sequence : public StaticHierarchy<3> {
|
||||
using StaticHierarchy<3>::StaticHierarchy;
|
||||
private:
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
Expression * clone() const override { return nullptr; }
|
||||
int polynomialDegree(char symbolName) const override { return -1; }
|
||||
Type type() const override { return Expression::Type::SimplificationRoot; }
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return nullptr;
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return 0; }
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
}
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
Expression * clone() const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -18,7 +18,7 @@ private:
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Evalutation */
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
|
||||
@@ -17,8 +17,8 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
bool needParenthesisWithParent(const Expression * e) const override;
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
namespace Poincare {
|
||||
|
||||
class Symbol : public StaticHierarchy<0> {
|
||||
friend class Store;
|
||||
public:
|
||||
enum SpecialSymbols : char {
|
||||
/* We can use characters from 1 to 31 as they do not correspond to usual
|
||||
@@ -67,7 +68,7 @@ private:
|
||||
/* Comparison */
|
||||
int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
float characteristicXRange(Context & context, AngleUnit angleUnit = AngleUnit::Default) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
int polynomialDegree(char symbolName) const override;
|
||||
private:
|
||||
/* Layout */
|
||||
ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
Evaluation<double> * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
|
||||
|
||||
@@ -23,10 +23,8 @@ Expression * AbsoluteValue::setSign(Sign s, Context & context, AngleUnit angleUn
|
||||
return this;
|
||||
}
|
||||
|
||||
ExpressionLayout * AbsoluteValue::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new AbsoluteValueLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false);
|
||||
ExpressionLayout * AbsoluteValue::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new AbsoluteValueLayout(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), false);
|
||||
}
|
||||
|
||||
Expression * AbsoluteValue::shallowReduce(Context& context, AngleUnit angleUnit) {
|
||||
|
||||
@@ -71,12 +71,10 @@ Expression * BinomialCoefficient::shallowReduce(Context& context, AngleUnit angl
|
||||
return replaceWith(new Rational(result), true);
|
||||
}
|
||||
|
||||
ExpressionLayout * BinomialCoefficient::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
ExpressionLayout * BinomialCoefficient::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new BinomialCoefficientLayout(
|
||||
operand(0)->createLayout(floatDisplayMode, complexFormat),
|
||||
operand(1)->createLayout(floatDisplayMode, complexFormat),
|
||||
operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits),
|
||||
operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits),
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,8 @@ std::complex<T> Ceiling::computeOnComplex(const std::complex<T> c, AngleUnit ang
|
||||
return std::ceil(c.real());
|
||||
}
|
||||
|
||||
ExpressionLayout * Ceiling::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new CeilingLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false);
|
||||
ExpressionLayout * Ceiling::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new CeilingLayout(m_operands[0]->createLayout(floatDisplayMode, numberOfSignificantDigits), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ Expression * Conjugate::clone() const {
|
||||
return a;
|
||||
}
|
||||
|
||||
ExpressionLayout * Conjugate::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new ConjugateLayout(operand(0)->createLayout(floatDisplayMode, complexFormat), false);
|
||||
ExpressionLayout * Conjugate::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new ConjugateLayout(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), false);
|
||||
}
|
||||
|
||||
Expression * Conjugate::shallowReduce(Context& context, AngleUnit angleUnit) {
|
||||
|
||||
@@ -217,7 +217,7 @@ bool Decimal::needParenthesisWithParent(const Expression * e) const {
|
||||
return e->isOfType(types, 7);
|
||||
}
|
||||
|
||||
ExpressionLayout * Decimal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
ExpressionLayout * Decimal::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
char buffer[k_maxBufferSize];
|
||||
int numberOfChars = convertToText(buffer, k_maxBufferSize, floatDisplayMode, PrintFloat::k_numberOfStoredSignificantDigits);
|
||||
return LayoutEngine::createStringLayout(buffer, numberOfChars);
|
||||
|
||||
@@ -53,12 +53,10 @@ std::complex<T> Division::compute(const std::complex<T> c, const std::complex<T>
|
||||
return c/d;
|
||||
}
|
||||
|
||||
ExpressionLayout * Division::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
ExpressionLayout * Division::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
const Expression * numerator = operand(0)->type() == Type::Parenthesis ? operand(0)->operand(0) : operand(0);
|
||||
const Expression * denominator = operand(1)->type() == Type::Parenthesis ? operand(1)->operand(0) : operand(1);
|
||||
return new FractionLayout(numerator->createLayout(floatDisplayMode, complexFormat), denominator->createLayout(floatDisplayMode, complexFormat), false);
|
||||
return new FractionLayout(numerator->createLayout(floatDisplayMode, numberOfSignificantDigits), denominator->createLayout(floatDisplayMode, numberOfSignificantDigits), false);
|
||||
}
|
||||
|
||||
template<typename T> MatrixComplex<T> Division::computeOnComplexAndMatrix(const std::complex<T> c, const MatrixComplex<T> n) {
|
||||
|
||||
@@ -17,7 +17,7 @@ int EmptyExpression::writeTextInBuffer(char * buffer, int bufferSize, int number
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, Ion::Charset::Empty);
|
||||
}
|
||||
|
||||
ExpressionLayout * EmptyExpression::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
ExpressionLayout * EmptyExpression::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new EmptyLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,13 +49,11 @@ Expression * Equal::shallowReduce(Context& context, AngleUnit angleUnit) {
|
||||
return this;
|
||||
}
|
||||
|
||||
ExpressionLayout * Equal::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
ExpressionLayout * Equal::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
HorizontalLayout * result = new HorizontalLayout();
|
||||
result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, complexFormat), 0, false);
|
||||
result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
|
||||
result->addChildAtIndex(new CharLayout('='), result->numberOfChildren());
|
||||
result->addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, complexFormat), result->numberOfChildren(), false);
|
||||
result->addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits), result->numberOfChildren(), false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,27 +350,6 @@ bool Expression::isEqualToItsApproximationLayout(Expression * approximation, int
|
||||
return equal;
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
|
||||
ExpressionLayout * Expression::createLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
switch (floatDisplayMode) {
|
||||
case PrintFloat::Mode::Default:
|
||||
switch (complexFormat) {
|
||||
case ComplexFormat::Default:
|
||||
return privateCreateLayout(Preferences::sharedPreferences()->displayMode(), Preferences::sharedPreferences()->complexFormat());
|
||||
default:
|
||||
return privateCreateLayout(Preferences::sharedPreferences()->displayMode(), complexFormat);
|
||||
}
|
||||
default:
|
||||
switch (complexFormat) {
|
||||
case ComplexFormat::Default:
|
||||
return privateCreateLayout(floatDisplayMode, Preferences::sharedPreferences()->complexFormat());
|
||||
default:
|
||||
return privateCreateLayout(floatDisplayMode, complexFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Simplification */
|
||||
|
||||
Expression * Expression::ParseAndSimplify(const char * text, Context & context, AngleUnit angleUnit) {
|
||||
|
||||
@@ -92,11 +92,9 @@ std::complex<T> Factorial::computeOnComplex(const std::complex<T> c, AngleUnit a
|
||||
return Complex<T>(std::round(result));
|
||||
}
|
||||
|
||||
ExpressionLayout * Factorial::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
ExpressionLayout * Factorial::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
HorizontalLayout * result = new HorizontalLayout();
|
||||
result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, complexFormat), 0, false);
|
||||
result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
|
||||
result->addChildAtIndex(new CharLayout('!'), result->numberOfChildren());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,8 @@ std::complex<T> Floor::computeOnComplex(const std::complex<T> c, AngleUnit angle
|
||||
return Complex<T>(std::floor(c.real()));
|
||||
}
|
||||
|
||||
ExpressionLayout * Floor::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != PrintFloat::Mode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new FloorLayout(m_operands[0]->createLayout(floatDisplayMode, complexFormat), false);
|
||||
ExpressionLayout * Floor::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return new FloorLayout(m_operands[0]->createLayout(floatDisplayMode, numberOfSignificantDigits), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ const Expression * GlobalContext::expressionForSymbol(const Symbol * symbol) {
|
||||
return m_expressions[index];
|
||||
}
|
||||
|
||||
ExpressionLayout * GlobalContext::expressionLayoutForSymbol(const Symbol * symbol) {
|
||||
ExpressionLayout * GlobalContext::expressionLayoutForSymbol(const Symbol * symbol, int numberOfSignificantDigits) {
|
||||
if (symbol->isMatrixSymbol()) {
|
||||
int index = symbolIndex(symbol);
|
||||
if (m_matrixLayout[index] == nullptr && m_matrixExpressions[index] != nullptr) {
|
||||
m_matrixLayout[index] = m_matrixExpressions[index]->createLayout();
|
||||
m_matrixLayout[index] = m_matrixExpressions[index]->createLayout(PrintFloat::Mode::Decimal, numberOfSignificantDigits);
|
||||
}
|
||||
return m_matrixLayout[index];
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user