Change name: Algebric -> Cartesian

Change-Id: I7855e9df1d401f9a3c0e95c933078852594ff309
This commit is contained in:
Émilie Feral
2017-06-21 13:11:08 +02:00
parent 9a8c65bab5
commit b64a4110af
6 changed files with 13 additions and 13 deletions

View File

@@ -71,7 +71,7 @@ Expression * Calculation::input() {
ExpressionLayout * Calculation::inputLayout() {
if (m_inputLayout == nullptr && input() != nullptr) {
m_inputLayout = input()->createLayout(Expression::FloatDisplayMode::Decimal, Expression::ComplexFormat::Algebric);
m_inputLayout = input()->createLayout(Expression::FloatDisplayMode::Decimal, Expression::ComplexFormat::Cartesian);
}
return m_inputLayout;
}

View File

@@ -150,7 +150,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
delete m_complexFormatLayout;
m_complexFormatLayout = nullptr;
}
if (Preferences::sharedPreferences()->complexFormat() == Expression::ComplexFormat::Algebric) {
if (Preferences::sharedPreferences()->complexFormat() == Expression::ComplexFormat::Cartesian) {
const char text[6] = {'a','+', Ion::Charset::IComplex, 'b', ' ', 0};
m_complexFormatLayout = new StringLayout(text, 6, KDText::FontSize::Small);
} else {

View File

@@ -79,7 +79,7 @@ public:
Default = 2
};
enum class ComplexFormat {
Algebric = 0,
Cartesian = 0,
Polar = 1,
Default = 2
};

View File

@@ -392,7 +392,7 @@ ExpressionLayout * Complex::createPolarLayout(FloatDisplayMode floatDisplayMode)
ExpressionLayout * Complex::createCartesianLayout(FloatDisplayMode floatDisplayMode) const {
char buffer[k_maxComplexBufferLength];
int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, ComplexFormat::Algebric);
int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, ComplexFormat::Cartesian);
return new StringLayout(buffer, numberOfChars);
}

View File

@@ -7,7 +7,7 @@ static Preferences s_preferences;
Preferences::Preferences() :
m_angleUnit(Expression::AngleUnit::Degree),
m_displayMode(Expression::FloatDisplayMode::Decimal),
m_complexFormat(Expression::ComplexFormat::Algebric)
m_complexFormat(Expression::ComplexFormat::Cartesian)
{
}

View File

@@ -8,10 +8,10 @@
using namespace Poincare;
constexpr Expression::FloatDisplayMode Decimal = Expression::FloatDisplayMode::Decimal;
constexpr Expression::FloatDisplayMode Scientific = Expression::FloatDisplayMode::Scientific;
constexpr Expression::ComplexFormat Algebric = Expression::ComplexFormat::Algebric;
constexpr Expression::ComplexFormat Cartesian = Expression::ComplexFormat::Cartesian;
constexpr Expression::ComplexFormat Polar = Expression::ComplexFormat::Polar;
void assert_cartesian_complex_converts_to(float a, float b, const char * result, Expression::FloatDisplayMode mode = Scientific, Expression::ComplexFormat format = Algebric, int significantDigits = 7, int bufferSize = 13+13+7+1) {
void assert_cartesian_complex_converts_to(float a, float b, const char * result, Expression::FloatDisplayMode mode = Scientific, Expression::ComplexFormat format = Cartesian, int significantDigits = 7, int bufferSize = 13+13+7+1) {
int tagSize = 8;
unsigned char tag = 'X';
char * taggedBuffer = (char *)malloc(bufferSize+2*tagSize);
@@ -76,17 +76,17 @@ QUIZ_CASE(poincare_complex_to_text) {
* give the exact right number because of float represention. The closest
* exact representation is -9.090897E-33. */
assert_cartesian_complex_converts_to(-0.00000000000000000000000000000000909090964f, 0.0f, "-9.090897E-33");
assert_cartesian_complex_converts_to(123.421f, 0.0f, "123.4", Decimal, Algebric, 4, 6);
assert_cartesian_complex_converts_to(123.421f, 0.0f, "1.2E2", Decimal, Algebric, 5, 6);
assert_cartesian_complex_converts_to(123.421f, 0.0f, "123.4", Decimal, Cartesian, 4, 6);
assert_cartesian_complex_converts_to(123.421f, 0.0f, "1.2E2", Decimal, Cartesian, 5, 6);
}
QUIZ_CASE(poincare_complex_cartesian_to_text) {
assert_cartesian_complex_converts_to(1.0f, 2.0f, "1+2*i", Decimal, Algebric);
assert_cartesian_complex_converts_to(1.0f, 2.0f, "1+2*i", Decimal, Cartesian);
assert_cartesian_complex_converts_to(1.0f, 2.0f, "2.236068*e^(1.107149*i)", Decimal, Polar);
assert_cartesian_complex_converts_to(-1.3f, 2.444f, "-1.3+2.444*i", Decimal, Algebric);
assert_cartesian_complex_converts_to(-1.3f, 2.444f, "-1.3+2.444*i", Decimal, Cartesian);
assert_cartesian_complex_converts_to(-1.3f, 2.444f, "2.768237*e^(2.059649*i)", Decimal, Polar);
assert_cartesian_complex_converts_to(-1.3f, -2.444f, "-1.3-2.444*i", Decimal, Algebric);
assert_cartesian_complex_converts_to(64078208.0f, 119229408.0f, "6.407821E7+1.192294E8*i", Decimal, Algebric);
assert_cartesian_complex_converts_to(-1.3f, -2.444f, "-1.3-2.444*i", Decimal, Cartesian);
assert_cartesian_complex_converts_to(64078208.0f, 119229408.0f, "6.407821E7+1.192294E8*i", Decimal, Cartesian);
assert_cartesian_complex_converts_to(64078208.0f, 119229408.0f, "1.353576E8*e^(1.07765*i)", Decimal, Polar);
}