mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[libaxx] add cmath and use cmath instead of math.h when required
Change-Id: Id839b17d33c69e2e002f370e553ff35246a1bc90
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "calculation.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
using namespace Poincare;
|
||||
|
||||
namespace Calculation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "discrete_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -35,7 +35,7 @@ I18n::Message DiscreteCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void DiscreteCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index == 0);
|
||||
float rf = roundf(f);
|
||||
float rf = std::round(f);
|
||||
m_abscissa = rf;
|
||||
compute(index);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void DiscreteCalculation::compute(int indexKnownElement) {
|
||||
}
|
||||
m_result = m_law->evaluateAtAbscissa(m_abscissa);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = roundf(m_result/k_precision)*k_precision;
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../law/normal_law.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -43,7 +43,7 @@ I18n::Message FiniteIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void FiniteIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 3);
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
float rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
}
|
||||
@@ -84,12 +84,12 @@ void FiniteIntegralCalculation::compute(int indexKnownElement) {
|
||||
assert(m_law->type() == Law::Type::Normal);
|
||||
float p = (1.0f+m_result)/2.0f;
|
||||
float a = ((NormalLaw *)m_law)->cumulativeDistributiveInverseForProbability(&p);
|
||||
m_lowerBound = roundf((2.0f*m_law->parameterValueAtIndex(0)-a)/k_precision)*k_precision;
|
||||
m_upperBound = roundf(a/k_precision)*k_precision;
|
||||
m_lowerBound = std::round((2.0f*m_law->parameterValueAtIndex(0)-a)/k_precision)*k_precision;
|
||||
m_upperBound = std::round(a/k_precision)*k_precision;
|
||||
}
|
||||
m_result = m_law->finiteIntegralBetweenAbscissas(m_lowerBound, m_upperBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = roundf(m_result/k_precision)*k_precision;
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "left_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -31,7 +31,7 @@ I18n::Message LeftIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void LeftIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
float rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_upperBound = rf;
|
||||
}
|
||||
@@ -60,10 +60,10 @@ void LeftIntegralCalculation::compute(int indexKnownElement) {
|
||||
if (indexKnownElement == 0) {
|
||||
m_result = m_law->cumulativeDistributiveFunctionAtAbscissa(m_upperBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = roundf(m_result/k_precision)*k_precision;
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
} else {
|
||||
m_upperBound = m_law->cumulativeDistributiveInverseForProbability(&m_result);
|
||||
m_upperBound = roundf(m_upperBound/k_precision)*k_precision;
|
||||
m_upperBound = std::round(m_upperBound/k_precision)*k_precision;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "right_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -31,7 +31,7 @@ I18n::Message RightIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
|
||||
void RightIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
float rf = roundf(f/k_precision)*k_precision;
|
||||
float rf = std::round(f/k_precision)*k_precision;
|
||||
if (index == 0) {
|
||||
m_lowerBound = rf;
|
||||
}
|
||||
@@ -60,10 +60,10 @@ void RightIntegralCalculation::compute(int indexKnownElement) {
|
||||
if (indexKnownElement == 0) {
|
||||
m_result = m_law->rightIntegralFromAbscissa(m_lowerBound);
|
||||
/* Results in probability application are rounder to 3 decimals */
|
||||
m_result = roundf(m_result/k_precision)*k_precision;
|
||||
m_result = std::round(m_result/k_precision)*k_precision;
|
||||
} else {
|
||||
m_lowerBound = m_law->rightIntegralInverseForProbability(&m_result);
|
||||
m_lowerBound = roundf(m_lowerBound/k_precision)*k_precision;
|
||||
m_lowerBound = std::round(m_lowerBound/k_precision)*k_precision;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "calculation/right_integral_calculation.h"
|
||||
#include "calculation/finite_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
@@ -231,7 +232,7 @@ bool CalculationController::textFieldDidFinishEditing(TextField * textField, con
|
||||
}
|
||||
}
|
||||
if (!m_law->isContinuous() && (m_highlightedSubviewIndex == 1 || m_calculation->type() == Calculation::Type::FiniteIntegral)) {
|
||||
floatBody = roundf(floatBody);
|
||||
floatBody = std::round(floatBody);
|
||||
}
|
||||
m_calculation->setParameterAtIndex(floatBody, m_highlightedSubviewIndex-1);
|
||||
if (event == Ion::Events::Right || event == Ion::Events::Left) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "binomial_law.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -92,9 +92,9 @@ float BinomialLaw::evaluateAtAbscissa(float x) const {
|
||||
if (x > m_parameter1) {
|
||||
return 0.0f;
|
||||
}
|
||||
float lResult = lgammaf(m_parameter1+1) - lgammaf((int)x+1) - lgammaf(m_parameter1 - (int)x+1)+
|
||||
(int)x*logf(m_parameter2) + (m_parameter1-(int)x)*logf(1-m_parameter2);
|
||||
return expf(lResult);
|
||||
float lResult = std::lgamma(m_parameter1+1) - std::lgamma(floorf(x)+1.0f) - std::lgamma(m_parameter1 - floorf(x)+1.0f)+
|
||||
(int)x*std::log(m_parameter2) + (m_parameter1-(int)x)*std::log(1-m_parameter2);
|
||||
return std::exp(lResult);
|
||||
}
|
||||
|
||||
bool BinomialLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "exponential_law.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <ion.h>
|
||||
|
||||
@@ -66,7 +66,7 @@ float ExponentialLaw::evaluateAtAbscissa(float x) const {
|
||||
if (x < 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return m_parameter1*expf(-m_parameter1*x);
|
||||
return m_parameter1*std::exp(-m_parameter1*x);
|
||||
}
|
||||
|
||||
bool ExponentialLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
@@ -77,7 +77,7 @@ bool ExponentialLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
}
|
||||
|
||||
float ExponentialLaw::cumulativeDistributiveFunctionAtAbscissa(float x) const {
|
||||
return 1.0f - expf(-m_parameter1*x);
|
||||
return 1.0f - std::exp(-m_parameter1*x);
|
||||
}
|
||||
|
||||
float ExponentialLaw::cumulativeDistributiveInverseForProbability(float * probability) {
|
||||
@@ -87,7 +87,7 @@ float ExponentialLaw::cumulativeDistributiveInverseForProbability(float * probab
|
||||
if (*probability <= 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
return -logf(1.0f - *probability)/m_parameter1;
|
||||
return -std::log(1.0f - *probability)/m_parameter1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "law.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
|
||||
namespace Probability {
|
||||
@@ -14,7 +14,7 @@ float Law::xGridUnit() {
|
||||
|
||||
float Law::cumulativeDistributiveFunctionAtAbscissa(float x) const {
|
||||
if (!isContinuous()) {
|
||||
int end = roundf(x);
|
||||
int end = std::round(x);
|
||||
float result = 0.0f;
|
||||
for (int k = 0; k <=end; k++) {
|
||||
result += evaluateAtAbscissa(k);
|
||||
@@ -42,8 +42,8 @@ float Law::finiteIntegralBetweenAbscissas(float a, float b) const {
|
||||
if (isContinuous()) {
|
||||
return cumulativeDistributiveFunctionAtAbscissa(b) - cumulativeDistributiveFunctionAtAbscissa(a);
|
||||
}
|
||||
int start = roundf(a);
|
||||
int end = roundf(b);
|
||||
int start = std::round(a);
|
||||
int end = std::round(b);
|
||||
float result = 0.0f;
|
||||
for (int k = start; k <=end; k++) {
|
||||
result += evaluateAtAbscissa(k);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "normal_law.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <ion.h>
|
||||
|
||||
@@ -45,14 +45,14 @@ float NormalLaw::xMin() {
|
||||
if (m_parameter2 == 0.0f) {
|
||||
return m_parameter1 - 1.0f;
|
||||
}
|
||||
return m_parameter1 - 5.0f*fabsf(m_parameter2);
|
||||
return m_parameter1 - 5.0f*std::fabs(m_parameter2);
|
||||
}
|
||||
|
||||
float NormalLaw::xMax() {
|
||||
if (m_parameter2 == 0.0f) {
|
||||
return m_parameter1 + 1.0f;
|
||||
}
|
||||
return m_parameter1 + 5.0f*fabsf(m_parameter2);
|
||||
return m_parameter1 + 5.0f*std::fabs(m_parameter2);
|
||||
}
|
||||
|
||||
float NormalLaw::yMin() {
|
||||
@@ -72,14 +72,14 @@ float NormalLaw::evaluateAtAbscissa(float x) const {
|
||||
if (m_parameter2 == 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return (1.0f/(fabsf(m_parameter2)*sqrtf(2.0f*M_PI)))*expf(-0.5f*powf((x-m_parameter1)/m_parameter2,2));
|
||||
return (1.0f/(std::fabs(m_parameter2)*std::sqrt(2.0f*M_PI)))*std::exp(-0.5f*std::pow((x-m_parameter1)/m_parameter2,2));
|
||||
}
|
||||
|
||||
bool NormalLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
if (index == 0) {
|
||||
return true;
|
||||
}
|
||||
if (x <= 0 || fabsf(m_parameter1/x) > k_maxRatioMuSigma) {
|
||||
if (x <= 0 || std::fabs(m_parameter1/x) > k_maxRatioMuSigma) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -87,7 +87,7 @@ bool NormalLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
|
||||
void NormalLaw::setParameterAtIndex(float f, int index) {
|
||||
TwoParameterLaw::setParameterAtIndex(f, index);
|
||||
if (index == 0 && fabsf(m_parameter1/m_parameter2) > k_maxRatioMuSigma) {
|
||||
if (index == 0 && std::fabs(m_parameter1/m_parameter2) > k_maxRatioMuSigma) {
|
||||
m_parameter2 = m_parameter1/k_maxRatioMuSigma;
|
||||
}
|
||||
}
|
||||
@@ -96,14 +96,14 @@ float NormalLaw::cumulativeDistributiveFunctionAtAbscissa(float x) const {
|
||||
if (m_parameter2 == 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return standardNormalCumulativeDistributiveFunctionAtAbscissa((x-m_parameter1)/fabsf(m_parameter2));
|
||||
return standardNormalCumulativeDistributiveFunctionAtAbscissa((x-m_parameter1)/std::fabs(m_parameter2));
|
||||
}
|
||||
|
||||
float NormalLaw::cumulativeDistributiveInverseForProbability(float * probability) {
|
||||
if (m_parameter2 == 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return standardNormalCumulativeDistributiveInverseForProbability(*probability)*fabsf(m_parameter2) + m_parameter1;
|
||||
return standardNormalCumulativeDistributiveInverseForProbability(*probability)*std::fabs(m_parameter2) + m_parameter1;
|
||||
}
|
||||
|
||||
float NormalLaw::standardNormalCumulativeDistributiveFunctionAtAbscissa(float abscissa) const {
|
||||
@@ -117,7 +117,7 @@ float NormalLaw::standardNormalCumulativeDistributiveFunctionAtAbscissa(float ab
|
||||
return 1.0f;
|
||||
}
|
||||
/* Waissi & Rossin's formula (error less than 0.0001) */
|
||||
return 1.0f/(1.0f+expf(-sqrtf(M_PI)*(k_beta1*powf(abscissa,5)+k_beta2*powf(abscissa,3)+k_beta3*abscissa)));
|
||||
return 1.0f/(1.0f+std::exp(-std::sqrt(M_PI)*(k_beta1*std::pow(abscissa,5)+k_beta2*std::pow(abscissa,3)+k_beta3*abscissa)));
|
||||
}
|
||||
|
||||
float NormalLaw::standardNormalCumulativeDistributiveInverseForProbability(float probability) {
|
||||
@@ -131,7 +131,7 @@ float NormalLaw::standardNormalCumulativeDistributiveInverseForProbability(float
|
||||
return -standardNormalCumulativeDistributiveInverseForProbability(1-probability);
|
||||
}
|
||||
/* Soranzo & Epure (error less than 0.001) */
|
||||
return (k_alpha3/logf(k_alpha2))*logf(1.0f - logf(-logf(probability)/logf(2.0f))/logf(k_alpha1));
|
||||
return (k_alpha3/std::log(k_alpha2))*std::log(1.0f - std::log(-std::log(probability)/std::log(2.0f))/std::log(k_alpha1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "poisson_law.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <ion.h>
|
||||
|
||||
namespace Probability {
|
||||
@@ -38,7 +38,7 @@ float PoissonLaw::xMin() {
|
||||
|
||||
float PoissonLaw::xMax() {
|
||||
assert(m_parameter1 != 0);
|
||||
return (m_parameter1 + 5.0f*sqrtf(m_parameter1))*(1.0f+k_displayRightMarginRatio);
|
||||
return (m_parameter1 + 5.0f*std::sqrt(m_parameter1))*(1.0f+k_displayRightMarginRatio);
|
||||
}
|
||||
|
||||
float PoissonLaw::yMin() {
|
||||
@@ -59,8 +59,8 @@ float PoissonLaw::evaluateAtAbscissa(float x) const {
|
||||
if (x < 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
float lResult = -m_parameter1+(int)x*logf(m_parameter1)-lgammaf((int)x+1);
|
||||
return expf(lResult);
|
||||
float lResult = -m_parameter1+(int)x*std::log(m_parameter1)-std::lgamma(floorf(x)+1.0f);
|
||||
return std::exp(lResult);
|
||||
}
|
||||
|
||||
bool PoissonLaw::authorizedValueAtIndex(float x, int index) const {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "law_curve_view.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../apps_container.h"
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
@@ -38,7 +39,7 @@ float GoToParameterController::parameterAtIndex(int index) {
|
||||
|
||||
bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
assert(parameterIndex == 0);
|
||||
if (fabsf(f) > k_maxDisplayableFloat) {
|
||||
if (std::fabs(f) > k_maxDisplayableFloat) {
|
||||
app()->displayWarning(I18n::Message::ForbiddenValue);
|
||||
return false;
|
||||
}
|
||||
@@ -46,7 +47,7 @@ bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
if (m_xPrediction) {
|
||||
x = m_store->yValueForXValue(f);
|
||||
}
|
||||
if (fabsf(x) > k_maxDisplayableFloat) {
|
||||
if (std::fabs(x) > k_maxDisplayableFloat) {
|
||||
app()->displayWarning(I18n::Message::ForbiddenValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "graph_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
@@ -77,7 +78,7 @@ void GraphController::reloadBannerView() {
|
||||
strlcpy(buffer+numberOfChar, legend, legendLength+1);
|
||||
numberOfChar += legendLength;
|
||||
} else {
|
||||
numberOfChar += Complex::convertFloatToText(roundf((float)*m_selectedDotIndex+1.0f), buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal);
|
||||
numberOfChar += Complex::convertFloatToText(std::round((float)*m_selectedDotIndex+1.0f), buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal);
|
||||
}
|
||||
legend = ") ";
|
||||
legendLength = strlen(legend);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "graph_view.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "initialisation_parameter_controller.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "store.h"
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
|
||||
using namespace Shared;
|
||||
@@ -27,7 +27,7 @@ int Store::closestVerticalDot(int direction, float x) {
|
||||
* otherwise */
|
||||
for (int index = 0; index < m_numberOfPairs; index++) {
|
||||
if ((m_xMin <= m_data[0][index] && m_data[0][index] <= m_xMax) &&
|
||||
(fabsf(m_data[0][index] - x) < fabsf(nextX - x)) &&
|
||||
(std::fabs(m_data[0][index] - x) < std::fabs(nextX - x)) &&
|
||||
((m_data[1][index] - yValueForXValue(m_data[0][index]) >= 0) == (direction > 0))) {
|
||||
// Handle edge case: if 2 dots have the same abscissa but different ordinates
|
||||
if (nextX != m_data[0][index] || ((nextY - m_data[1][index] >= 0) == (direction > 0))) {
|
||||
@@ -39,7 +39,7 @@ 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)) &&
|
||||
(std::fabs(meanOfColumn(0) - x) < std::fabs(nextX - x)) &&
|
||||
((meanOfColumn(1) - yValueForXValue(meanOfColumn(0)) >= 0) == (direction > 0))) {
|
||||
if (nextX != meanOfColumn(0) || ((nextY - meanOfColumn(1) >= 0) == (direction > 0))) {
|
||||
selectedDot = m_numberOfPairs;
|
||||
@@ -63,7 +63,7 @@ int Store::nextDot(int direction, int dot) {
|
||||
* - the next dot is the closest one in abscissa to x
|
||||
* - the next dot is not the same as the selected one
|
||||
* - the next dot is at the right of the selected one */
|
||||
if (fabsf(m_data[0][index] - x) < fabsf(nextX - x) &&
|
||||
if (std::fabs(m_data[0][index] - x) < std::fabs(nextX - x) &&
|
||||
(index != dot) &&
|
||||
(m_data[0][index] >= x)) {
|
||||
// Handle edge case: 2 dots have same abscissa
|
||||
@@ -74,7 +74,7 @@ int Store::nextDot(int direction, int dot) {
|
||||
}
|
||||
}
|
||||
// Compare with the mean dot
|
||||
if (fabsf(meanOfColumn(0) - x) < fabsf(nextX - x) &&
|
||||
if (std::fabs(meanOfColumn(0) - x) < std::fabs(nextX - x) &&
|
||||
(m_numberOfPairs != dot) &&
|
||||
(meanOfColumn(0) >= x)) {
|
||||
if (meanOfColumn(0) != x || (x > dot)) {
|
||||
@@ -83,7 +83,7 @@ int Store::nextDot(int direction, int dot) {
|
||||
}
|
||||
} else {
|
||||
// Compare with the mean dot
|
||||
if (fabsf(meanOfColumn(0) - x) < fabsf(nextX - x) &&
|
||||
if (std::fabs(meanOfColumn(0) - x) < std::fabs(nextX - x) &&
|
||||
(m_numberOfPairs != dot) &&
|
||||
(meanOfColumn(0) <= x)) {
|
||||
if (meanOfColumn(0) != x || (m_numberOfPairs < dot)) {
|
||||
@@ -92,7 +92,7 @@ int Store::nextDot(int direction, int dot) {
|
||||
}
|
||||
}
|
||||
for (int index = m_numberOfPairs-1; index >= 0; index--) {
|
||||
if (fabsf(m_data[0][index] - x) < fabsf(nextX - x) &&
|
||||
if (std::fabs(m_data[0][index] - x) < std::fabs(nextX - x) &&
|
||||
(index != dot) &&
|
||||
(m_data[0][index] <= x)) {
|
||||
// Handle edge case: 2 dots have same abscissa
|
||||
@@ -169,7 +169,7 @@ float Store::varianceOfColumn(int i) {
|
||||
}
|
||||
|
||||
float Store::standardDeviationOfColumn(int i) {
|
||||
return sqrtf(varianceOfColumn(i));
|
||||
return std::sqrt(varianceOfColumn(i));
|
||||
}
|
||||
|
||||
float Store::covariance() {
|
||||
@@ -189,7 +189,7 @@ float Store::yValueForXValue(float x) {
|
||||
}
|
||||
|
||||
float Store::xValueForYValue(float y) {
|
||||
if (fabsf(slope()) < FLT_EPSILON) {
|
||||
if (std::fabs(slope()) < FLT_EPSILON) {
|
||||
return NAN;
|
||||
}
|
||||
return (y - yIntercept())/slope();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "curve_view_range.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <ion.h>
|
||||
#include <poincare.h>
|
||||
|
||||
@@ -17,8 +17,8 @@ CurveViewRange::CurveViewRange(CurveViewCursor * cursor, InteractiveCurveViewRan
|
||||
void CurveViewRange::roundAbscissa() {
|
||||
float xMin = m_xMin;
|
||||
float xMax = m_xMax;
|
||||
float newXMin = clipped(roundf((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
|
||||
float newXMax = clipped(roundf((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
|
||||
float newXMin = clipped(std::round((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
|
||||
float newXMax = clipped(std::round((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
|
||||
if (isnan(newXMin) || isnan(newXMax)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "go_to_parameter_controller.h"
|
||||
#include "../app.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
assert(parameterIndex == 0);
|
||||
return Shared::FunctionGoToParameterController::setParameterAtIndex(parameterIndex, roundf(f));
|
||||
return Shared::FunctionGoToParameterController::setParameterAtIndex(parameterIndex, std::round(f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "graph_controller.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -45,14 +46,14 @@ bool GraphController::handleEnter() {
|
||||
}
|
||||
|
||||
bool GraphController::moveCursorHorizontally(int direction) {
|
||||
float xCursorPosition = roundf(m_cursor->x());
|
||||
float xCursorPosition = std::round(m_cursor->x());
|
||||
if (direction < 0 && xCursorPosition <= 0) {
|
||||
return false;
|
||||
}
|
||||
/* The cursor moves by step of at minimum 1. If the windowRange is to large
|
||||
* compared to the resolution, the cursor takes bigger round step to cross
|
||||
* the window in approximatively resolution steps. */
|
||||
float step = ceilf((interactiveCurveViewRange()->xMax()-interactiveCurveViewRange()->xMin())/m_view.resolution());
|
||||
float step = std::ceil((interactiveCurveViewRange()->xMax()-interactiveCurveViewRange()->xMin())/m_view.resolution());
|
||||
step = step < 1.0f ? 1.0f : step;
|
||||
float x = direction > 0 ? xCursorPosition + step:
|
||||
xCursorPosition - step;
|
||||
@@ -68,7 +69,7 @@ bool GraphController::moveCursorHorizontally(int direction) {
|
||||
}
|
||||
|
||||
void GraphController::initCursorParameters() {
|
||||
float x = roundf((interactiveCurveViewRange()->xMin()+interactiveCurveViewRange()->xMax())/2.0f);
|
||||
float x = std::round((interactiveCurveViewRange()->xMin()+interactiveCurveViewRange()->xMax())/2.0f);
|
||||
m_indexFunctionSelectedByCursor = 0;
|
||||
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
|
||||
int functionIndex = 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "graph_view.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -26,7 +27,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* We draw a dot at every integer if WindowRange/Resolution < 1. Otherwise,
|
||||
* we draw a dot at every step where step is an integer wider than 1. */
|
||||
float windowRange = pixelToFloat(Axis::Horizontal, bounds().width()) - pixelToFloat(Axis::Horizontal, 0);
|
||||
int step = ceilf(windowRange/resolution());
|
||||
int step = std::ceil(windowRange/resolution());
|
||||
for (int x = rectXMin; x < rectXMax; x += step) {
|
||||
float y = evaluateModelWithParameter(s, x);
|
||||
if (isnan(y)) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../../../poincare/src/layout/horizontal_layout.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace Shared;
|
||||
@@ -64,14 +64,14 @@ bool TermSumController::handleEvent(Ion::Events::Event event) {
|
||||
if (m_step > 0 && m_startSum >= m_cursor->x()) {
|
||||
return false;
|
||||
}
|
||||
if (moveCursorHorizontallyToPosition(roundf(m_cursor->x()-1.0f))) {
|
||||
if (moveCursorHorizontallyToPosition(std::round(m_cursor->x()-1.0f))) {
|
||||
m_graphView->reload();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (event == Ion::Events::Right) {
|
||||
if (moveCursorHorizontallyToPosition(roundf(m_cursor->x()+1.0f))) {
|
||||
if (moveCursorHorizontallyToPosition(std::round(m_cursor->x()+1.0f))) {
|
||||
m_graphView->reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "local_context.h"
|
||||
#include <math.h>
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../poincare/src/layout/baseline_relative_layout.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
@@ -272,7 +273,7 @@ bool Sequence::isEmpty() {
|
||||
}
|
||||
|
||||
float Sequence::evaluateAtAbscissa(float x, Poincare::Context * context) const {
|
||||
float n = roundf(x);
|
||||
float n = std::round(x);
|
||||
switch (m_type) {
|
||||
case Type::Explicite:
|
||||
if (n < 0) {
|
||||
@@ -345,7 +346,7 @@ float Sequence::sumOfTermsBetweenAbscissa(float start, float end, Context * cont
|
||||
if (end-start > k_maxNumberOfTermsInSum || start + 1.0f == start) {
|
||||
return NAN;
|
||||
}
|
||||
for (float i = roundf(start); i <= roundf(end); i = i + 1.0f) {
|
||||
for (float i = std::round(start); i <= std::round(end); i = i + 1.0f) {
|
||||
/* When |start| >> 1.0f, start + 1.0f = start. In that case, quit the
|
||||
* infinite loop. */
|
||||
if (i == i-1.0f || i == i+1.0f) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "interval_parameter_controller.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -24,7 +25,7 @@ bool IntervalParameterController::setParameterAtIndex(int parameterIndex, float
|
||||
app()->displayWarning(I18n::Message::ForbiddenValue);
|
||||
return false;
|
||||
}
|
||||
float parameter = roundf(f);
|
||||
float parameter = std::round(f);
|
||||
if (parameterIndex == 2 && parameter == 0.0f) {
|
||||
parameter = 1.0f;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "values_controller.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -49,7 +50,7 @@ bool ValuesController::setDataAtLocation(float floatBody, int columnIndex, int r
|
||||
if (floatBody < 0) {
|
||||
return false;
|
||||
}
|
||||
return Shared::ValuesController::setDataAtLocation(roundf(floatBody), columnIndex, rowIndex);
|
||||
return Shared::ValuesController::setDataAtLocation(std::round(floatBody), columnIndex, rowIndex);
|
||||
}
|
||||
|
||||
int ValuesController::maxNumberOfCells() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../constant.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
|
||||
using namespace Poincare;
|
||||
@@ -117,7 +117,7 @@ void CurveView::computeLabels(Axis axis) {
|
||||
char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];
|
||||
float step = gridUnit(axis);
|
||||
for (int index = 0; index < numberOfLabels(axis); index++) {
|
||||
float labelValue = 2.0f*step*(ceilf(min(axis)/(2.0f*step)))+index*2.0f*step;
|
||||
float labelValue = 2.0f*step*(std::ceil(min(axis)/(2.0f*step)))+index*2.0f*step;
|
||||
if (labelValue < step && labelValue > -step) {
|
||||
labelValue = 0.0f;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void CurveView::computeLabels(Axis axis) {
|
||||
|
||||
void CurveView::drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOrigin) const {
|
||||
float step = gridUnit(axis);
|
||||
float start = 2.0f*step*(ceilf(min(axis)/(2.0f*step)));
|
||||
float start = 2.0f*step*(std::ceil(min(axis)/(2.0f*step)));
|
||||
float end = max(axis);
|
||||
int i = 0;
|
||||
for (float x = start; x < end; x += 2.0f*step) {
|
||||
@@ -184,14 +184,14 @@ void CurveView::drawSegment(KDContext * ctx, KDRect rect, Axis axis, float coord
|
||||
switch(axis) {
|
||||
case Axis::Horizontal:
|
||||
lineRect = KDRect(
|
||||
roundf(floatToPixel(Axis::Horizontal, lowerBound)), roundf(floatToPixel(Axis::Vertical, coordinate)),
|
||||
roundf(floatToPixel(Axis::Horizontal, upperBound) - floatToPixel(Axis::Horizontal, lowerBound)), thickness
|
||||
std::round(floatToPixel(Axis::Horizontal, lowerBound)), std::round(floatToPixel(Axis::Vertical, coordinate)),
|
||||
std::round(floatToPixel(Axis::Horizontal, upperBound) - floatToPixel(Axis::Horizontal, lowerBound)), thickness
|
||||
);
|
||||
break;
|
||||
case Axis::Vertical:
|
||||
lineRect = KDRect(
|
||||
roundf(floatToPixel(Axis::Horizontal, coordinate)), roundf(floatToPixel(Axis::Vertical, upperBound)),
|
||||
thickness, roundf(floatToPixel(Axis::Vertical, lowerBound) - floatToPixel(Axis::Vertical, upperBound))
|
||||
std::round(floatToPixel(Axis::Horizontal, coordinate)), std::round(floatToPixel(Axis::Vertical, upperBound)),
|
||||
thickness, std::round(floatToPixel(Axis::Vertical, lowerBound) - floatToPixel(Axis::Vertical, upperBound))
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -225,8 +225,8 @@ KDColor s_dotWorkingBuffer[dotDiameter*dotDiameter];
|
||||
KDColor s_oversizeDotWorkingBuffer[oversizeDotDiameter*oversizeDotDiameter];
|
||||
|
||||
void CurveView::drawDot(KDContext * ctx, KDRect rect, float x, float y, KDColor color, bool oversize) const {
|
||||
KDCoordinate px = roundf(floatToPixel(Axis::Horizontal, x));
|
||||
KDCoordinate py = roundf(floatToPixel(Axis::Vertical, y));
|
||||
KDCoordinate px = std::round(floatToPixel(Axis::Horizontal, x));
|
||||
KDCoordinate py = std::round(floatToPixel(Axis::Vertical, y));
|
||||
if ((px + dotDiameter < rect.left() - k_externRectMargin || px - dotDiameter > rect.right() + k_externRectMargin) ||
|
||||
(py + dotDiameter < rect.top() - k_externRectMargin || py - dotDiameter > rect.bottom() + k_externRectMargin)) {
|
||||
return;
|
||||
@@ -320,9 +320,9 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, Model * curve, KDColor c
|
||||
float pxf = floatToPixel(Axis::Horizontal, x);
|
||||
float pyf = floatToPixel(Axis::Vertical, y);
|
||||
if (colorUnderCurve && x > colorLowerBound && x < colorUpperBound) {
|
||||
KDRect colorRect((int)pxf, roundf(pyf), 1, floatToPixel(Axis::Vertical, 0.0f) - roundf(pyf));
|
||||
if (floatToPixel(Axis::Vertical, 0.0f) < roundf(pyf)) {
|
||||
colorRect = KDRect((int)pxf, floatToPixel(Axis::Vertical, 0.0f), 1, roundf(pyf) - floatToPixel(Axis::Vertical, 0.0f));
|
||||
KDRect colorRect((int)pxf, std::round(pyf), 1, floatToPixel(Axis::Vertical, 0.0f) - std::round(pyf));
|
||||
if (floatToPixel(Axis::Vertical, 0.0f) < std::round(pyf)) {
|
||||
colorRect = KDRect((int)pxf, floatToPixel(Axis::Vertical, 0.0f), 1, std::round(pyf) - floatToPixel(Axis::Vertical, 0.0f));
|
||||
}
|
||||
ctx->fillRect(colorRect, color);
|
||||
}
|
||||
@@ -343,10 +343,10 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, Model * curve, KDColor c
|
||||
void CurveView::drawHistogram(KDContext * ctx, KDRect rect, Model * model, float firstBarAbscissa, float barWidth,
|
||||
bool fillBar, KDColor defaultColor, KDColor highlightColor, float highlightLowerBound, float highlightUpperBound) const {
|
||||
float rectMin = pixelToFloat(Axis::Horizontal, rect.left());
|
||||
int rectMinBinNumber = floorf((rectMin - firstBarAbscissa)/barWidth);
|
||||
int rectMinBinNumber = std::floor((rectMin - firstBarAbscissa)/barWidth);
|
||||
float rectMinLowerBound = firstBarAbscissa + rectMinBinNumber*barWidth;
|
||||
float rectMax = pixelToFloat(Axis::Horizontal, rect.right());
|
||||
int rectMaxBinNumber = floorf((rectMax - firstBarAbscissa)/barWidth);
|
||||
int rectMaxBinNumber = std::floor((rectMax - firstBarAbscissa)/barWidth);
|
||||
float rectMaxUpperBound = firstBarAbscissa + (rectMaxBinNumber+1)*barWidth + barWidth;
|
||||
float pHighlightLowerBound = floatToPixel(Axis::Horizontal, highlightLowerBound);
|
||||
float pHighlightUpperBound = floatToPixel(Axis::Horizontal, highlightUpperBound);
|
||||
@@ -361,15 +361,15 @@ void CurveView::drawHistogram(KDContext * ctx, KDRect rect, Model * model, float
|
||||
if (isnan(y)) {
|
||||
continue;
|
||||
}
|
||||
KDCoordinate pxf = roundf(floatToPixel(Axis::Horizontal, x));
|
||||
KDCoordinate pyf = roundf(floatToPixel(Axis::Vertical, y));
|
||||
KDCoordinate pixelBarWidth = fillBar ? roundf(floatToPixel(Axis::Horizontal, x+barWidth)) - roundf(floatToPixel(Axis::Horizontal, x))-1 : 2;
|
||||
KDCoordinate pxf = std::round(floatToPixel(Axis::Horizontal, x));
|
||||
KDCoordinate pyf = std::round(floatToPixel(Axis::Vertical, y));
|
||||
KDCoordinate pixelBarWidth = fillBar ? std::round(floatToPixel(Axis::Horizontal, x+barWidth)) - std::round(floatToPixel(Axis::Horizontal, x))-1 : 2;
|
||||
KDRect binRect(pxf, pyf, pixelBarWidth, floatToPixel(Axis::Vertical, 0.0f) - pyf);
|
||||
if (floatToPixel(Axis::Vertical, 0.0f) < pyf) {
|
||||
binRect = KDRect(pxf, floatToPixel(Axis::Vertical, 0.0f), pixelBarWidth+1, pyf - floatToPixel(Axis::Vertical, 0.0f));
|
||||
}
|
||||
KDColor binColor = defaultColor;
|
||||
if (pxf >= floorf(pHighlightLowerBound) && pxf <= floorf(pHighlightUpperBound)) {
|
||||
if (pxf >= std::floor(pHighlightLowerBound) && pxf <= std::floor(pHighlightUpperBound)) {
|
||||
binColor = highlightColor;
|
||||
}
|
||||
ctx->fillRect(binRect, binColor);
|
||||
@@ -381,7 +381,7 @@ int CurveView::numberOfLabels(Axis axis) const {
|
||||
if (min(otherAxis) > 0.0f || max(otherAxis) < 0.0f) {
|
||||
return 0;
|
||||
}
|
||||
return ceilf((max(axis) - min(axis))/(2*gridUnit(axis)));
|
||||
return std::ceil((max(axis) - min(axis))/(2*gridUnit(axis)));
|
||||
}
|
||||
|
||||
float CurveView::evaluateModelWithParameter(Model * curve, float t) const {
|
||||
@@ -460,8 +460,8 @@ void CurveView::stampAtLocation(KDContext * ctx, KDRect rect, float pxf, float p
|
||||
}
|
||||
uint8_t shiftedMask[stampSize][stampSize];
|
||||
KDColor workingBuffer[stampSize*stampSize];
|
||||
float dx = pxf - floorf(pxf);
|
||||
float dy = pyf - floorf(pyf);
|
||||
float dx = pxf - std::floor(pxf);
|
||||
float dy = pyf - std::floor(pyf);
|
||||
/* TODO: this could be optimized by precomputing 10 or 100 shifted masks. The
|
||||
* dx and dy would be rounded to one tenth or one hundredth to choose the
|
||||
* right shifted mask. */
|
||||
@@ -476,8 +476,8 @@ void CurveView::stampAtLocation(KDContext * ctx, KDRect rect, float pxf, float p
|
||||
|
||||
void CurveView::layoutSubviews() {
|
||||
if (m_curveViewCursor != nullptr && m_cursorView != nullptr) {
|
||||
KDCoordinate xCursorPixelPosition = roundf(floatToPixel(Axis::Horizontal, m_curveViewCursor->x()));
|
||||
KDCoordinate yCursorPixelPosition = roundf(floatToPixel(Axis::Vertical, m_curveViewCursor->y()));
|
||||
KDCoordinate xCursorPixelPosition = std::round(floatToPixel(Axis::Horizontal, m_curveViewCursor->x()));
|
||||
KDCoordinate yCursorPixelPosition = std::round(floatToPixel(Axis::Vertical, m_curveViewCursor->y()));
|
||||
KDRect cursorFrame(xCursorPixelPosition - cursorSize().width()/2, yCursorPixelPosition - cursorSize().height()/2, cursorSize().width(), cursorSize().height());
|
||||
if (cursorSize().height() == 0) {
|
||||
KDCoordinate bannerHeight = m_bannerView != nullptr ? m_bannerView->minimalSizeForOptimalDisplay().height() : 0;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <escher.h>
|
||||
#include <poincare.h>
|
||||
#include <math.h>
|
||||
#include "curve_view_range.h"
|
||||
#include "curve_view_cursor.h"
|
||||
#include "banner_view.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "curve_view_range.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <ion.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
@@ -31,12 +31,12 @@ float CurveViewRange::computeGridUnit(Axis axis, float min, float max) {
|
||||
float units[3] = {k_smallGridUnitMantissa, k_mediumGridUnitMantissa, k_largeGridUnitMantissa};
|
||||
for (int k = 0; k < 3; k++) {
|
||||
float unit = units[k];
|
||||
if (floorf(log10f(d/(unit*maxNumberOfUnits))) != floorf(log10f(d/(unit*minNumberOfUnits)))) {
|
||||
b = floorf(log10f(d/(unit*minNumberOfUnits)));
|
||||
if (std::floor(std::log10(d/(unit*maxNumberOfUnits))) != std::floor(std::log10(d/(unit*minNumberOfUnits)))) {
|
||||
b = std::floor(std::log10(d/(unit*minNumberOfUnits)));
|
||||
a = unit;
|
||||
}
|
||||
}
|
||||
return a*powf(10,b);
|
||||
return a*std::pow(10.0f,b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "function_go_to_parameter_controller.h"
|
||||
#include "text_field_delegate_app.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
@@ -23,7 +24,7 @@ bool FunctionGoToParameterController::setParameterAtIndex(int parameterIndex, fl
|
||||
assert(parameterIndex == 0);
|
||||
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
|
||||
float y = m_function->evaluateAtAbscissa(f, myApp->localContext());
|
||||
if (fabsf(f) > k_maxDisplayableFloat || fabsf(y) > k_maxDisplayableFloat) {
|
||||
if (std::fabs(f) > k_maxDisplayableFloat || std::fabs(y) > k_maxDisplayableFloat) {
|
||||
app()->displayWarning(I18n::Message::ForbiddenValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "interactive_curve_view_range.h"
|
||||
#include <poincare.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -90,7 +90,7 @@ void InteractiveCurveViewRange::zoom(float ratio, float x, float y) {
|
||||
float xMax = m_xMax;
|
||||
float yMin = m_yMin;
|
||||
float yMax = m_yMax;
|
||||
if (ratio*fabsf(xMax-xMin) < k_minFloat || ratio*fabsf(yMax-yMin) < k_minFloat) {
|
||||
if (ratio*std::fabs(xMax-xMin) < k_minFloat || ratio*std::fabs(yMax-yMin) < k_minFloat) {
|
||||
return;
|
||||
}
|
||||
float newXMin = clipped(x*(1.0f-ratio)+ratio*xMin, false);
|
||||
@@ -122,8 +122,8 @@ void InteractiveCurveViewRange::panWithVector(float x, float y) {
|
||||
void InteractiveCurveViewRange::roundAbscissa() {
|
||||
float xMin = m_xMin;
|
||||
float xMax = m_xMax;
|
||||
float newXMin = clipped(roundf((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
|
||||
float newXMax = clipped(roundf((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
|
||||
float newXMin = clipped(std::round((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f, false);
|
||||
float newXMax = clipped(std::round((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f, true);
|
||||
if (isnan(newXMin) || isnan(newXMax)) {
|
||||
return;
|
||||
}
|
||||
@@ -178,16 +178,16 @@ void InteractiveCurveViewRange::centerAxisAround(Axis axis, float position) {
|
||||
}
|
||||
if (axis == Axis::X) {
|
||||
float range = m_xMax - m_xMin;
|
||||
if (fabsf(position/range) > k_maxRatioPositionRange) {
|
||||
range = powf(10.0f, floorf(log10f(fabsf(position)))-1.0f);
|
||||
if (std::fabs(position/range) > k_maxRatioPositionRange) {
|
||||
range = std::pow(10.0f, std::floor(std::log10(std::fabs(position)))-1.0f);
|
||||
}
|
||||
m_xMax = clipped(position + range/2.0f, true);
|
||||
MemoizedCurveViewRange::setXMin(clipped(position - range/2.0f, false));
|
||||
} else {
|
||||
m_yAuto = false;
|
||||
float range = m_yMax - m_yMin;
|
||||
if (fabsf(position/range) > k_maxRatioPositionRange) {
|
||||
range = powf(10.0f, floorf(log10f(fabsf(position)))-1.0f);
|
||||
if (std::fabs(position/range) > k_maxRatioPositionRange) {
|
||||
range = std::pow(10.0f, std::floor(std::log10(std::fabs(position)))-1.0f);
|
||||
}
|
||||
m_yMax = clipped(position + range/2.0f, true);
|
||||
MemoizedCurveViewRange::setYMin(clipped(position - range/2.0f, false));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "interactive_curve_view_range_delegate.h"
|
||||
#include "interactive_curve_view_range.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
@@ -30,11 +30,11 @@ bool InteractiveCurveViewRangeDelegate::didChangeRange(InteractiveCurveViewRange
|
||||
max = 1.0f;
|
||||
}
|
||||
if (min == FLT_MAX) {
|
||||
float step = max != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, fabsf(max)) : 1.0f;
|
||||
float step = max != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, std::fabs(max)) : 1.0f;
|
||||
min = max-step;
|
||||
}
|
||||
if (max == -FLT_MAX) {
|
||||
float step = min != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, fabsf(min)) : 1.0f;
|
||||
float step = min != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, std::fabs(min)) : 1.0f;
|
||||
max = min+step;
|
||||
}
|
||||
interactiveCurveViewRange->setYMin(addMargin(min, range, true));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "memoized_curve_view_range.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
|
||||
@@ -45,7 +45,7 @@ void MemoizedCurveViewRange::setXMin(float xMin) {
|
||||
}
|
||||
m_xMin = xMin;
|
||||
if (m_xMin >= m_xMax) {
|
||||
m_xMax = xMin + powf(10.0f, floorf(log10f(fabsf(xMin)))-1.0f);
|
||||
m_xMax = xMin + std::pow(10.0f, std::floor(std::log10(std::fabs(xMin)))-1.0f);
|
||||
}
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ void MemoizedCurveViewRange::setXMax(float xMax) {
|
||||
}
|
||||
m_xMax = xMax;
|
||||
if (m_xMin >= m_xMax) {
|
||||
m_xMin = xMax - powf(10.0f, floorf(log10f(fabsf(xMax)))-1.0f);
|
||||
m_xMin = xMax - std::pow(10.0f, std::floor(std::log10(std::fabs(xMax)))-1.0f);
|
||||
}
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ void MemoizedCurveViewRange::setYMin(float yMin) {
|
||||
}
|
||||
m_yMin = yMin;
|
||||
if (m_yMin >= m_yMax) {
|
||||
m_yMax = yMin + powf(10.0f, floorf(log10f(fabsf(yMin)))-1.0f);
|
||||
m_yMax = yMin + std::pow(10.0f, std::floor(std::log10(std::fabs(yMin)))-1.0f);
|
||||
}
|
||||
m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ void MemoizedCurveViewRange::setYMax(float yMax) {
|
||||
}
|
||||
m_yMax = yMax;
|
||||
if (m_yMin >= m_yMax) {
|
||||
m_yMin = yMax - + powf(10.0f, floorf(log10f(fabsf(yMax)))-1.0f);
|
||||
m_yMin = yMax - + std::pow(10.0f, std::floor(std::log10(std::fabs(yMax)))-1.0f);
|
||||
|
||||
}
|
||||
m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "box_controller.h"
|
||||
#include "app.h"
|
||||
#include "../apps_container.h"
|
||||
#include <math.h>
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "box_view.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -50,8 +50,8 @@ void BoxView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
float lowBound = 0.35f;
|
||||
float upBound = 0.65f;
|
||||
// Draw the main box
|
||||
KDCoordinate firstQuartilePixels = roundf(floatToPixel(Axis::Horizontal, m_store->firstQuartile()));
|
||||
KDCoordinate thirdQuartilePixels = roundf(floatToPixel(Axis::Horizontal, m_store->thirdQuartile()));
|
||||
KDCoordinate firstQuartilePixels = std::round(floatToPixel(Axis::Horizontal, m_store->firstQuartile()));
|
||||
KDCoordinate thirdQuartilePixels = std::round(floatToPixel(Axis::Horizontal, m_store->thirdQuartile()));
|
||||
KDCoordinate lowBoundPixel = floatToPixel(Axis::Vertical, upBound);
|
||||
KDCoordinate upBoundPixel = floatToPixel(Axis::Vertical, lowBound);
|
||||
ctx->fillRect(KDRect(firstQuartilePixels, lowBoundPixel, thirdQuartilePixels - firstQuartilePixels+2,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../apps_container.h"
|
||||
#include "app.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "histogram_parameter_controller.h"
|
||||
#include "app.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -42,7 +43,7 @@ float HistogramParameterController::parameterAtIndex(int index) {
|
||||
bool HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) {
|
||||
assert(parameterIndex >= 0 && parameterIndex < k_numberOfCells);
|
||||
if (parameterIndex == 0) {
|
||||
float newNumberOfBars = ceilf((m_store->maxValue() - m_store->minValue())/f);
|
||||
float newNumberOfBars = std::ceil((m_store->maxValue() - m_store->minValue())/f);
|
||||
if (f <= 0.0f || newNumberOfBars > Store::k_maxNumberOfBars) {
|
||||
app()->displayWarning(I18n::Message::ForbiddenValue);
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "store.h"
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
#include <ion.h>
|
||||
|
||||
@@ -51,14 +51,14 @@ float Store::heightOfBarAtIndex(int index) {
|
||||
|
||||
float Store::heightOfBarAtValue(float value) {
|
||||
float width = barWidth();
|
||||
int barNumber = floorf((value - m_firstDrawnBarAbscissa)/width);
|
||||
int barNumber = std::floor((value - m_firstDrawnBarAbscissa)/width);
|
||||
float lowerBound = m_firstDrawnBarAbscissa + barNumber*width;
|
||||
float upperBound = m_firstDrawnBarAbscissa + (barNumber+1)*width;
|
||||
return sumOfValuesBetween(lowerBound, upperBound);
|
||||
}
|
||||
|
||||
float Store::startOfBarAtIndex(int index) {
|
||||
float firstBarAbscissa = m_firstDrawnBarAbscissa + m_barWidth*floorf((minValue()- m_firstDrawnBarAbscissa)/m_barWidth);
|
||||
float firstBarAbscissa = m_firstDrawnBarAbscissa + m_barWidth*std::floor((minValue()- m_firstDrawnBarAbscissa)/m_barWidth);
|
||||
return firstBarAbscissa + index * m_barWidth;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ float Store::endOfBarAtIndex(int index) {
|
||||
}
|
||||
|
||||
int Store::numberOfBars() {
|
||||
float firstBarAbscissa = m_firstDrawnBarAbscissa + m_barWidth*floorf((minValue()- m_firstDrawnBarAbscissa)/m_barWidth);
|
||||
return ceilf((maxValue() - firstBarAbscissa)/m_barWidth)+1;
|
||||
float firstBarAbscissa = m_firstDrawnBarAbscissa + m_barWidth*std::floor((minValue()- m_firstDrawnBarAbscissa)/m_barWidth);
|
||||
return std::ceil((maxValue() - firstBarAbscissa)/m_barWidth)+1;
|
||||
}
|
||||
|
||||
bool Store::scrollToSelectedBarIndex(int index) {
|
||||
@@ -129,16 +129,16 @@ float Store::variance() {
|
||||
}
|
||||
|
||||
float Store::standardDeviation() {
|
||||
return sqrtf(variance());
|
||||
return std::sqrt(variance());
|
||||
}
|
||||
|
||||
float Store::firstQuartile() {
|
||||
int firstQuartileIndex = ceilf(sumOfColumn(1)/4);
|
||||
int firstQuartileIndex = std::ceil(sumOfColumn(1)/4);
|
||||
return sortedElementNumber(firstQuartileIndex);
|
||||
}
|
||||
|
||||
float Store::thirdQuartile() {
|
||||
int thirdQuartileIndex = ceilf(3*sumOfColumn(1)/4);
|
||||
int thirdQuartileIndex = std::ceil(3*sumOfColumn(1)/4);
|
||||
return sortedElementNumber(thirdQuartileIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../apps_container.h"
|
||||
#include "../constant.h"
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
@@ -37,7 +38,7 @@ bool StoreController::setDataAtLocation(float floatBody, int columnIndex, int ro
|
||||
if (floatBody < 0) {
|
||||
return false;
|
||||
}
|
||||
m_store->set(roundf(floatBody), columnIndex, rowIndex-1);
|
||||
m_store->set(std::round(floatBody), columnIndex, rowIndex-1);
|
||||
return true;
|
||||
}
|
||||
return Shared::StoreController::setDataAtLocation(floatBody, columnIndex, rowIndex);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <escher/button_row_controller.h>
|
||||
#include <escher/palette.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
ButtonRowDelegate::ButtonRowDelegate(ButtonRowController * header, ButtonRowController * footer) :
|
||||
m_header(header),
|
||||
@@ -85,7 +85,7 @@ void ButtonRowController::ContentView::layoutSubviews() {
|
||||
Button * button = buttonAtIndex(i);
|
||||
totalButtonWidth += button->minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
widthMargin = roundf((bounds().width() - totalButtonWidth)/(nbOfButtons+1));
|
||||
widthMargin = std::round((float)((bounds().width() - totalButtonWidth)/(nbOfButtons+1)));
|
||||
buttonHeightMargin = k_embossedStyleHeightMargin;
|
||||
buttonHeight = rowHeight- 2*k_embossedStyleHeightMargin;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void ButtonRowController::ContentView::drawRect(KDContext * ctx, KDRect rect) co
|
||||
Button * button = buttonAtIndex(i);
|
||||
totalButtonWidth += button->minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
KDCoordinate widthMargin = roundf((bounds().width() - totalButtonWidth)/(numberOfButtons()+1));
|
||||
KDCoordinate widthMargin = std::round((float)((bounds().width() - totalButtonWidth)/(numberOfButtons()+1)));
|
||||
|
||||
int currentXOrigin = widthMargin-1;
|
||||
for (int i = 0; i < numberOfButtons(); i++) {
|
||||
|
||||
@@ -8,8 +8,8 @@ LIBA_BEGIN_DECLS
|
||||
|
||||
#define NAN (0.0f/0.0f)
|
||||
#define INFINITY __builtin_inff()
|
||||
#define M_E 2.71828182845904523536028747135266250f
|
||||
#define M_PI 3.14159265358979323846264338327950288f
|
||||
#define M_E 2.71828182845904523536028747135266250
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
|
||||
/* The C99 standard requires isinf and isnan to be defined as macros that can
|
||||
* handle arbitrary precision float numbers. The names of the functions called
|
||||
|
||||
59
libaxx/include/cmath
Normal file
59
libaxx/include/cmath
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef LIBAXX_CMATH
|
||||
#define LIBAXX_CMATH
|
||||
|
||||
extern "C" {
|
||||
#include <math.h>
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
static inline double acos(double x) { return ::acos(x); }
|
||||
static inline float acos(float x) { return ::acosf(x); }
|
||||
static inline double acosh(double x) { return ::acosh(x); }
|
||||
static inline float acosh(float x) { return ::acoshf(x); }
|
||||
static inline double asin(double x) { return ::asin(x); }
|
||||
static inline float asin(float x) { return ::asinf(x); }
|
||||
static inline double asinh(double x) { return ::asinh(x); }
|
||||
static inline float asinh(float x) { return ::asinhf(x); }
|
||||
static inline double atan(double x) { return ::atan(x); }
|
||||
static inline float atan(float x) { return ::atanf(x); }
|
||||
static inline double atanh(double x) { return ::atanh(x); }
|
||||
static inline float atanh(float x) { return ::atanhf(x); }
|
||||
static inline double ceil(double x) { return ::ceil(x); }
|
||||
static inline float ceil(float x) { return ::ceilf(x); }
|
||||
static inline double copysign(double x, double y) { return ::copysign(x, y); }
|
||||
static inline float copysign(float x, float y) { return ::copysignf(x, y); }
|
||||
static inline double cos(double x) { return ::cos(x); }
|
||||
static inline float cos(float x) { return ::cosf(x); }
|
||||
static inline double cosh(double x) { return ::cosh(x); }
|
||||
static inline float cosh(float x) { return ::coshf(x); }
|
||||
static inline double exp(double x) { return ::exp(x); }
|
||||
static inline float exp(float x) { return ::expf(x); }
|
||||
static inline double fabs(double x) { return ::fabs(x); }
|
||||
static inline float fabs(float x) { return ::fabsf(x); }
|
||||
static inline double floor(double x) { return ::floor(x); }
|
||||
static inline float floor(float x) { return ::floorf(x); }
|
||||
static inline double lgamma(double x) { return ::lgamma(x); }
|
||||
static inline float lgamma(float x) { return ::lgammaf(x); }
|
||||
static inline double log10(double x) { return ::log10(x); }
|
||||
static inline float log10(float x) { return ::log10f(x); }
|
||||
static inline double log(double x) { return ::log(x); }
|
||||
static inline float log(float x) { return ::logf(x); }
|
||||
static inline double pow(double x, double y) { return ::pow(x, y); }
|
||||
static inline float pow(float x, float y) { return ::powf(x, y); }
|
||||
static inline double round(double x) { return ::round(x); }
|
||||
static inline float round(float x) { return ::roundf(x); }
|
||||
static inline double sin(double x) { return ::sin(x); }
|
||||
static inline float sin(float x) { return ::sinf(x); }
|
||||
static inline double sinh(double x) { return ::sinh(x); }
|
||||
static inline float sinh(float x) { return ::sinhf(x); }
|
||||
static inline double sqrt(double x) { return ::sqrt(x); }
|
||||
static inline float sqrt(float x) { return ::sqrtf(x); }
|
||||
static inline double tan(double x) { return ::tan(x); }
|
||||
static inline float tan(float x) { return ::tanf(x); }
|
||||
static inline double tanh(double x) { return ::tanh(x); }
|
||||
static inline float tanh(float x) { return ::tanhf(x); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/preferences.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/arc_cosine.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex ArcCosine::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
float result = acosf(c.a());
|
||||
float result = std::acos(c.a());
|
||||
if (angleUnit == AngleUnit::Degree) {
|
||||
return Complex::Float(result*180.0f/M_PI);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/arc_sine.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex ArcSine::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
float result = asinf(c.a());
|
||||
float result = std::asin(c.a());
|
||||
if (angleUnit == AngleUnit::Degree) {
|
||||
return Complex::Float(result*180.0f/M_PI);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/arc_tangent.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex ArcTangent::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
float result = atanf(c.a());
|
||||
float result = std::atan(c.a());
|
||||
if (angleUnit == AngleUnit::Degree) {
|
||||
return Complex::Float(result*180.0f/M_PI);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/binary_operation.h>
|
||||
#include <poincare/complex_matrix.h>
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -43,7 +43,7 @@ Evaluation * BinomialCoefficient::privateEvaluate(Context& context, AngleUnit an
|
||||
for (int i = 0; i < (int)k; i++) {
|
||||
result *= (n-(float)i)/(k-(float)i);
|
||||
}
|
||||
return new Complex(Complex::Float(roundf(result)));
|
||||
return new Complex(Complex::Float(std::round(result)));
|
||||
}
|
||||
|
||||
ExpressionLayout * BinomialCoefficient::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex Ceiling::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(ceilf(c.a()));
|
||||
return Complex::Float(std::ceil(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
}
|
||||
#include <cmath>
|
||||
#include <poincare/complex_matrix.h>
|
||||
#include "layout/string_layout.h"
|
||||
#include "layout/baseline_relative_layout.h"
|
||||
@@ -22,7 +22,7 @@ Complex Complex::Cartesian(float a, float b) {
|
||||
}
|
||||
|
||||
Complex Complex::Polar(float r, float th) {
|
||||
return Complex(r*cosf(th),r*sinf(th));
|
||||
return Complex(r*std::cos(th),r*std::sin(th));
|
||||
}
|
||||
|
||||
static inline float setSign(float f, bool negative) {
|
||||
@@ -53,7 +53,7 @@ Complex::Complex(const char * integralPart, int integralPartLength, bool integra
|
||||
float j = digitsToFloat(fractionalPart, fractionalPartLength);
|
||||
float l = setSign(digitsToFloat(exponent, exponentLength), exponentNegative);
|
||||
|
||||
m_a = setSign((i + j*powf(10.0f, -ceilf(fractionalPartLength)))* powf(10.0f, l), integralNegative);
|
||||
m_a = setSign((i + j*std::pow(10.0f, -std::ceil((float)fractionalPartLength)))* std::pow(10.0f, l), integralNegative);
|
||||
m_b = 0.0f;
|
||||
}
|
||||
|
||||
@@ -103,16 +103,16 @@ float Complex::b() const {
|
||||
|
||||
float Complex::r() const {
|
||||
if (m_b == 0) {
|
||||
return fabsf(m_a);
|
||||
return std::fabs(m_a);
|
||||
}
|
||||
return sqrtf(m_a*m_a + m_b*m_b);
|
||||
return std::sqrt(m_a*m_a + m_b*m_b);
|
||||
}
|
||||
|
||||
float Complex::th() const {
|
||||
float result = atanf(m_b/m_a) + M_PI;
|
||||
float result = std::atan(m_b/m_a) + M_PI;
|
||||
if (m_a >= 0.0f) {
|
||||
float a = m_a == 0.0f ? 0.0f : m_a;
|
||||
result = atanf(m_b/a);
|
||||
result = std::atan(m_b/a);
|
||||
}
|
||||
if (result > M_PI + FLT_EPSILON) {
|
||||
result = result - 2.0f*M_PI;
|
||||
@@ -255,11 +255,11 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
|
||||
return currentChar;
|
||||
}
|
||||
|
||||
float logBase10 = f != 0.0f ? log10f(fabsf(f)) : 0;
|
||||
int exponentInBase10 = floorf(logBase10);
|
||||
float logBase10 = f != 0.0f ? std::log10(std::fabs(f)) : 0;
|
||||
int exponentInBase10 = std::floor(logBase10);
|
||||
/* Correct the exponent in base 10: sometines the exact log10 of f is 6.999999
|
||||
* but is stored as 7 in hardware. We catch these cases here. */
|
||||
if (f != 0.0f && logBase10 == (int)logBase10 && fabsf(f) < powf(10.0f, logBase10)) {
|
||||
if (f != 0.0f && logBase10 == (int)logBase10 && std::fabs(f) < std::pow(10.0f, logBase10)) {
|
||||
exponentInBase10--;
|
||||
}
|
||||
|
||||
@@ -276,49 +276,49 @@ int Complex::convertFloatToTextPrivate(float f, char * buffer, int numberOfSigni
|
||||
/* The number of digits in an integer is capped because the maximal integer is
|
||||
* 2^31 - 1. As our mantissa is an integer, we assert that we stay beyond this
|
||||
* threshold during computation. */
|
||||
assert(availableCharsForMantissaWithoutSign - 1 < log10f(powf(2, 31)));
|
||||
assert(availableCharsForMantissaWithoutSign - 1 < std::log10(std::pow(2.0f, 31.0f)));
|
||||
|
||||
int numberOfDigitBeforeDecimal = exponentInBase10 >= 0 || displayMode == FloatDisplayMode::Scientific ?
|
||||
exponentInBase10 + 1 : 1;
|
||||
float mantissa = roundf(f * powf(10.0f, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal));
|
||||
float mantissa = std::round(f * std::pow(10.0f, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal));
|
||||
/* if availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal
|
||||
* is too big (or too small), mantissa is now inf. We handle this case by
|
||||
* using logarithm function. */
|
||||
if (isnan(mantissa) || isinf(mantissa)) {
|
||||
mantissa = roundf(powf(10.0f, log10f(fabsf(f))+(float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal)));
|
||||
mantissa = copysignf(mantissa, f);
|
||||
mantissa = std::round(std::pow(10.0f, std::log10(std::fabs(f))+(float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal)));
|
||||
mantissa = std::copysign(mantissa, f);
|
||||
}
|
||||
/* We update the exponent in base 10 (if 0.99999999 was rounded to 1 for
|
||||
* instance) */
|
||||
float truncatedMantissa = (int)(f * powf(10, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal));
|
||||
float truncatedMantissa = (int)(f * std::pow(10.0f, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal));
|
||||
if (isinf(truncatedMantissa) || isnan(truncatedMantissa)) {
|
||||
truncatedMantissa = (int)(powf(10.0f, log10f(fabsf(f))+(float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal)));
|
||||
truncatedMantissa = copysignf(truncatedMantissa, f);
|
||||
truncatedMantissa = (int)(std::pow(10.0f, std::log10(std::fabs(f))+(float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal)));
|
||||
truncatedMantissa = std::copysign(truncatedMantissa, f);
|
||||
}
|
||||
if (mantissa != truncatedMantissa) {
|
||||
float newLogBase10 = mantissa != 0.0f ? log10f(fabsf(mantissa/powf(10, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal))) : 0.0f;
|
||||
float newLogBase10 = mantissa != 0.0f ? std::log10(std::fabs(mantissa/std::pow(10.0f, availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal))) : 0.0f;
|
||||
if (isnan(newLogBase10) || isinf(newLogBase10)) {
|
||||
newLogBase10 = log10f(fabsf(mantissa)) - (float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal);
|
||||
newLogBase10 = std::log10(std::fabs(mantissa)) - (float)(availableCharsForMantissaWithoutSign - 1 - numberOfDigitBeforeDecimal);
|
||||
}
|
||||
exponentInBase10 = floorf(newLogBase10);
|
||||
exponentInBase10 = std::floor(newLogBase10);
|
||||
}
|
||||
int decimalMarkerPosition = exponentInBase10 < 0 || displayMode == FloatDisplayMode::Scientific ?
|
||||
1 : exponentInBase10+1;
|
||||
|
||||
// Correct the number of digits in mantissa after rounding
|
||||
int mantissaExponentInBase10 = exponentInBase10 > 0 || displayMode == FloatDisplayMode::Scientific ? availableCharsForMantissaWithoutSign - 1 : availableCharsForMantissaWithoutSign + exponentInBase10;
|
||||
if ((int)(fabsf(mantissa) * powf(10, - mantissaExponentInBase10)) > 0) {
|
||||
if ((int)(std::fabs(mantissa) * std::pow(10.0f, - mantissaExponentInBase10)) > 0) {
|
||||
mantissa = mantissa/10;
|
||||
}
|
||||
|
||||
int numberOfCharExponent = exponentInBase10 != 0 ? log10f(fabsf((float)exponentInBase10)) + 1 : 1;
|
||||
int numberOfCharExponent = exponentInBase10 != 0 ? std::log10(std::fabs((float)exponentInBase10)) + 1 : 1;
|
||||
if (exponentInBase10 < 0){
|
||||
// If the exponent is < 0, we need a additional char for the sign
|
||||
numberOfCharExponent++;
|
||||
}
|
||||
|
||||
// Supress the 0 on the right side of the mantissa
|
||||
int dividend = fabsf((float)mantissa);
|
||||
int dividend = std::fabs((float)mantissa);
|
||||
int quotien = dividend/10;
|
||||
int digit = dividend - quotien*10;
|
||||
int minimumNumberOfCharsInMantissa = 1;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#include <poincare/complex.h>
|
||||
#include "layout/grid_layout.h"
|
||||
#include "layout/bracket_layout.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <poincare/evaluation.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -36,8 +36,8 @@ Evaluation * ConfidenceInterval::privateEvaluate(Context& context, AngleUnit ang
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
Complex operands[2];
|
||||
operands[0] = Complex::Float(f - 1.0f/sqrtf(n));
|
||||
operands[1] = Complex::Float(f + 1.0f/sqrtf(n));
|
||||
operands[0] = Complex::Float(f - 1.0f/std::sqrt(n));
|
||||
operands[1] = Complex::Float(f + 1.0f/std::sqrt(n));
|
||||
return new ComplexMatrix(operands, 2, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <poincare/complex.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -31,7 +31,7 @@ Complex Cosine::compute(const Complex c) {
|
||||
}
|
||||
|
||||
float Cosine::computeForRadianReal(float x) const {
|
||||
return cosf(x);
|
||||
return std::cos(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <poincare/derivative.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/complex.h>
|
||||
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
}
|
||||
|
||||
@@ -52,11 +51,11 @@ Evaluation * Derivative::privateEvaluate(Context& context, AngleUnit angleUnit)
|
||||
* pp. 75–76. */
|
||||
|
||||
// Initiate hh
|
||||
float h = fabsf(x) < FLT_MIN ? k_minInitialRate : x/1000.0f;
|
||||
float h = std::fabs(x) < FLT_MIN ? k_minInitialRate : x/1000.0f;
|
||||
float f2 = approximateDerivate2(x, h, xContext, angleUnit);
|
||||
f2 = fabsf(f2) < FLT_MIN ? k_minInitialRate : f2;
|
||||
float hh = sqrtf(fabsf(functionValue/(f2/(powf(h,2.0f)))))/10.0f;
|
||||
hh = fabsf(hh) <FLT_MIN ? k_minInitialRate : hh;
|
||||
f2 = std::fabs(f2) < FLT_MIN ? k_minInitialRate : f2;
|
||||
float hh = std::sqrt(std::fabs(functionValue/(f2/(std::pow(h,2.0f)))))/10.0f;
|
||||
hh = std::fabs(hh) <FLT_MIN ? k_minInitialRate : hh;
|
||||
/* Make hh an exactly representable number */
|
||||
volatile float temp = x+hh;
|
||||
hh = temp - x;
|
||||
@@ -84,7 +83,7 @@ Evaluation * Derivative::privateEvaluate(Context& context, AngleUnit angleUnit)
|
||||
for (int j = 1; j < 10; j++) {
|
||||
a[j][i] = (a[j-1][i]*fac-a[j-1][i-1])/(fac-1.0f);
|
||||
fac = k_rateStepSize*k_rateStepSize*fac;
|
||||
errt = fabsf(a[j][i]-a[j-1][i]) > fabsf(a[j][i]-a[j-1][i-1]) ? fabsf(a[j][i]-a[j-1][i]) : fabsf(a[j][i]-a[j-1][i-1]);
|
||||
errt = std::fabs(a[j][i]-a[j-1][i]) > std::fabs(a[j][i]-a[j-1][i-1]) ? std::fabs(a[j][i]-a[j-1][i]) : std::fabs(a[j][i]-a[j-1][i-1]);
|
||||
/* Update error and answer if error decreases */
|
||||
if (errt < err) {
|
||||
err = errt;
|
||||
@@ -93,7 +92,7 @@ Evaluation * Derivative::privateEvaluate(Context& context, AngleUnit angleUnit)
|
||||
}
|
||||
/* If higher extrapolation order significantly increases the error, return
|
||||
* early */
|
||||
if (fabsf(a[i][i]-a[i-1][i-1]) > 2.0f*err) {
|
||||
if (std::fabs(a[i][i]-a[i-1][i-1]) > 2.0f*err) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,8 +103,8 @@ Evaluation * Derivative::privateEvaluate(Context& context, AngleUnit angleUnit)
|
||||
if (err < FLT_MIN) {
|
||||
return new Complex(Complex::Float(ans));
|
||||
}
|
||||
err = powf(10.0f, (int)log10f(fabsf(err))+2.0f);
|
||||
return new Complex(Complex::Float(roundf(ans/err)*err));
|
||||
err = std::pow(10.0f, (int)std::log10(std::fabs(err))+2.0f);
|
||||
return new Complex(Complex::Float(std::round(ans/err)*err));
|
||||
}
|
||||
|
||||
float Derivative::growthRateAroundAbscissa(float x, float h, VariableContext xContext, AngleUnit angleUnit) const {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <poincare/matrix.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -34,7 +34,7 @@ Evaluation * DivisionQuotient::privateEvaluate(Context & context, AngleUnit angl
|
||||
if (isnan(f1) || isnan(f2) || f1 != (int)f1 || f2 != (int)f2) {
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
return new Complex(Complex::Float(floorf(f1/f2)));
|
||||
return new Complex(Complex::Float(std::floor(f1/f2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -34,7 +34,7 @@ Evaluation * DivisionRemainder::privateEvaluate(Context & context, AngleUnit ang
|
||||
if (isnan(f1) || isnan(f2) || f1 != (int)f1 || f2 != (int)f2) {
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
return new Complex(Complex::Float(roundf(f1-f2*floorf(f1/f2))));
|
||||
return new Complex(Complex::Float(std::round(f1-f2*std::floor(f1/f2))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
#include <poincare/complex.h>
|
||||
#include "layout/grid_layout.h"
|
||||
#include "layout/bracket_layout.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -66,13 +66,13 @@ Evaluation * Evaluation::createDeterminant() const {
|
||||
/* Search for pivot */
|
||||
int rowWithPivot = i;
|
||||
for (int row = i+1; row < dim; row++) {
|
||||
if (fabsf(tempMat[rowWithPivot][i]) < fabsf(tempMat[row][i])) {
|
||||
if (std::fabs(tempMat[rowWithPivot][i]) < std::fabs(tempMat[row][i])) {
|
||||
rowWithPivot = row;
|
||||
}
|
||||
}
|
||||
float valuePivot = tempMat[rowWithPivot][i];
|
||||
/* if the pivot is null, det = 0. */
|
||||
if (fabsf(valuePivot) <= FLT_EPSILON) {
|
||||
if (std::fabs(valuePivot) <= FLT_EPSILON) {
|
||||
for (int i = 0; i < dim; i++) {
|
||||
free(tempMat[i]);
|
||||
}
|
||||
@@ -128,13 +128,13 @@ Evaluation * Evaluation::createInverse() const {
|
||||
/* Search for pivot */
|
||||
int rowWithPivot = i;
|
||||
for (int row = i+1; row < dim; row++) {
|
||||
if (fabsf(inv[rowWithPivot][i]) < fabsf(inv[row][i])) {
|
||||
if (std::fabs(inv[rowWithPivot][i]) < std::fabs(inv[row][i])) {
|
||||
rowWithPivot = row;
|
||||
}
|
||||
}
|
||||
float valuePivot = inv[rowWithPivot][i];
|
||||
/* if the pivot is null, the matrix in not invertible. */
|
||||
if (fabsf(valuePivot) <= FLT_EPSILON) {
|
||||
if (std::fabs(valuePivot) <= FLT_EPSILON) {
|
||||
for (int i = 0; i < dim; i++) {
|
||||
free(inv[i]);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <poincare/list_data.h>
|
||||
#include <poincare/matrix_data.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <cmath>
|
||||
#include "expression_parser.hpp"
|
||||
#include "expression_lexer.hpp"
|
||||
extern "C" {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
* which is not installed by default on MacOS, we thus made the choice to prefer
|
||||
* compatibility with MacOS's default version (2.3) instead of using the code
|
||||
* requires feature. */
|
||||
#include <math.h>
|
||||
#include <poincare.h>
|
||||
#include "expression_parser.hpp"
|
||||
using namespace Poincare;
|
||||
|
||||
@@ -5,7 +5,7 @@ extern "C" {
|
||||
#include <poincare/expression_matrix.h>
|
||||
#include <poincare/complex_matrix.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "layout/horizontal_layout.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -38,7 +38,7 @@ Complex Factorial::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
return Complex::Float(result);
|
||||
}
|
||||
}
|
||||
return Complex::Float(roundf(result));
|
||||
return Complex::Float(std::round(result));
|
||||
}
|
||||
|
||||
ExpressionLayout * Factorial::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex Floor::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(floorf(c.a()));
|
||||
return Complex::Float(std::floor(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Complex FracPart::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(c.a()-floorf(c.a()));
|
||||
return Complex::Float(c.a()-std::floor(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
#include <cmath>
|
||||
#include <poincare/function.h>
|
||||
#include <poincare/complex.h>
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <poincare/global_context.h>
|
||||
#include <poincare/matrix.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <ion.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -47,7 +47,7 @@ Evaluation * GreatCommonDivisor::privateEvaluate(Context & context, AngleUnit an
|
||||
a = b;
|
||||
b = r;
|
||||
}
|
||||
return new Complex(Complex::Float(roundf((float)a)));
|
||||
return new Complex(Complex::Float(std::round((float)a)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/hyperbolic_arc_cosine.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -27,7 +27,7 @@ Complex HyperbolicArcCosine::computeComplex(const Complex c, AngleUnit angleUnit
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(acoshf(c.a()));
|
||||
return Complex::Float(std::acosh(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/hyperbolic_arc_sine.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -27,7 +27,7 @@ Complex HyperbolicArcSine::computeComplex(const Complex c, AngleUnit angleUnit)
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(asinhf(c.a()));
|
||||
return Complex::Float(std::asinh(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/hyperbolic_arc_tangent.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -27,7 +27,7 @@ Complex HyperbolicArcTangent::computeComplex(const Complex c, AngleUnit angleUni
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(atanhf(c.a()));
|
||||
return Complex::Float(std::atanh(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <poincare/opposite.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -30,7 +30,7 @@ Expression * HyperbolicCosine::cloneWithDifferentOperands(Expression** newOperan
|
||||
|
||||
Complex HyperbolicCosine::compute(const Complex c) {
|
||||
if (c.b() == 0.0f) {
|
||||
return Complex::Float(coshf(c.a()));
|
||||
return Complex::Float(std::cosh(c.a()));
|
||||
}
|
||||
Complex e = Complex::Float(M_E);
|
||||
Complex exp1 = Power::compute(e, c);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <poincare/opposite.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -30,7 +30,7 @@ Expression * HyperbolicSine::cloneWithDifferentOperands(Expression** newOperands
|
||||
|
||||
Complex HyperbolicSine::compute(const Complex c) {
|
||||
if (c.b() == 0.0f) {
|
||||
return Complex::Float(sinhf(c.a()));
|
||||
return Complex::Float(std::sinh(c.a()));
|
||||
}
|
||||
Complex e = Complex::Float(M_E);
|
||||
Complex exp1 = Power::compute(e, c);
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <poincare/fraction.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -28,7 +28,7 @@ Expression * HyperbolicTangent::cloneWithDifferentOperands(Expression** newOpera
|
||||
|
||||
Complex HyperbolicTangent::compute(const Complex c) {
|
||||
if (c.b() == 0.0f) {
|
||||
return Complex::Float(tanhf(c.a()));
|
||||
return Complex::Float(std::tanh(c.a()));
|
||||
}
|
||||
Complex arg1 = HyperbolicSine::compute(c);
|
||||
Complex arg2 = HyperbolicCosine::compute(c);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <poincare/imaginary_part.h>
|
||||
#include <poincare/complex.h>
|
||||
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include <poincare/integer.h>
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <poincare/complex.h>
|
||||
#include "layout/string_layout.h"
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/context.h>
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
@@ -111,12 +111,12 @@ Integral::DetailedResult Integral::kronrodGaussQuadrature(float a, float b, Vari
|
||||
|
||||
float centr = 0.5f*(a+b);
|
||||
float hlgth = 0.5f*(b-a);
|
||||
float dhlgth = fabsf(hlgth);
|
||||
float dhlgth = std::fabs(hlgth);
|
||||
|
||||
float resg =0.0f;
|
||||
float fc = functionValueAtAbscissa(centr, xContext, angleUnit);
|
||||
float resk = wgk[10]*fc;
|
||||
float resabs = fabsf(resk);
|
||||
float resabs = std::fabs(resk);
|
||||
for (int j = 0; j < 5; j++) {
|
||||
int jtw = 2*j+1;
|
||||
float absc = hlgth*xgk[jtw];
|
||||
@@ -127,7 +127,7 @@ Integral::DetailedResult Integral::kronrodGaussQuadrature(float a, float b, Vari
|
||||
float fsum = fval1+fval2;
|
||||
resg += wg[j]*fsum;
|
||||
resk += wgk[jtw]*fsum;
|
||||
resabs += wgk[jtw]*(fabsf(fval1)+fabsf(fval2));
|
||||
resabs += wgk[jtw]*(std::fabs(fval1)+std::fabs(fval2));
|
||||
}
|
||||
for (int j = 0; j < 5; j++) {
|
||||
int jtwm1 = 2*j;
|
||||
@@ -138,19 +138,19 @@ Integral::DetailedResult Integral::kronrodGaussQuadrature(float a, float b, Vari
|
||||
fv2[jtwm1] = fval2;
|
||||
float fsum = fval1+fval2;
|
||||
resk += wgk[jtwm1]*fsum;
|
||||
resabs += wgk[jtwm1]*(fabsf(fval1)+fabsf(fval2));
|
||||
resabs += wgk[jtwm1]*(std::fabs(fval1)+std::fabs(fval2));
|
||||
}
|
||||
float reskh = resk*0.5f;
|
||||
float resasc = wgk[10]*fabsf(fc-reskh);
|
||||
float resasc = wgk[10]*std::fabs(fc-reskh);
|
||||
for (int j = 0; j < 10; j++) {
|
||||
resasc += wgk[j]*(fabsf(fv1[j]-reskh)+fabsf(fv2[j]-reskh));
|
||||
resasc += wgk[j]*(std::fabs(fv1[j]-reskh)+std::fabs(fv2[j]-reskh));
|
||||
}
|
||||
float integral = resk*hlgth;
|
||||
resabs = resabs*dhlgth;
|
||||
resasc = resasc*dhlgth;
|
||||
float abserr = fabsf((resk-resg)*hlgth);
|
||||
float abserr = std::fabs((resk-resg)*hlgth);
|
||||
if (resasc != 0.0f && abserr != 0.0f) {
|
||||
abserr = 1.0f > powf(200.0f*abserr/resasc, 1.5f)? resasc*powf(200.0f*abserr/resasc, 1.5f) : resasc;
|
||||
abserr = 1.0f > std::pow(200.0f*abserr/resasc, 1.5f)? resasc*std::pow(200.0f*abserr/resasc, 1.5f) : resasc;
|
||||
}
|
||||
if (resabs > FLT_MAX/(50.0f*FLT_EPSILON)) {
|
||||
abserr = abserr > FLT_EPSILON*50.0f*resabs ? abserr : FLT_EPSILON*50.0f*resabs;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -48,7 +48,7 @@ Evaluation * LeastCommonMultiple::privateEvaluate(Context & context, AngleUnit a
|
||||
a = b;
|
||||
b = r;
|
||||
}
|
||||
return new Complex(Complex::Float(roundf((float)(product/a))));
|
||||
return new Complex(Complex::Float(std::round((float)(product/a))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <poincare/logarithm.h>
|
||||
#include <poincare/fraction.h>
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
#include "layout/baseline_relative_layout.h"
|
||||
@@ -45,7 +45,7 @@ Complex Logarithm::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(log10f(c.a()));
|
||||
return Complex::Float(std::log10(c.a()));
|
||||
}
|
||||
|
||||
Evaluation * Logarithm::privateEvaluate(Context & context, AngleUnit angleUnit) const {
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#include <poincare/complex.h>
|
||||
#include "layout/grid_layout.h"
|
||||
#include "layout/bracket_layout.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <poincare/matrix.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <poincare/fraction.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <poincare/matrix.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <poincare/fraction.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
#include <poincare/multiplication.h>
|
||||
#include "layout/string_layout.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <poincare/naperian_logarithm.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
#include <cmath>
|
||||
#include "layout/horizontal_layout.h"
|
||||
#include "layout/parenthesis_layout.h"
|
||||
#include "layout/string_layout.h"
|
||||
@@ -31,7 +31,7 @@ Complex NaperianLogarithm::computeComplex(const Complex c, AngleUnit angleUnit)
|
||||
if (c.b() != 0.0f) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
return Complex::Float(logf(c.a()));
|
||||
return Complex::Float(std::log(c.a()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -48,7 +48,7 @@ Evaluation * NthRoot::privateEvaluate(Context& context, AngleUnit angleUnit) con
|
||||
|
||||
Complex NthRoot::compute(const Complex c, const Complex d) const {
|
||||
if (c.b() == 0.0f && d.b() == 0.0f) {
|
||||
return Complex::Float(powf(c.a(), 1.0f/d.a()));
|
||||
return Complex::Float(std::pow(c.a(), 1.0f/d.a()));
|
||||
}
|
||||
Complex invIndex = Fraction::compute(Complex::Float(1.0f), d);
|
||||
return Power::compute(c, invIndex);
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
#include "layout/horizontal_layout.h"
|
||||
#include "layout/parenthesis_layout.h"
|
||||
#include "layout/string_layout.h"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -43,7 +43,7 @@ Evaluation * PermuteCoefficient::privateEvaluate(Context& context, AngleUnit ang
|
||||
for (int i = (int)n-(int)k+1; i <= (int)n; i++) {
|
||||
result *= i;
|
||||
}
|
||||
return new Complex(Complex::Float(roundf(result)));
|
||||
return new Complex(Complex::Float(std::round(result)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
#include <poincare/power.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/opposite.h>
|
||||
@@ -38,13 +38,13 @@ Complex Power::compute(const Complex c, const Complex d) {
|
||||
return Complex::Float(NAN);
|
||||
}
|
||||
/* Second case only d is complex */
|
||||
float radius = powf(c.a(), d.a());
|
||||
float theta = d.b()*logf(c.a());
|
||||
float radius = std::pow(c.a(), d.a());
|
||||
float theta = d.b()*std::log(c.a());
|
||||
return Complex::Polar(radius, theta);
|
||||
}
|
||||
/* Third case only c is complex */
|
||||
float radius = powf(c.r(), d.a());
|
||||
if (c.b() == 0 && d.a() == roundf(d.a())) {
|
||||
float radius = std::pow(c.r(), d.a());
|
||||
if (c.b() == 0 && d.a() == std::round(d.a())) {
|
||||
/* We handle the case "c float and d integer" separatly to avoid getting
|
||||
* complex result due to float representation: a float power an integer is
|
||||
* always real. */
|
||||
@@ -66,7 +66,7 @@ Evaluation * Power::computeOnComplexMatrixAndComplex(Evaluation * m, const Compl
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
float power = c->toFloat();
|
||||
if (isnan(power) || isinf(power) || power != (int)power || fabsf(power) > k_maxNumberOfSteps) {
|
||||
if (isnan(power) || isinf(power) || power != (int)power || std::fabs(power) > k_maxNumberOfSteps) {
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
if (power < 0.0f) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <poincare/matrix.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -35,8 +35,8 @@ Evaluation * PredictionInterval::privateEvaluate(Context& context, AngleUnit ang
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
Complex operands[2];
|
||||
operands[0] = Complex::Float(p - 1.96f*sqrtf(p*(1.0f-p))/sqrtf(n));
|
||||
operands[1] = Complex::Float(p + 1.96f*sqrtf(p*(1.0f-p))/sqrtf(n));
|
||||
operands[0] = Complex::Float(p - 1.96f*std::sqrt(p*(1.0f-p))/std::sqrt(n));
|
||||
operands[1] = Complex::Float(p + 1.96f*std::sqrt(p*(1.0f-p))/std::sqrt(n));
|
||||
return new ComplexMatrix(operands, 2, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -34,8 +34,8 @@ Evaluation * Round::privateEvaluate(Context & context, AngleUnit angleUnit) cons
|
||||
if (isnan(f2) || f2 != (int)f2) {
|
||||
return new Complex(Complex::Float(NAN));
|
||||
}
|
||||
float err = powf(10.0f, (int)f2);
|
||||
return new Complex(Complex::Float(roundf(f1*err)/err));
|
||||
float err = std::pow(10.0f, (int)f2);
|
||||
return new Complex(Complex::Float(std::round(f1*err)/err));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include "layout/horizontal_layout.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <poincare/multiplication.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -33,7 +33,7 @@ Complex Sine::compute(const Complex c) {
|
||||
}
|
||||
|
||||
float Sine::computeForRadianReal(float x) const {
|
||||
return sinf(x);
|
||||
return std::sin(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "layout/nth_root_layout.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -34,7 +34,7 @@ ExpressionLayout * SquareRoot::privateCreateLayout(FloatDisplayMode floatDisplay
|
||||
|
||||
Complex SquareRoot::computeComplex(const Complex c, AngleUnit angleUnit) const {
|
||||
if (c.b() == 0.0f) {
|
||||
return Complex::Float(sqrtf(c.a()));
|
||||
return Complex::Float(std::sqrt(c.a()));
|
||||
}
|
||||
return Power::compute(c, Complex::Float(0.5f));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
}
|
||||
#include <poincare/store.h>
|
||||
#include <ion.h>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user