16 changes: 8 additions & 8 deletions src/libkst/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool Vector::resize(int sz, bool init) {
return false;
}
if (init && _size < sz) {
for (int i = _size; i < sz; i++) {
for (int i = _size; i < sz; ++i) {
_v[i] = NOPOINT;
}
}
Expand All @@ -394,7 +394,7 @@ void Vector::internalUpdate() {
_is_rising = true;

// Look for a valid (finite) point...
for (i = 0; i < _size && !isfinite(_v[i]); i++) {
for (i = 0; i < _size && !isfinite(_v[i]); ++i) {
// do nothing
}

Expand Down Expand Up @@ -432,7 +432,7 @@ void Vector::internalUpdate() {

last_v = _v[i0];

for (i = i0; i < _size; i++) {
for (i = i0; i < _size; ++i) {
v = _v[i]; // get rid of redirections

if (isfinite(v)) {
Expand Down Expand Up @@ -471,7 +471,7 @@ void Vector::internalUpdate() {
last = _v[_size-1];
first = _v[0];

for (i = i0; i < _size; i++) {
for (i = i0; i < _size; ++i) {
v = _v[i]; // get rid of redirections
if (isfinite(v)) {
if (fabs(v - last_v) < no_spike_max_dv) {
Expand Down Expand Up @@ -517,7 +517,7 @@ void Vector::save(QXmlStreamWriter &s) {
QByteArray qba(length()*sizeof(double), '\0');
QDataStream qds(&qba, QIODevice::WriteOnly);

for (int i = 0; i < length(); i++) {
for (int i = 0; i < length(); ++i) {
qds << _v[i];
}

Expand Down Expand Up @@ -654,12 +654,12 @@ ObjectList<Primitive> Vector::outputPrimitives() const {
PrimitiveList primitive_list;

int n = _scalars.count();
for (int i = 0; i< n; i++) {
for (int i = 0; i< n; ++i) {
primitive_list.append(kst_cast<Primitive>(_scalars.values().at(i)));
}

n = _strings.count();
for (int i = 0; i< n; i++) {
for (int i = 0; i< n; ++i) {
primitive_list.append(kst_cast<Primitive>(_strings.values().at(i)));
}

Expand Down Expand Up @@ -768,7 +768,7 @@ QByteArray Vector::getBinaryArray() const {
QByteArray ret;
QDataStream ds(&ret,QIODevice::WriteOnly);
ds<<(qint64)_size;
for(int i=0;i<_size;i++) {
for(int i=0; i<_size; ++i) {
ds<<(double)_v[i];
}
unlock();
Expand Down
6 changes: 3 additions & 3 deletions src/libkstapp/stringscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ QByteArrayList StringGenSI::commands() {
}

QString StringGenSI::doCommand(QString x) {
if(x.startsWith("setName(")) {
if(x.startsWith(QLatin1String("setName("))) {
str->writeLock();
str->setDescriptiveName(x.remove("setName(").remove(')'));
str->unlock();
return "Done";
} else if(x.startsWith("setValue(")) {
} else if(x.startsWith(QLatin1String("setValue("))) {
str->writeLock();
str->setValue(x.remove("setValue(").remove(')'));
str->unlock();
return "Done";
} else if(x.startsWith("uncheckAuto()")) {
} else if(x.startsWith(QLatin1String("uncheckAuto()"))) {
str->writeLock();
str->setDescriptiveName("");
str->unlock();
Expand Down
12 changes: 6 additions & 6 deletions src/libkstmath/curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ int Curve::getIndexNearXY(double x, double dx_per_pix, double y) const {
dx = fabs(x - xi);
dy = fabs(y - yi);

for (i = i0 + 1; i <= iN; i++) {
for (i = i0 + 1; i <= iN; ++i) {
xi = xv->interpolate(i, NS);
dxi = fabs(x - xi);
if (dxi < dx_per_pix) {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ qDebug() << "y not in bounds"
if (xv->isRising()) {
double oldX = 0.0;

for (i_pt = i0; i_pt <= iN; i_pt++) {
for (i_pt = i0; i_pt <= iN; ++i_pt) {
rX = xv->interpolate(i_pt, NS);
if (i_pt > i0) {
if (rX - oldX < drX) {
Expand All @@ -1164,7 +1164,7 @@ qDebug() << "y not in bounds"
}
}

for (i_pt = i0; i_pt <= iN; i_pt++) {
for (i_pt = i0; i_pt <= iN; ++i_pt) {
visible = true;

if (exv) {
Expand Down Expand Up @@ -1294,7 +1294,7 @@ qDebug() << "y not in bounds"
}
}

for (i_pt = i0; i_pt <= iN; i_pt++) {
for (i_pt = i0; i_pt <= iN; ++i_pt) {
do_low_flag = true;
do_high_flag = true;

Expand Down Expand Up @@ -1384,7 +1384,7 @@ qDebug() << "y not in bounds"
}
}

for (i_pt = i0; i_pt <= iN; i_pt++) {
for (i_pt = i0; i_pt <= iN; ++i_pt) {
do_low_flag = true;
do_high_flag = true;

Expand Down Expand Up @@ -1509,7 +1509,7 @@ void Curve::yRange(double xFrom, double xTo, double* yMin, double* yMax) {
// search for min/max
bool first = true;
double newYMax = 0, newYMin = 0;
for (int i_pt = i0; i_pt <= iN; i_pt++) {
for (int i_pt = i0; i_pt <= iN; ++i_pt) {
double rX = xv->interpolate(i_pt, NS);
double rY = yv->interpolate(i_pt, NS);
// make sure this point is visible
Expand Down
64 changes: 32 additions & 32 deletions src/libkstmath/labelparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'a':
x = 0x20;
case 'A':
if (txt.mid(from + 1).startsWith("lpha")) {
if (txt.mid(from + 1).startsWith(QLatin1String("lpha"))) {
*skip = 5;
setNormalChar(QChar(0x391+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("pprox")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("pprox"))) {
*skip = 6;
setNormalChar(QChar(0x2248), tail);
return true;
Expand All @@ -223,11 +223,11 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'c':
x = 0x20;
case 'C':
if (txt.mid(from + 1).startsWith("hi")) {
if (txt.mid(from + 1).startsWith(QLatin1String("hi"))) {
*skip = 3;
setNormalChar(QChar(0x3a7+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("dot")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("dot"))) {
*skip = 4;
setNormalChar(QChar(0x2219), tail);
return true;
Expand All @@ -237,15 +237,15 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'e':
x = 0x20;
case 'E':
if (txt.mid(from + 1).startsWith("psilon")) {
if (txt.mid(from + 1).startsWith(QLatin1String("psilon"))) {
*skip = 7;
setNormalChar(QChar(0x395+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("ta")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("ta"))) {
*skip = 3;
setNormalChar(QChar(0x397+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("ll")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("ll"))) {
*skip = 3;
setNormalChar(QChar(0x2113), tail);
return true;
Expand All @@ -255,11 +255,11 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'g':
x = 0x20;
case 'G':
if (txt.mid(from + 1).startsWith("amma")) {
if (txt.mid(from + 1).startsWith(QLatin1String("amma"))) {
*skip = 5;
setNormalChar(QChar(0x393+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("eq")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("eq"))) {
*skip = 3;
setNormalChar(QChar(0x2265), tail);
return true;
Expand All @@ -273,15 +273,15 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'i':
x = 0x20;
case 'I':
if (txt.mid(from + 1).startsWith("ota")) {
if (txt.mid(from + 1).startsWith(QLatin1String("ota"))) {
*skip = 4;
setNormalChar(QChar(0x399+x), tail);
return true;
} else if (!upper && txt.mid(from + 1).startsWith("nf")) {
} else if (!upper && txt.mid(from + 1).startsWith(QLatin1String("nf"))) {
*skip = 3;
setNormalChar(QChar(0x221E), tail);
return true;
} else if (!upper && txt.mid(from + 1).startsWith("nt")) {
} else if (!upper && txt.mid(from + 1).startsWith(QLatin1String("nt"))) {
*skip = 3;
setNormalChar(QChar(0x222B), tail);
return true;
Expand All @@ -291,11 +291,11 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'l':
x = 0x20;
case 'L':
if (txt.mid(from + 1).startsWith("ambda")) {
if (txt.mid(from + 1).startsWith(QLatin1String("ambda"))) {
*skip = 6;
setNormalChar(QChar(0x39b+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("eq")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("eq"))) {
*skip = 3;
setNormalChar(QChar(0x2264), tail);
return true;
Expand Down Expand Up @@ -335,7 +335,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'o':
x = 0x20;
case 'O':
if (txt.mid(from + 1).startsWith("verline{")) {
if (txt.mid(from + 1).startsWith(QLatin1String("verline{"))) {
if ((*tail)->group) {
*tail = new Chunk(*tail, Chunk::None, false, true);
}
Expand All @@ -347,15 +347,15 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = parseStart - from + 1;
dumpattr(working, "end group for overline");
return true;
} else if (txt.mid(from + 1).startsWith("micron")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("micron"))) {
*skip = 7;
setNormalChar(QChar(0x39F+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("mega")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("mega"))) {
*skip = 5;
setNormalChar(QChar(0x3A9+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("dot")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("dot"))) {
*skip = 4;
setNormalChar(QChar(0x2299), tail);
return true;
Expand All @@ -369,19 +369,19 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = 2;
setNormalChar(QChar(0x3a0+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("hi")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("hi"))) {
*skip = 3;
setNormalChar(QChar(0x3A6+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("si")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("si"))) {
*skip = 3;
setNormalChar(QChar(0x3A8+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("artial")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("artial"))) {
*skip = 7;
setNormalChar(QChar(0x2202), tail);
return true;
} else if (txt.mid(from + 1).startsWith("rod")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("rod"))) {
*skip = 4;
setNormalChar(QChar(0x220F), tail);
return true;
Expand All @@ -395,7 +395,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 't':
x = 0x20;
case 'T':
if (txt.mid(from + 1).startsWith("extcolor{")) { // \textcolor{color}{text}
if (txt.mid(from + 1).startsWith(QLatin1String("extcolor{"))) { // \textcolor{color}{text}
if ((*tail)->group) {
*tail = new Chunk(*tail, Chunk::None, false, true);
}
Expand All @@ -412,7 +412,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = parseStart - from + 1;
dumpattr(working, "end group for textcolor");
return true;
} else if (txt.mid(from + 1).startsWith("extbf{")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("extbf{"))) {
if ((*tail)->group) {
*tail = new Chunk(*tail, Chunk::None, false, true);
}
Expand All @@ -424,7 +424,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = parseStart - from + 1;
dumpattr(working, "end group for textbf");
return true;
} else if (txt.mid(from + 1).startsWith("extit{")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("extit{"))) {
if ((*tail)->group) {
*tail = new Chunk(*tail, Chunk::None, false, true);
}
Expand All @@ -436,11 +436,11 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = parseStart - from + 1;
dumpattr(working, "end group for textit");
return true;
} else if (txt.mid(from + 1).startsWith("heta")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("heta"))) {
*skip = 5;
setNormalChar(QChar(0x398+x), tail);
return true;
} else if (txt.mid(from + 1).startsWith("au")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("au"))) {
*skip = 3;
setNormalChar(QChar(0x3A4+x), tail);
return true;
Expand All @@ -458,15 +458,15 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 's':
x = 0x20;
case 'S':
if (txt.mid(from + 1).startsWith("igma")) {
if (txt.mid(from + 1).startsWith(QLatin1String("igma"))) {
*skip = 5;
setNormalChar(QChar(0x3A3+x), tail);
return true;
} else if (!upper && txt.mid(from + 1).startsWith("um")) {
} else if (!upper && txt.mid(from + 1).startsWith(QLatin1String("um"))) {
*skip = 3;
setNormalChar(QChar(0x2211), tail);
return true;
} else if (!upper && txt.mid(from + 1).startsWith("qrt")) {
} else if (!upper && txt.mid(from + 1).startsWith(QLatin1String("qrt"))) {
*skip = 4;
setNormalChar(QChar(0x221A), tail);
return true;
Expand All @@ -476,7 +476,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
case 'u':
x = 0x20;
case 'U':
if (txt.mid(from + 1).startsWith("nderline{")) {
if (txt.mid(from + 1).startsWith(QLatin1String("nderline{"))) {
if ((*tail)->group) {
*tail = new Chunk(*tail, Chunk::None, false, true);
}
Expand All @@ -488,7 +488,7 @@ inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail,
*skip = parseStart - from + 1;
dumpattr(working, "end group for underline");
return true;
} else if (txt.mid(from + 1).startsWith("psilon")) {
} else if (txt.mid(from + 1).startsWith(QLatin1String("psilon"))) {
*skip = 7;
setNormalChar(QChar(0x3A5+x), tail);
return true;
Expand Down
36 changes: 19 additions & 17 deletions src/libkstmath/psdcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@ int PSDCalculator::calculatePowerSpectrum(
updateWindowFxn(apodizeFxn, gaussianSigma);
}

int currentCopyLen, nsamples = 0;
int i_samp, i_subset, ioffset;
int currentCopyLen;
int nsamples = 0;
int i_samp;
int ioffset;

memset(output, 0, sizeof(double)*outputLen); // initialize output.

// Mingw build could be 10 times slower (Gaussian apod, mostly 0 then?)
//MeasureTime time_in_rfdt("rdft()");

bool done = false;
for (i_subset = 0; !done; i_subset++) {
for (int i_subset = 0; !done; i_subset++) {
ioffset = i_subset*outputLen; //overlapping average => i_subset*outputLen

// only zero pad if we really have to. It is better to adjust the last chunk's
Expand All @@ -215,7 +217,7 @@ int PSDCalculator::calculatePowerSpectrum(
double mean = 0.0;

if (removeMean) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
mean += input[i_samp + ioffset];
}
mean /= (double)currentCopyLen;
Expand All @@ -224,35 +226,35 @@ int PSDCalculator::calculatePowerSpectrum(
// apply the PSD options (removeMean, apodize, etc.)
// separate cases for speed- although this shouldn't really matter- the rdft should be the most time consuming step by far for any large data set.
if (removeMean && apodize && interpolateHoles) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = (Kst::kstInterpolateNoHoles(input, inputLen, i_samp + ioffset, inputLen) - mean)*_w[i_samp];
}
} else if (removeMean && apodize) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = (input[i_samp + ioffset] - mean)*_w[i_samp];
}
} else if (removeMean && interpolateHoles) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = Kst::kstInterpolateNoHoles(input, inputLen, i_samp + ioffset, inputLen) - mean;
}
} else if (apodize && interpolateHoles) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = Kst::kstInterpolateNoHoles(input, inputLen, i_samp + ioffset, inputLen)*_w[i_samp];
}
} else if (removeMean) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = input[i_samp + ioffset] - mean;
}
} else if (apodize) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = input[i_samp + ioffset]*_w[i_samp];
}
} else if (interpolateHoles) {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = Kst::kstInterpolateNoHoles(input, inputLen, i_samp + ioffset, inputLen);
}
} else {
for (i_samp = 0; i_samp < currentCopyLen; i_samp++) {
for (i_samp = 0; i_samp < currentCopyLen; ++i_samp) {
_a[i_samp] = input[i_samp + ioffset];
}
}
Expand All @@ -267,7 +269,7 @@ int PSDCalculator::calculatePowerSpectrum(

output[0] += _a[0] * _a[0];
output[outputLen-1] += _a[1] * _a[1];
for (i_samp = 1; i_samp < outputLen - 1; i_samp++) {
for (i_samp = 1; i_samp < outputLen - 1; ++i_samp) {
output[i_samp] += cabs2(_a[i_samp * 2], _a[i_samp * 2 + 1]);
}
}
Expand All @@ -292,26 +294,26 @@ int PSDCalculator::calculatePowerSpectrum(
default:
case PSDAmplitudeSpectralDensity: // amplitude spectral density (default) [V/Hz^1/2]
norm /= frequencyStep;
for (i_samp = 0; i_samp < outputLen; i_samp++) {
for (i_samp = 0; i_samp < outputLen; ++i_samp) {
output[i_samp] = sqrt(output[i_samp]*norm);
}
break;

case PSDPowerSpectralDensity: // power spectral density [V^2/Hz]
norm /= frequencyStep;
for (i_samp = 0; i_samp < outputLen; i_samp++) {
for (i_samp = 0; i_samp < outputLen; ++i_samp) {
output[i_samp] *= norm;
}
break;

case PSDAmplitudeSpectrum: // amplitude spectrum [V]
for (i_samp = 0; i_samp < outputLen; i_samp++) {
for (i_samp = 0; i_samp < outputLen; ++i_samp) {
output[i_samp] = sqrt(output[i_samp]*norm);
}
break;

case PSDPowerSpectrum: // power spectrum [V^2]
for (i_samp = 0; i_samp < outputLen; i_samp++) {
for (i_samp = 0; i_samp < outputLen; ++i_samp) {
output[i_samp] *= norm;
}
break;
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/dataobject/crossspectrum/crossspectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool CrossSpectrumSource::algorithm() {

/* Fill the frequency and zero the xps */
df = SR/( 2.0*double( xps_len-1 ) );
for ( i=0; i<xps_len; i++ ) {
for ( i=0; i<xps_len; ++i ) {
outputVectorFrequency->value()[i] = double( i ) * df;
outputVectorReal->value()[i] = 0.0;
outputVectorImaginary->value()[i] = 0.0;
Expand All @@ -229,15 +229,15 @@ bool CrossSpectrumSource::algorithm() {
/* do the fft's */
n_subsets = v_len/xps_len + 1;

for ( i_subset=0; i_subset<n_subsets; i_subset++ ) {
for ( i_subset=0; i_subset<n_subsets; ++i_subset ) {
/* copy each chunk into a[] and find mean */
if (i_subset*xps_len + ALen <= v_len) {
copyLen = ALen;
} else {
copyLen = v_len - i_subset*xps_len;
}
mean_b = mean_a = 0;
for (i_samp = 0; i_samp < copyLen; i_samp++) {
for (i_samp = 0; i_samp < copyLen; ++i_samp) {
i = ( i_samp + i_subset*xps_len )/dv0;
mean_a += (
a[i_samp] = inputVectorOne->value()[i]
Expand All @@ -253,12 +253,12 @@ bool CrossSpectrumSource::algorithm() {
}

/* Remove Mean and apodize */
for (i_samp=0; i_samp<copyLen; i_samp++) {
for (i_samp=0; i_samp<copyLen; ++i_samp) {
a[i_samp] -= mean_a;
b[i_samp] -= mean_b;
}

for (;i_samp < ALen; i_samp++) {
for (;i_samp < ALen; ++i_samp) {
a[i_samp] = 0.0;
b[i_samp] = 0.0;
}
Expand All @@ -270,7 +270,7 @@ bool CrossSpectrumSource::algorithm() {
/* sum each bin into psd[] */
outputVectorReal->value()[0] += ( a[0]*b[0] );
outputVectorReal->value()[xps_len-1] += ( a[1]*b[1] );
for (i_samp=1; i_samp<xps_len-1; i_samp++) {
for (i_samp=1; i_samp<xps_len-1; ++i_samp) {
outputVectorReal->value()[i_samp]+= ( a[i_samp*2] * b[i_samp*2] -
a[i_samp*2+1] * b[i_samp*2+1] );
outputVectorImaginary->value()[i_samp]+= ( -a[i_samp*2] * b[i_samp*2+1] +
Expand All @@ -280,7 +280,7 @@ bool CrossSpectrumSource::algorithm() {

/* renormalize */
norm_factor = 1.0/((double(SR)*double(xps_len))*double(n_subsets));
for ( i=0; i<xps_len; i++ ) {
for ( i=0; i<xps_len; ++i ) {
outputVectorReal->value()[i]*=norm_factor;
outputVectorImaginary->value()[i]*=norm_factor;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/dataobject/linefit/linefit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ bool LineFitSource::algorithm() {

xScale = inputVectorX->length()/inputVectorY->length();

for (i = 0; i < inputVectorY->length(); i++) {
for (i = 0; i < inputVectorY->length(); ++i) {
double z = xScale*i;
long int idx = long(Kst::roundDouble(z));
double skew = z - floor(z); /* [0..1] */
Expand All @@ -198,7 +198,7 @@ bool LineFitSource::algorithm() {

sxoss = sx / inputVectorX->length();

for (i = 0; i < inputVectorX->length(); i++) {
for (i = 0; i < inputVectorX->length(); ++i) {
double t = inputVectorX->value()[i] - sxoss;
st2 += t * t;
b += t * inputVectorY->value()[i];
Expand All @@ -214,7 +214,7 @@ bool LineFitSource::algorithm() {
outputVectorY->value()[0] = a+b*outputVectorX->value()[0];
outputVectorY->value()[1] = a+b*outputVectorX->value()[1];

for (i = 0; i < inputVectorX->length(); i++) {
for (i = 0; i < inputVectorX->length(); ++i) {
double z = xScale*i;
long int idx = long(Kst::roundDouble(z));
double skew = z - floor(z); /* [0..1] */
Expand Down
24 changes: 12 additions & 12 deletions src/plugins/dataobject/periodogram/periodogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void PeriodogramSource::spread(double y, double yy[], unsigned long n, double x,
ihi = ilo + m - 1;
nden = nfac[m];
fac = x - ilo;
for (j = ilo + 1;j <= ihi;j++) {
for (j = ilo + 1;j <= ihi;++j) {
fac *= x - (double)j;
}
yy[ihi] += y*fac/(double)(nden*(x - ihi));
Expand Down Expand Up @@ -487,7 +487,7 @@ void PeriodogramSource::realft(double data[], unsigned long n, int isign) {
wr = 1.0 + wpr;
wi = wpi;
np3 = n+3;
for (i = 2;i <= (n>>2);i++) {
for (i = 2;i <= (n>>2);++i) {
i1 = (2*i) - 1;
i2 = i1 + 1;
i3 = np3 - i2;
Expand Down Expand Up @@ -532,13 +532,13 @@ void PeriodogramSource::avevar(
ep = 0.0;

if (n > 0) {
for (*ave = 0.0, j = 1;j <= n;j++) {
for (*ave = 0.0, j = 1;j <= n;++j) {
*ave += data[j];
}
*ave /= n;

if (n > 1) {
for (j = 1;j <= n;j++) {
for (j = 1;j <= n;++j) {
s = data[j] - (*ave);
ep += s;
*var += s*s;
Expand Down Expand Up @@ -599,7 +599,7 @@ void PeriodogramSource::FastLombPeriodogram(

xmax = x[1];
xmin = x[1];
for (j = 2;j <= n;j++) {
for (j = 2;j <= n;++j) {
if (x[j] < xmin) {
xmin = x[j];
}
Expand All @@ -608,15 +608,15 @@ void PeriodogramSource::FastLombPeriodogram(
}
}
xdif = xmax - xmin;
for (j = 1;j <= ndim;j++) {
for (j = 1;j <= ndim;++j) {
wk1[j] = 0.0;
wk2[j] = 0.0;
}

fac = ndim / (xdif * ofac);
fndim = ndim;

for (j = 1;j <= n;j++) {
for (j = 1;j <= n;++j) {
ck = (x[j] - xmin) * fac;
ck = fmod(ck, fndim);
ckk = 2.0*(ck++);
Expand Down Expand Up @@ -734,7 +734,7 @@ void PeriodogramSource::SlowLombPeriodogram(

xmax = x[1];
xmin = x[1];
for (j=1;j<=n;j++) {
for (j=1;j<=n;++j) {
if (x[j] > xmax) {
xmax = x[j];
}
Expand All @@ -746,19 +746,19 @@ void PeriodogramSource::SlowLombPeriodogram(
xave = 0.5*(xmax+xmin);
pymax = 0.0;
pnow = 1.0/(xdif*ofac);
for (j=1;j<=n;j++) {
for (j=1;j<=n;++j) {
arg = TWO_PI*((x[j]-xave)*pnow);
wpr[j] = -2.0*(sin(0.5*arg)*sin(0.5*arg));
wpi[j] = sin(arg);
wr[j] = cos(arg);
wi[j] = wpi[j];
}
for (i=1;i<=(*nout);i++) {
for (i=1;i<=(*nout);++i) {
sumsh = 0.0;
sumc = 0.0;
px[i] = pnow;

for (j=1;j<=n;j++) {
for (j=1;j<=n;++j) {
c = wr[j];
s = wi[j];
sumsh += s*c;
Expand All @@ -771,7 +771,7 @@ void PeriodogramSource::SlowLombPeriodogram(
sumc = 0.0;
sumsy = 0.0;
sumcy = 0.0;
for (j=1;j<=n;j++) {
for (j=1;j<=n;++j) {
s = wi[j];
c = wr[j];
ss = s*cwtau-c*swtau;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/filters/despike/filterdespike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool FilterDespikeSource::algorithm() {
}

/* get mean deviation of 3 pt difference */
for (i=dx; i<N-dx; i++) {
for (i=dx; i<N-dx; ++i) {
mdev += fabs(inputVector->value(i)-(inputVector->value(i-dx) + inputVector->value(i+dx))*0.5);
}
mdev /= double(N);
Expand All @@ -207,7 +207,7 @@ bool FilterDespikeSource::algorithm() {

// for first dx points, do a 2 point difference
last_good = inputVector->value(0);
for (i=0; i<dx; i++) {
for (i=0; i<dx; ++i) {
if (fabs(inputVector->value(i) - inputVector->value(i+dx))>cut) {
if (spike_start<0) {
spike_start = i-border;
Expand All @@ -230,7 +230,7 @@ bool FilterDespikeSource::algorithm() {
}
}
// do a 3 point difference where it is possible
for (i=dx; i<N-dx; i++) {
for (i=dx; i<N-dx; ++i) {
if (fabs(inputVector->value(i) - (inputVector->value(i-dx) + inputVector->value(i+dx))*0.5)>cut) {
if (spike_start<0) {
spike_start = i-border;
Expand All @@ -254,7 +254,7 @@ bool FilterDespikeSource::algorithm() {
}
}
// do a 2 point difference for last dx points
for (i=N-dx-1; i<N; i++) {
for (i=N-dx-1; i<N; ++i) {
if (fabs(inputVector->value(i-dx) - inputVector->value(i))>cut) {
if (spike_start<0) {
spike_start = i-border;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/filters/unwind/filterunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool FilterUnwindSource::algorithm() {
last_x_in = inputVector->value(0);
outputVector->value()[0] = last_x_in;

for (i=1; i<N; i++) {
for (i=1; i<N; ++i) {
x = inputVector->value(i);
if ((x>max) || (x<min)) { // invalid/spike... ignore.
x = last_x_in;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ bool FitGradientUnweightedSource::algorithm() {
if( precursor( inputVectorX, inputVectorY, 0, &iLength, false, true, 2, pInputs, outputVectorYFitted, outputVectorYResiduals, outputVectorYParameters, outputVectorYCovariance, outputVectorYLo, outputVectorYHi ) ) {

if( !gsl_fit_mul( pInputs[XVALUES], 1, pInputs[YVALUES], 1, iLength, &c0, &cov00, &dSumSq ) ) {
for( i=0; i<iLength; i++ ) {
for( i=0; i<iLength; ++i ) {
gsl_fit_mul_est( pInputs[XVALUES][i], c0, cov00, &y, &yErr );

outputVectorYFitted->value()[i] = y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool FitGradientWeightedSource::algorithm() {
if( precursor( inputVectorX, inputVectorY, inputVectorWeights, &iLength, true, true, 2, pInputs, outputVectorYFitted, outputVectorYResiduals, outputVectorYParameters, outputVectorYCovariance, outputVectorYLo, outputVectorYHi ) ) {

if( !gsl_fit_wmul( pInputs[XVALUES], 1, pInputs[WEIGHTS], 1, pInputs[YVALUES], 1, iLength, &c0, &cov00, &dSumSq ) ) {
for( i=0; i<iLength; i++ ) {
for( i=0; i<iLength; ++i ) {
gsl_fit_mul_est( pInputs[XVALUES][i], c0, cov00, &y, &yErr );

outputVectorYFitted->value()[i] = y;
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/fits/kneefrequency/fitkneefrequency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool FitKneeFrequencySource::algorithm() {
double sumY, sumY2;
sumY = sumY2 = 0;

for (i = minWhiteNoiseIndex; i < inArraysLength; i++) {
for (i = minWhiteNoiseIndex; i < inArraysLength; ++i) {
yi = inputVectorY->value()[i];
sumY += yi;
sumY2 += pow(yi,2);
Expand All @@ -289,7 +289,7 @@ bool FitKneeFrequencySource::algorithm() {
double sumLnXLnY, sumLnX, sumLnY, sumLnX2;
sumLnXLnY = sumLnX = sumLnY = sumLnX2 = 0;

for (i = 0; i < maxOneOverFIndex; i++) {
for (i = 0; i < maxOneOverFIndex; ++i) {
xi = inputVectorX->value()[i];
yi = inputVectorY->value()[i];

Expand All @@ -312,17 +312,17 @@ bool FitKneeFrequencySource::algorithm() {
double knee_freq = pow(ybar*whiteNoiseC/b,1.0/a); // calculate knee frequency.

// output fit data
for (i = 0; i < maxOneOverFIndex; i++) {
for (i = 0; i < maxOneOverFIndex; ++i) {
outputVectorYFitted->value()[i] = b * pow(inputVectorX->value()[i],a) + ybar;
outputVectorYResiduals->value()[i] = inputVectorY->value()[i] - outputVectorYFitted->value()[i];
}

for (i = maxOneOverFIndex; i < minWhiteNoiseIndex; i++) { // zeros for unfitted region.
for (i = maxOneOverFIndex; i < minWhiteNoiseIndex; ++i) { // zeros for unfitted region.
outputVectorYFitted->value()[i] = 0;
outputVectorYResiduals->value()[i] = 0;
}

for (i = minWhiteNoiseIndex; i < inArraysLength; i++) {
for (i = minWhiteNoiseIndex; i < inArraysLength; ++i) {
outputVectorYFitted->value()[i] = ybar;
outputVectorYResiduals->value()[i] = outputVectorYFitted->value()[i] - ybar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool FitLinearUnweightedSource::algorithm() {
if( precursor( inputVectorX, inputVectorY, 0, &iLength, false, true, 2, pInputs, outputVectorYFitted, outputVectorYResiduals, outputVectorYParameters, outputVectorYCovariance, outputVectorYLo, outputVectorYHi ) ) {

if( !gsl_fit_linear( pInputs[XVALUES], 1, pInputs[YVALUES], 1, iLength, &c0, &c1, &cov00, &cov01, &cov11, &dSumSq ) ) {
for( i=0; i<iLength; i++ ) {
for( i=0; i<iLength; ++i ) {
gsl_fit_linear_est( pInputs[XVALUES][i], c0, c1, cov00, cov01, cov11, &y, &yErr );
outputVectorYFitted->value()[i] = y;
outputVectorYResiduals->value()[i] = pInputs[YVALUES][i] - y;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/fits/linear_weighted/fitlinear_weighted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool FitLinearWeightedSource::algorithm() {
if( precursor( inputVectorX, inputVectorY, inputVectorWeights, &iLength, true, true, 2, pInputs, outputVectorYFitted, outputVectorYResiduals, outputVectorYParameters, outputVectorYCovariance, outputVectorYLo, outputVectorYHi ) ) {

if( !gsl_fit_wlinear( pInputs[XVALUES], 1, pInputs[WEIGHTS], 1, pInputs[YVALUES], 1, iLength, &c0, &c1, &cov00, &cov01, &cov11, &dSumSq ) ) {
for( i=0; i<iLength; i++ ) {
for( i=0; i<iLength; ++i ) {
gsl_fit_linear_est( pInputs[XVALUES][i], c0, c1, cov00, cov01, cov11, &y, &yErr );
outputVectorYFitted->value()[i] = y;
outputVectorYResiduals->value()[i] = pInputs[YVALUES][i] - y;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/curveselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void CurveSelector::setSelectedCurve(CurvePtr selectedCurve) {
//FIXME: findData doesn't work, but the loop here - which is supposed
// to do exactly the same thing - does. WHY???
//int i = _curve->findData(qVariantFromValue(selectedVector.data()));
int i=-1,j;
for (j=0; j<_curve->count() ; j++) {
int i=-1;
for (int j=0; j<_curve->count() ; j++) {
if (selectedCurve.data() == _curve->itemData(j).value<Curve*>()) {
i=j;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/scalarselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ void ScalarSelector::setSelectedScalar(QString Name) {


void ScalarSelector::setSelectedScalar(ScalarPtr selectedScalar) {
int i=-1,j;
for (j=0; j<_scalar->count() ; j++) {
int i=-1;
for (int j=0; j<_scalar->count() ; ++j) {
if (selectedScalar.data() == _scalar->itemData(j).value<Scalar*>()) {
i=j;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/stringselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ StringPtr StringSelector::selectedString() const {


void StringSelector::setSelectedString(StringPtr selectedString) {
int i=-1,j;
for (j=0; j<_string->count() ; j++) {
int i=-1;
for (int j=0; j<_string->count() ; ++j) {
if (selectedString.data() == _string->itemData(j).value<String*>()) {
i=j;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/vectorselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void VectorSelector::setSelectedVector(VectorPtr selectedVector) {
}
// "findData can't work here" says the trolls... so we do it 'manually'.
//int i = _vector->findData(qVariantFromValue(selectedVector.data()));
int i=-1,j;
for (j=0; j<_vector->count() ; j++) {
int i=-1;
for (int j=0; j<_vector->count() ; ++j) {
if (selectedVector.data() == _vector->itemData(j).value<Vector*>()) {
i=j;
break;
Expand Down