Skip to content

Commit

Permalink
Corrected bugs
Browse files Browse the repository at this point in the history
- Regression polynomial had the wrong coefficients
- ZeGrapher wasn't parsing correctly x(1-x)
  • Loading branch information
AdelKS committed Mar 6, 2017
1 parent 7adb235 commit 06bf51e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
4 changes: 0 additions & 4 deletions Calculus/exprcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
**
****************************************************************************/





#include "Calculus/exprcalculator.h"

static double tenPower(double x)
Expand Down
4 changes: 0 additions & 4 deletions Calculus/exprcalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
**
****************************************************************************/





#ifndef EXPRCALCULATOR_H
#define EXPRCALCULATOR_H

Expand Down
8 changes: 3 additions & 5 deletions Calculus/polynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ double Polynomial::getXTranslation() const

void Polynomial::translateX(double Dx)
{
translation += -Dx;
translation -= Dx;

translatedCoefficients.clear();

Dx = -Dx;
translatedCoefficients.clear();

QList<double> DxPowTable;
DxPowTable.reserve(coefficients.size());
Expand All @@ -99,7 +97,7 @@ void Polynomial::translateX(double Dx)
{
translatedCoefficients << 0;
DxPowTable << DxPow;
DxPow *= Dx;
DxPow *= translation;
}

for(int n = 0 ; n < coefficients.size() ; n++)
Expand Down
2 changes: 1 addition & 1 deletion Calculus/polynomialregression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void PolynomialRegression::calculateRegressionPolynomials()

continuousPol.translateX(1);
continuousPol.expand(xamp/2);
continuousPol.translateX(xmin);
continuousPol.translateX(xmin);

continuousPol.translateY(1);
continuousPol *= yamp/2;
Expand Down
11 changes: 5 additions & 6 deletions Calculus/treecreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ void TreeCreator::insertMultiplySigns(QString &formula)
(formula[i].isLetter() && formula[i+1].isDigit()) ||
(formula[i].isDigit() && formula[i+1] == '(') ||
(formula[i] == ')' && formula[i+1] == '(') ||
(formula[i] == ')' && (formula[i+1].isDigit() || formula[i+1].isLetter())) ||
(i != 0 && !formula[i-1].isLetter() && vars.contains(QString(formula[i])) && formula[i+1] == '('))
(formula[i] == ')' && (formula[i+1].isDigit() || formula[i+1].isLetter())))
{
formula.insert(i+1, QString("*"));
i++;
Expand Down Expand Up @@ -228,8 +227,8 @@ bool TreeCreator::check(QString formula)
if(!ok)
return false;

openingParenthesis = varOrFunc = numberSign = false;
digit = ope = closingParenthesis = canEnd = true;
digit = openingParenthesis = varOrFunc = numberSign = false;
ope = closingParenthesis = canEnd = true;
}
else if(formula[i].isLetter() && varOrFunc)
{
Expand Down Expand Up @@ -280,8 +279,8 @@ bool TreeCreator::check(QString formula)

else if(constants.contains(name) || customVars.contains(name) || vars.contains(name))
{
varOrFunc = numberSign = false;
openingParenthesis = digit = ope = closingParenthesis = canEnd = true;
varOrFunc = numberSign = openingParenthesis = digit = false;
ope = closingParenthesis = canEnd = true;

if(customVars.contains(name)) /* customVars comes at first because of overriding policy, customvars come from dataplot, and user can redefine
n t or x or k */
Expand Down
4 changes: 2 additions & 2 deletions Structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#define STRUCTURES_H

#include <cmath>


#include <QtWidgets>

#define SOFTWARE_VERSION 3.01


#define FROM_CURRENT_GRAPHIC 0
#define MANUAL_ENTRY 1
Expand Down
2 changes: 1 addition & 1 deletion Widgets/pareqcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ParEqController::nextAnimationFrame()
{
bool update = false;

for(int i = 0; i < parEqs->size(); i++)
for(int i = 0 ; i < parEqs->size(); i++)
{
if(parEqs->at(i)->isAnimated() && parEqs->at(i)->isPlaying())
{
Expand Down
6 changes: 6 additions & 0 deletions Widgets/pareqwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ void ParEqWidget::setRatio(double r)
if(tWidget->isAnimateChecked() && valid)
{
if(2*trunc(tRange.step * ratio) > trunc(tRange.end - tRange.start))
{
blockAnimation = true;
parCurrentValLineEdit->setText(tr("Increment period too small for the animation to be seen."));
}
else
{
blockAnimation = false;
Expand All @@ -101,7 +104,10 @@ void ParEqWidget::setRatio(double r)
else if(kWidget->isAnimateChecked() && valid)
{
if(2*trunc(kRange.step * ratio) > trunc(kRange.end - kRange.start))
{
blockAnimation = true;
parCurrentValLineEdit->setText(tr("Increment period too small for the animation to be seen."));
}
else
{
blockAnimation = false;
Expand Down
2 changes: 1 addition & 1 deletion Windows/updatecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void UpdateCheck::downloadFinished(QNetworkReply *reply)
}
else
{
if(latestVersion > 3.0)
if(latestVersion > SOFTWARE_VERSION)
{
statusLabel->setTextFormat(Qt::RichText);
statusLabel->setText(tr("A new version is available!<br/><br/>To download it, visit <a href=http://zegrapher.com>zegrapher.com</a>"));
Expand Down
2 changes: 2 additions & 0 deletions Windows/updatecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <QNetworkRequest>
#include <QNetworkReply>

#include <Structures.h>


class UpdateCheck : public QDialog
{
Expand Down

0 comments on commit 06bf51e

Please sign in to comment.