19 const char * Symbol::textForSpecialSymbols(
char name)
const {
23 case SpecialSymbols::un:
25 case SpecialSymbols::un1:
27 case SpecialSymbols::vn:
29 case SpecialSymbols::vn1:
31 case SpecialSymbols::M0:
33 case SpecialSymbols::M1:
35 case SpecialSymbols::M2:
37 case SpecialSymbols::M3:
39 case SpecialSymbols::M4:
41 case SpecialSymbols::M5:
43 case SpecialSymbols::M6:
45 case SpecialSymbols::M7:
47 case SpecialSymbols::M8:
49 case SpecialSymbols::M9:
59 switch (index -
'0') {
61 return SpecialSymbols::M0;
63 return SpecialSymbols::M1;
65 return SpecialSymbols::M2;
67 return SpecialSymbols::M3;
69 return SpecialSymbols::M4;
71 return SpecialSymbols::M5;
73 return SpecialSymbols::M6;
75 return SpecialSymbols::M7;
77 return SpecialSymbols::M8;
79 return SpecialSymbols::M9;
82 return SpecialSymbols::M0;
102 return new Symbol(m_name);
106 if (m_name == symbol) {
113 if (m_name == symbol) {
115 if (
parent() && value->needParenthesisWithParent(
parent())) {
168 return replaceWith(e->clone(),
true)->deepReduce(context, angleUnit);
174 Expression * Symbol::templatedApproximate(Context& context, AngleUnit angleUnit)
const {
175 if (context.expressionForSymbol(
this) !=
nullptr) {
176 return context.expressionForSymbol(
this)->approximate<
T>(context, angleUnit);
195 if (m_name == SpecialSymbols::un) {
198 if (m_name == SpecialSymbols::un1) {
201 if (m_name == SpecialSymbols::vn) {
204 if (m_name == SpecialSymbols::vn1) {
208 const char mi[] = {
'M', (char)(m_name-(
char)SpecialSymbols::M0+
'0') };
209 return new StringLayout(mi,
sizeof(mi));
211 return new StringLayout(&m_name, 1);
214 int Symbol::writeTextInBuffer(
char * buffer,
int bufferSize,
int numberOfSignificantDigits)
const {
215 if (bufferSize == 0) {
218 if (bufferSize == 1) {
219 buffer[bufferSize-1] = 0;
223 if (m_name >0 && m_name < 32) {
224 return strlcpy(buffer, textForSpecialSymbols(m_name), bufferSize);
232 if (m_name >= (
char)SpecialSymbols::M0 && m_name <= (
char)SpecialSymbols::M9) {
239 if (m_name >=
'A' && m_name <=
'Z') {
245 int Symbol::simplificationOrderSameType(
const Expression * e,
bool canBeInterrupted)
const {
247 if ((
uint8_t)m_name == ((
uint8_t)static_cast<const Symbol *>(e)->name())) {
250 if ((
uint8_t)m_name > ((
uint8_t)static_cast<const Symbol *>(e)->name())) {
virtual const Expression * expressionForSymbol(const Symbol *symbol)=0
Expression * parent() const
Expression * replaceWith(Expression *newOperand, bool deleteAfterReplace=true)
Sign sign() const override
float characteristicXRange(Context &context, AngleUnit angleUnit=AngleUnit::Default) const override
bool isApproximate(Context &context) const
int polynomialDegree(char symbolName) const override
size_t strlcpy(char *dst, const char *src, size_t len)
Type type() const override
virtual Expression * clone() const =0
static SpecialSymbols matrixSymbol(char index)
static Complex< T > Float(T x)
bool hasAnExactRepresentation(Context &context) const
bool isScalarSymbol() const
bool isMatrixSymbol() const
const Expression * operand(int i) const
virtual Type type() const =0
Expression * clone() const override