[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Tue Nov 18 17:50:06 CET 2008
SVN commit 886151 by fenton:
Add remaining windows build fixes for plugins.
M +14 -0 libkst/math_kst.h
M +4 -2 plugins/dataobject/linefit/linefit.cpp
M +3 -3 plugins/dataobject/shift/shift.cpp
--- branches/work/kst/portto4/kst/src/libkst/math_kst.h #886150:886151
@@ -141,7 +141,21 @@
}
}
+#ifdef Q_WS_WIN32
+inline double roundDouble (double x) {
+ int i = (int) x;
+ if (x >= 0.0) {
+ return ((x-i) >= 0.5) ? (i + 1) : (i);
+ } else {
+ return (-x+i >= 0.5) ? (i - 1) : (i);
+ }
}
+#else
+inline double roundDouble(double x) {
+ return rint(x);
+}
#endif
+}
+#endif
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/plugins/dataobject/linefit/linefit.cpp #886150:886151
@@ -14,6 +14,8 @@
#include "objectstore.h"
#include "ui_linefitconfig.h"
+#include "math_kst.h"
+
static const QString& VECTOR_IN_X = "Vector In X";
static const QString& VECTOR_IN_Y = "Vector In Y";
static const QString& VECTOR_OUT_X = "X Interpolated";
@@ -181,7 +183,7 @@
for (i = 0; i < inputVectorY->length(); i++) {
double z = xScale*i;
- long int idx = long(rint(z));
+ long int idx = long(Kst::roundDouble(z));
double skew = z - floor(z); /* [0..1] */
long int idx2 = idx + 1;
sy += inputVectorY->value()[i];
@@ -211,7 +213,7 @@
for (i = 0; i < inputVectorX->length(); i++) {
double z = xScale*i;
- long int idx = long(rint(z));
+ long int idx = long(Kst::roundDouble(z));
double skew = z - floor(z); /* [0..1] */
long int idx2 = idx + 1;
double newX;
--- branches/work/kst/portto4/kst/src/plugins/dataobject/shift/shift.cpp #886150:886151
@@ -13,6 +13,7 @@
#include "shift.h"
#include "objectstore.h"
#include "ui_shiftconfig.h"
+#include "math_kst.h"
static const QString& VECTOR_IN = "Vector In";
static const QString& SCALAR_IN = "Shift value (# points, negative allowed)";
@@ -136,7 +137,6 @@
Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
int delay = 0;
- const double nan = 0.0 / 0.0;
/* Memory allocation */
outputVector->resize(inputVector->length(), false);
@@ -153,7 +153,7 @@
if (delay >= 0) {
/* Pad beginning with zeros */
for (int i = 0; i < delay; i++) {
- outputVector->value()[i] = nan;
+ outputVector->value()[i] = NAN;
}
/* Then, copy values with the right offset */
for (int i = delay; i < inputVector->length(); i++) {
@@ -170,7 +170,7 @@
}
/* Pad end with zeros */
for (int i = inputVector->length()-delay; i < inputVector->length(); i++) {
- outputVector->value()[i] = nan;
+ outputVector->value()[i] = NAN;
}
}
return true;
More information about the Kst
mailing list