mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-30 04:00:02 +02:00
[apps/stats] Series context
This commit is contained in:
@@ -18,6 +18,7 @@ app_objs += $(addprefix apps/statistics/,\
|
||||
multiple_data_view.o\
|
||||
multiple_data_view_controller.o\
|
||||
multiple_histograms_view.o\
|
||||
series_context.o\
|
||||
store.o\
|
||||
store_controller.o\
|
||||
)
|
||||
|
||||
31
apps/statistics/series_context.cpp
Normal file
31
apps/statistics/series_context.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "series_context.h"
|
||||
#include <poincare/decimal.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
const Expression * SeriesContext::expressionForSymbol(const Symbol * symbol) {
|
||||
assert(m_seriesPairIndex >= 0);
|
||||
if (!symbol->isSeriesSymbol()) {
|
||||
return nullptr;
|
||||
}
|
||||
const char * seriesName = Symbol::textForSpecialSymbols(symbol->name());
|
||||
assert(strlen(seriesName) == 2);
|
||||
|
||||
int series = seriesName[1] - '0';
|
||||
assert(series >= 0 && series < Store::k_numberOfSeries);
|
||||
|
||||
assert((seriesName[0] == 'V') || (seriesName[0] == 'N'));
|
||||
int storeI = seriesName[0] == 'V' ? 0 : 1;
|
||||
|
||||
assert(m_seriesPairIndex < store->numberOfPairsOfSeries(series));
|
||||
|
||||
Expression * result = new Decimal(m_store->get(series, storeI, m_seriesPairIndex));
|
||||
assert(result != nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
26
apps/statistics/series_context.h
Normal file
26
apps/statistics/series_context.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef STATISTICS_SERIES_CONTEXT_H
|
||||
#define STATISTICS_SERIES_CONTEXT_H
|
||||
|
||||
#include <poincare/context.h>
|
||||
#include "../shared/float_pair_store.h"
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
class SeriesContext : public Poincare::Context {
|
||||
public:
|
||||
SeriesContext(Shared::FloatPairStore * store) :
|
||||
Poincare::Context(),
|
||||
m_store(store),
|
||||
m_seriesPairIndex(-1)
|
||||
{}
|
||||
void setStorePosition(int series, int i, int j);
|
||||
void setExpressionForSymbolName(const Poincare::Expression * expression, const Poincare::Symbol * symbol, Poincare::Context & context) override {}
|
||||
const Poincare::Expression * expressionForSymbol(const Poincare::Symbol * symbol) override;
|
||||
private:
|
||||
Shared::FloatPairStore * m_store;
|
||||
int m_seriesPairIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
bool isApproximate(Context & context) const;
|
||||
float characteristicXRange(Context & context, AngleUnit angleUnit = AngleUnit::Default) const override;
|
||||
bool hasAnExactRepresentation(Context & context) const;
|
||||
static const char * textForSpecialSymbols(char name);
|
||||
private:
|
||||
const char * textForSpecialSymbols(char name) const;
|
||||
Expression * replaceSymbolWithExpression(char symbol, Expression * expression) override;
|
||||
/* Simplification */
|
||||
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
|
||||
|
||||
@@ -21,7 +21,7 @@ extern "C" {
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
const char * Symbol::textForSpecialSymbols(char name) const {
|
||||
const char * Symbol::textForSpecialSymbols(char name) {
|
||||
switch (name) {
|
||||
case SpecialSymbols::Ans:
|
||||
return "ans";
|
||||
|
||||
Reference in New Issue
Block a user