diff --git a/apps/calculation/selectable_table_view.cpp b/apps/calculation/selectable_table_view.cpp index 611337e10..12aa4c661 100644 --- a/apps/calculation/selectable_table_view.cpp +++ b/apps/calculation/selectable_table_view.cpp @@ -24,7 +24,7 @@ void CalculationSelectableTableView::scrollToCell(int i, int j) { if (dataSource()->rowHeight(j) > bounds().height()) { KDCoordinate contentOffsetX = contentOffset().x(); KDCoordinate contentOffsetY = contentOffset().y(); - if (contentOffset().y() > dataSource()->cumulatedHeightFromIndex(j) && contentOffset().y() > dataSource()->cumulatedHeightFromIndex(j+1)) { + if (contentOffsetY > dataSource()->cumulatedHeightFromIndex(j) && contentOffsetY > dataSource()->cumulatedHeightFromIndex(j+1)) { // Let's scroll the tableView to align the top of the cell to the top contentOffsetY = dataSource()->cumulatedHeightFromIndex(j); } else { @@ -47,15 +47,13 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo } /* Main part of the scroll */ KDCoordinate contentOffsetX = contentOffset().x(); - KDCoordinate contentOffsetY = contentOffset().y(); + KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling(); if (subviewType == HistoryViewCell::SubviewType::Input) { if (j == 0) { contentOffsetY = 0; } else { contentOffsetY = dataSource()->cumulatedHeightFromIndex(j); } - } else { - contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling(); } /* For the same reason, we have to rehighlight the new history view cell and * inform the delegate which history view cell is highlighted even if the diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 31e99585a..3d0127bb9 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -47,7 +47,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell; CartesianFunction * function = functionAtColumn(i); char bufferName[6] = {0, 0, '(', 'x', ')', 0}; - const char * name = bufferName; + const char * name = nullptr; if (isDerivativeColumn(i)) { bufferName[0] = *function->name(); bufferName[1] = '\''; diff --git a/apps/regression/store.cpp b/apps/regression/store.cpp index 16ec6ba5a..9e7cc7407 100644 --- a/apps/regression/store.cpp +++ b/apps/regression/store.cpp @@ -65,10 +65,8 @@ int Store::closestVerticalDot(int direction, float x) { // Compare with the mean dot if (m_xMin <= meanOfColumn(0) && meanOfColumn(0) <= m_xMax && (fabsf(meanOfColumn(0) - x) < fabsf(nextX - x)) && - ((meanOfColumn(1) - yValueForXValue(meanOfColumn(0)) >= 0) == (direction > 0))) { + ((meanOfColumn(1) - yValueForXValue(meanOfColumn(0)) >= 0) == (direction > 0))) { if (nextX != meanOfColumn(0) || ((nextY - meanOfColumn(1) >= 0) == (direction > 0))) { - nextX = meanOfColumn(0); - nextY = meanOfColumn(1); selectedDot = m_numberOfPairs; } } @@ -105,7 +103,6 @@ int Store::nextDot(int direction, int dot) { (m_numberOfPairs != dot) && (meanOfColumn(0) >= x)) { if (meanOfColumn(0) != x || (x > dot)) { - nextX = meanOfColumn(0); selectedDot = m_numberOfPairs; } } diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index 09827866d..1c5884970 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -178,7 +178,7 @@ void HistogramController::reloadBannerView() { strlcpy(buffer, legend, legendLength+1); numberOfChar += legendLength; float frequency = size/m_store->sumOfColumn(1); - numberOfChar += Complex::convertFloatToText(frequency, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + Complex::convertFloatToText(frequency, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); m_bannerView.setLegendAtIndex(buffer, 5); } diff --git a/poincare/src/binary_operation.cpp b/poincare/src/binary_operation.cpp index 664003187..5fdeb1030 100644 --- a/poincare/src/binary_operation.cpp +++ b/poincare/src/binary_operation.cpp @@ -47,17 +47,37 @@ Expression * BinaryOperation::privateEvaluate(Context& context, AngleUnit angleU return nullptr; } Expression * result = nullptr; - if (leftOperandEvalutation->type() == Type::Complex && rightOperandEvalutation->type() == Type::Complex) { - result = evaluateOnComplex((Complex *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit); - } - if (leftOperandEvalutation->type() == Type::Complex && rightOperandEvalutation->type() == Type::Matrix) { - result = evaluateOnComplexAndMatrix((Complex *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit); - } - if (leftOperandEvalutation->type() == Type::Matrix && rightOperandEvalutation->type() == Type::Complex) { - result = evaluateOnMatrixAndComplex((Matrix *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit); - } - if (leftOperandEvalutation->type() == Type::Matrix && rightOperandEvalutation->type() == Type::Matrix) { - result = evaluateOnMatrices((Matrix *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit); + switch (leftOperandEvalutation->type()) { + case Type::Complex: + { + switch (rightOperandEvalutation->type()) { + case Type::Complex: + result = evaluateOnComplex((Complex *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit); + break; + case Type::Matrix: + result = evaluateOnComplexAndMatrix((Complex *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit); + break; + default: + break; + } + } + break; + case Type::Matrix: + { + switch (rightOperandEvalutation->type()) { + case Type::Complex: + result = evaluateOnMatrixAndComplex((Matrix *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit); + break; + case Type::Matrix: + result = evaluateOnMatrices((Matrix *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit); + break; + default: + break; + } + } + break; + default: + break; } delete leftOperandEvalutation; delete rightOperandEvalutation; diff --git a/poincare/src/matrix.cpp b/poincare/src/matrix.cpp index 97ab0ac93..389469825 100644 --- a/poincare/src/matrix.cpp +++ b/poincare/src/matrix.cpp @@ -283,8 +283,8 @@ Expression * Matrix::createInverse(Context& context, AngleUnit angleUnit) const } } Expression ** operands = (Expression **)malloc(numberOfOperands()*sizeof(Expression *)); - for (int i = 0; i < numberOfRows(); i++) { - for (int j = 0; j < numberOfColumns(); j++) { + for (int i = 0; i < dim; i++) { + for (int j = 0; j < dim; j++) { operands[i*dim+j] = new Complex(Complex::Float(inv[i][j+dim])); } } diff --git a/poincare/src/opposite.cpp b/poincare/src/opposite.cpp index 92018ecd3..b65e708a0 100644 --- a/poincare/src/opposite.cpp +++ b/poincare/src/opposite.cpp @@ -43,11 +43,15 @@ Expression * Opposite::privateEvaluate(Context& context, AngleUnit angleUnit) co return nullptr; } Expression * result = nullptr; - if (operandEvalutation->type() == Type::Complex) { - result = new Complex(Complex::Cartesian(-((Complex *)operandEvalutation)->a(), -((Complex *)operandEvalutation)->b())); - } - if (operandEvalutation->type() == Type::Matrix) { - result = evaluateOnMatrix((Matrix *)operandEvalutation, context, angleUnit); + switch (operandEvalutation->type()) { + case Type::Complex: + result = new Complex(Complex::Cartesian(-((Complex *)operandEvalutation)->a(), -((Complex *)operandEvalutation)->b())); + break; + case Type::Matrix: + result = evaluateOnMatrix((Matrix *)operandEvalutation, context, angleUnit); + break; + default: + break; } delete operandEvalutation; return result; diff --git a/poincare/src/simplify/expression_match.cpp b/poincare/src/simplify/expression_match.cpp index b802128b7..a0ba47ee4 100644 --- a/poincare/src/simplify/expression_match.cpp +++ b/poincare/src/simplify/expression_match.cpp @@ -14,7 +14,7 @@ ExpressionMatch::ExpressionMatch() { ExpressionMatch::ExpressionMatch(const Expression ** expressions, int numberOfExpressions) { m_numberOfExpressions = numberOfExpressions; - m_expressions = (const Expression**) malloc(m_numberOfExpressions * sizeof(ExpressionMatch*)); + m_expressions = (const Expression**) malloc(m_numberOfExpressions * sizeof(Expression*)); for (int i(0); i