Commit c9fcbd64 authored by Stefan Gerlach's avatar Stefan Gerlach

C header and isnan fixes

parent 8f8714d5
......@@ -28,7 +28,7 @@
***************************************************************************/
#include "StatisticsFilter.h"
#include "core/AbstractColumn.h"
#include <math.h>
#include <cmath>
class StatisticsColumn : public AbstractColumn {
public:
......@@ -148,7 +148,7 @@ void StatisticsFilter::inputDataChanged(int port)
// iterate over all rows, determining first_valid_row, last_valid_row, N, min, max and sum
for (int row = 0; row <= column->rowCount(); row++) {
double val = m_inputs.at(port)->valueAt(row);
if (isnan(val)) continue;
if (std::isnan(val)) continue;
if (s->first_valid_row == -1) s->first_valid_row = row;
s->last_valid_row = row;
s->N++;
......@@ -167,7 +167,7 @@ void StatisticsFilter::inputDataChanged(int port)
s->variance = 0;
for (int row = 0; row <= column->rowCount(); row++) {
double val = column->valueAt(row);
if (isnan(val)) continue;
if (std::isnan(val)) continue;
s->variance += pow(val - mean, 2);
}
s->variance /= double(s->N);
......
......@@ -38,10 +38,10 @@
#include <QtCore/QDateTime>
#include <QtCore/QDate>
#include <QtCore/QTime>
#include <math.h>
#include <QMetaType>
#include <QDebug>
#include <KLocale>
#include <cmath>
/**
* \class AbstractColumn
......@@ -213,7 +213,7 @@ void AbstractColumn::clear() {}
bool AbstractColumn::isValid(int row) const {
switch (columnMode()) {
case AbstractColumn::Numeric:
return !isnan(valueAt(row));
return !std::isnan(valueAt(row));
case AbstractColumn::Text:
return !textAt(row).isNull();
case AbstractColumn::DateTime:
......@@ -466,7 +466,7 @@ double AbstractColumn::minimum() const{
double min = INFINITY;
for (int row = 0; row < rowCount(); row++) {
val = valueAt(row);
if (isnan(val))
if (std::isnan(val))
continue;
if (val < min)
......@@ -480,7 +480,7 @@ double AbstractColumn::maximum() const{
double max = -INFINITY;
for (int row = 0; row < rowCount(); row++) {
val = valueAt(row);
if (isnan(val))
if (std::isnan(val))
continue;
if (val > max)
......
......@@ -31,7 +31,7 @@
#define ABSTRACTCOLUMN_H
#include "backend/core/AbstractAspect.h"
#include <math.h>
#include <cmath>
class AbstractColumnPrivate;
class AbstractSimpleFilter;
......
......@@ -31,7 +31,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter QDateTime -> double (using Julian day).
class DateTime2DoubleFilter : public AbstractSimpleFilter
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDate>
#include <math.h>
#include <cmath>
//! Conversion filter QDateTime -> double, translating dates into days of the week (Monday -> 1).
class DayOfWeek2DoubleFilter : public AbstractSimpleFilter
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter double -> QDateTime, interpreting the input numbers as (fractional) Julian days.
class Double2DateTimeFilter : public AbstractSimpleFilter
......@@ -43,13 +43,13 @@ class Double2DateTimeFilter : public AbstractSimpleFilter
virtual QDate dateAt(int row) const {
if (!m_inputs.value(0)) return QDate();
double inputValue = m_inputs.value(0)->valueAt(row);
if (isnan(inputValue)) return QDate();
if (std::isnan(inputValue)) return QDate();
return QDate::fromJulianDay(qRound(inputValue));
}
virtual QTime timeAt(int row) const {
if (!m_inputs.value(0)) return QTime();
double inputValue = m_inputs.value(0)->valueAt(row);
if (isnan(inputValue)) return QTime();
if (std::isnan(inputValue)) return QTime();
// we only want the digits behind the dot and
// convert them from fraction of day to milliseconds
return QTime(12,0,0,0).addMSecs(int( (inputValue - int(inputValue)) * 86400000.0 ));
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter double -> QDateTime, interpreting the input numbers as days of the week (1 = Monday).
class Double2DayOfWeekFilter : public AbstractSimpleFilter
......@@ -42,7 +42,7 @@ class Double2DayOfWeekFilter : public AbstractSimpleFilter
virtual QDate dateAt(int row) const {
if (!m_inputs.value(0)) return QDate();
double inputValue = m_inputs.value(0)->valueAt(row);
if (isnan(inputValue)) return QDate();
if (std::isnan(inputValue)) return QDate();
// Don't use Julian days here since support for years < 1 is bad
// Use 1900-01-01 instead (a Monday)
return QDate(1900,1,1).addDays(qRound(inputValue - 1.0));
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter double -> QDateTime, interpreting the input numbers as months of the year.
class Double2MonthFilter : public AbstractSimpleFilter
......@@ -48,7 +48,7 @@ class Double2MonthFilter : public AbstractSimpleFilter
virtual QDateTime dateTimeAt(int row) const {
if (!m_inputs.value(0)) return QDateTime();
double inputValue = m_inputs.value(0)->valueAt(row);
if (isnan(inputValue)) return QDateTime();
if (std::isnan(inputValue)) return QDateTime();
// Don't use Julian days here since support for years < 1 is bad
// Use 1900-01-01 instead
QDate result_date = QDate(1900,1,1).addMonths(qRound(inputValue - 1.0));
......
......@@ -31,7 +31,7 @@
#include "../AbstractSimpleFilter.h"
#include <QLocale>
#include <math.h>
#include <cmath>
//! Locale-aware conversion filter double -> QString.
class Double2StringFilter : public AbstractSimpleFilter
......@@ -74,7 +74,7 @@ class Double2StringFilter : public AbstractSimpleFilter
if (!m_inputs.value(0)) return QString();
if (m_inputs.value(0)->rowCount() <= row) return QString();
double inputValue = m_inputs.value(0)->valueAt(row);
if (isnan(inputValue)) return QString();
if (std::isnan(inputValue)) return QString();
return QLocale().toString(inputValue, m_format, m_digits);
}
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDate>
#include <math.h>
#include <cmath>
/**
* \brief Conversion filter QDateTime -> double, translating dates into months (January -> 1).
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter String -> QDateTime, interpreting the input as days of the week (either numeric or "Mon" etc).
class String2DayOfWeekFilter : public AbstractSimpleFilter
......
......@@ -31,7 +31,7 @@
#include "../AbstractSimpleFilter.h"
#include <QLocale>
#include <math.h>
#include <cmath>
//! Locale-aware conversion filter QString -> double.
class String2DoubleFilter : public AbstractSimpleFilter
......
......@@ -32,7 +32,7 @@
#include "../AbstractSimpleFilter.h"
#include <QDateTime>
#include <math.h>
#include <cmath>
//! Conversion filter String -> QDateTime, interpreting the input as months of the year (either numeric or "Jan" etc).
class String2MonthFilter : public AbstractSimpleFilter
......
......@@ -26,10 +26,10 @@
***************************************************************************/
#include "ImageEditor.h"
#include "math.h"
#include <QThreadPool>
#include <QElapsedTimer>
#include <QMutex>
#include <cmath>
// #include <QDebug>
static const QRgb white = QColor(Qt::white).rgb();
......
......@@ -26,9 +26,7 @@
***************************************************************************/
#include "Transform.h"
#include "math.h"
#define PI 3.14159265
#include <cmath>
Transform::Transform() {
}
......@@ -56,8 +54,8 @@ bool Transform::mapTypeToCartesian(const DatapickerImage::ReferencePoints& axisP
for(int i=0; i<3; i++) {
if (axisPoints.logicalPos[i].x() < 0)
return false;
x[i] = axisPoints.logicalPos[i].x()*cos(axisPoints.logicalPos[i].y()*PI / 180.0);
y[i] = axisPoints.logicalPos[i].x()*sin(axisPoints.logicalPos[i].y()*PI / 180.0);
x[i] = axisPoints.logicalPos[i].x()*cos(axisPoints.logicalPos[i].y()*M_PI / 180.0);
y[i] = axisPoints.logicalPos[i].x()*sin(axisPoints.logicalPos[i].y()*M_PI / 180.0);
X[i] = axisPoints.scenePos[i].x();
Y[i] = axisPoints.scenePos[i].y();
}
......@@ -138,7 +136,7 @@ QVector3D Transform::mapCartesianToType(const QPointF& point, const DatapickerIm
return QVector3D(point.x(), exp(point.y()), 0);
} else if (axisPoints.type == DatapickerImage::PolarInDegree) {
double r = sqrt(point.x()*point.x() + point.y()*point.y());
double angle = atan(point.y()*180/(point.x()*PI));
double angle = atan(point.y()*180/(point.x()*M_PI));
return QVector3D(r, angle, 0);
} else if (axisPoints.type == DatapickerImage::PolarInRadians) {
double r = sqrt(point.x()*point.x() + point.y()*point.y());
......
......@@ -29,12 +29,11 @@ Copyright : (C) 2015 by Stefan Gerlach (stefan.gerlach@uni.kn)
#include "backend/datasources/FileDataSource.h"
#include "backend/core/column/Column.h"
#include <math.h>
#include <QDataStream>
#include <QDebug>
#include <KLocale>
#include <kfilterdev.h>
#include <cmath>
/*!
\class BinaryFilter
......
......@@ -29,13 +29,12 @@ Copyright : (C) 2015 by Stefan Gerlach (stefan.gerlach@uni.kn)
#include "backend/datasources/FileDataSource.h"
#include "backend/core/column/Column.h"
#include <math.h>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <KLocale>
#include <KIcon>
#include <cmath>
/*!
\class HDFFilter
......
......@@ -29,13 +29,13 @@ Copyright : (C) 2015 by Stefan Gerlach (stefan.gerlach@uni.kn)
#include "backend/datasources/FileDataSource.h"
#include "backend/core/column/Column.h"
#include <math.h>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <KLocale>
#include <cmath>
/*!
\class ImageFilter
\brief Manages the import/export of data from/to an image file.
......
......@@ -29,13 +29,12 @@ Copyright : (C) 2015 by Stefan Gerlach (stefan.gerlach@uni.kn)
#include "backend/datasources/FileDataSource.h"
#include "backend/core/column/Column.h"
#include <math.h>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <KLocale>
#include <KIcon>
#include <cmath>
/*!
\class NetCDFFilter
......
......@@ -3,8 +3,8 @@
Project : LabPlot
--------------------------------------------------------------------
Copyright : (C) 2014 Alexander Semke (alexander.semke@web.de)
(C) 2014 Stefan Gerlach (stefan.gerlach@uni.kn)
Description : c++ wrapper for the bison generated parser.
Copyright : (C) 2014 Stefan Gerlach (stefan.gerlach@uni.kn)
Description : C++ wrapper for the bison generated parser.
***************************************************************************/
......@@ -31,12 +31,14 @@
#include "backend/gsl/parser_extern.h"
#include "backend/gsl/parser_struct.h"
#include <klocale.h>
extern "C" {
#include <gsl/gsl_errno.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_const_mksa.h>
#include <gsl/gsl_const_num.h>
#include <klocale.h>
}
ExpressionParser* ExpressionParser::instance = NULL;
......
......@@ -3,8 +3,8 @@
Project : LabPlot
Description : definition of functions
--------------------------------------------------------------------
Copyright : (C) 2014 by Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2014 by Stefan Gerlach (stefan.gerlach@uni-konstanz.de)
Copyright : (C) 2014 by Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2014 by Stefan Gerlach (stefan.gerlach@uni.kn)
***************************************************************************/
......
......@@ -35,16 +35,16 @@
#include "backend/lib/commandtemplates.h"
#include "backend/lib/XmlStreamReader.h"
#include "kdefrontend/worksheet/ExportWorksheetDialog.h"
#include <math.h>
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include "KIcon"
#include <KIcon>
#include <KConfigGroup>
#include <KLocale>
#include <QDebug>
#include <cmath>
/**
* \class Worksheet
......
......@@ -51,9 +51,7 @@
#include <KLocale>
#include <cmath>
extern "C" {
#include <float.h>
}
#include <cfloat>
/**
* \class AxisGrid
......@@ -1221,7 +1219,7 @@ void AxisPrivate::retransformTicks() {
}
} else {
majorTickPos = majorTicksColumn->valueAt(iMajor);
if (isnan(majorTickPos))
if (std::isnan(majorTickPos))
break; //stop iterating after the first non numerical value in the column
}
......@@ -1276,7 +1274,7 @@ void AxisPrivate::retransformTicks() {
minorTickPos = majorTickPos + (iMinor+1)*minorTicksSpacing;
} else {
minorTickPos = minorTicksColumn->valueAt(iMinor);
if (isnan(minorTickPos))
if (std::isnan(minorTickPos))
break; //stop iterating after the first non numerical value in the column
//in the case a custom column is used for the minor ticks, we draw them _once_ for the whole range of the axis.
......
......@@ -558,7 +558,7 @@ QList<QLineF> CartesianCoordinateSystem::mapLogicalToScene(const QList<QLineF> &
if (flags & MarkGaps) {
if (!isnan(xGapBefore)) {
if (!std::isnan(xGapBefore)) {
if (clipResult.xClippedLeft[0]) {
QLineF gapMarker(QPointF(x1 + xGapBefore / 4, y1 - xGapBefore / 2),
QPointF(x1 - xGapBefore / 4, y1 + xGapBefore / 2));
......@@ -573,7 +573,7 @@ QList<QLineF> CartesianCoordinateSystem::mapLogicalToScene(const QList<QLineF> &
}
}
if (!isnan(xGapAfter)) {
if (!std::isnan(xGapAfter)) {
if (clipResult.xClippedRight[0]) {
QLineF gapMarker(QPointF(x1 + xGapAfter / 4, y1 - xGapAfter / 2),
QPointF(x1 - xGapAfter / 4, y1 + xGapAfter / 2));
......@@ -588,7 +588,7 @@ QList<QLineF> CartesianCoordinateSystem::mapLogicalToScene(const QList<QLineF> &
}
}
if (!isnan(yGapBefore)) {
if (!std::isnan(yGapBefore)) {
if (clipResult.yClippedTop[0]) {
QLineF gapMarker(QPointF(x1 + yGapBefore / 2, y1 - yGapBefore / 4),
QPointF(x1 - yGapBefore / 2, y1 + yGapBefore / 4));
......@@ -603,7 +603,7 @@ QList<QLineF> CartesianCoordinateSystem::mapLogicalToScene(const QList<QLineF> &
}
}
if (!isnan(yGapAfter)) {
if (!std::isnan(yGapAfter)) {
if (clipResult.yClippedBottom[0]) {
QLineF gapMarker(QPointF(x1 + yGapAfter / 2, y1 - yGapAfter / 4),
QPointF(x1 - yGapAfter / 2, y1 + yGapAfter / 4));
......
......@@ -1283,7 +1283,7 @@ void CartesianPlotPrivate::retransformScales() {
bool hasValidBreak = false;
if (xRangeBreakingEnabled && !xRangeBreaks.list.isEmpty()) {
foreach(const CartesianPlot::RangeBreak& b, xRangeBreaks.list)
hasValidBreak = (!isnan(b.start) && !isnan(b.end));
hasValidBreak = (!std::isnan(b.start) && !std::isnan(b.end));
}
//create x-scales
......@@ -1329,7 +1329,7 @@ void CartesianPlotPrivate::retransformScales() {
hasValidBreak = false;
if (yRangeBreakingEnabled && !yRangeBreaks.list.isEmpty()) {
foreach(const CartesianPlot::RangeBreak& b, yRangeBreaks.list)
hasValidBreak = (!isnan(b.start) && !isnan(b.end));
hasValidBreak = (!std::isnan(b.start) && !std::isnan(b.end));
}
//create y-scales
......
......@@ -219,7 +219,7 @@ void XYSmoothCurvePrivate::recalculate() {
QVector<double> ydataVector;
for (int row=0; row<xDataColumn->rowCount(); ++row) {
//only copy those data where _all_ values (for x and y, if given) are valid
if (!isnan(xDataColumn->valueAt(row)) && !isnan(yDataColumn->valueAt(row))
if (!std::isnan(xDataColumn->valueAt(row)) && !std::isnan(yDataColumn->valueAt(row))
&& !xDataColumn->isMasked(row) && !yDataColumn->isMasked(row)) {
xdataVector.append(xDataColumn->valueAt(row));
......
......@@ -59,8 +59,8 @@
#include <KAction>
#include <KIcon>
#include <float.h>
#include "math.h"
#include <cfloat>
#include <cmath>
MatrixView::MatrixView(Matrix* matrix) : QWidget(),
m_stackedWidget(new QStackedWidget(this)),
......
......@@ -178,7 +178,7 @@ void StatisticsDialog::setColumns(const QList<Column*>& columns) {
}
const QString StatisticsDialog::isNanValue(const double value) {
return (isnan(value) ? i18n("The value couldn't be calculated.") : QString::number(value,'g', 10));
return (std::isnan(value) ? i18n("The value couldn't be calculated.") : QString::number(value,'g', 10));
}
QSize StatisticsDialog::sizeHint() const {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment