[Kst] branches/work/kst/portto4/kst/src/plugins/fits
Peter Kümmel
syntheticpp at gmx.net
Mon Mar 21 23:08:51 CET 2011
SVN commit 1225594 by kuemmel:
^pretty printing also for weighted poly fit
M +2 -1 polynomial_unweighted/fitpolynomial_unweighted.cpp
M +33 -0 polynomial_weighted/fitpolynomial_weighted.cpp
M +1 -0 polynomial_weighted/fitpolynomial_weighted.h
--- branches/work/kst/portto4/kst/src/plugins/fits/polynomial_unweighted/fitpolynomial_unweighted.cpp #1225593:1225594
@@ -214,13 +214,14 @@
return bReturn;
}
+
+// TODO merge with FitPolynomialWeightedSource
QString FitPolynomialUnweightedSource::parameterVectorToString() const {
QString str = Name();
if (hasParameterVector()) {
Kst::VectorPtr vectorParam = _outputVectors["Parameters Vector"];
- //for (int i = vectorParam->length() - 1; i >= 0; i--) {
for (int i = 0; i < vectorParam->length(); i++) {
QString paramName = parameterName(i);
if (!paramName.isEmpty()) {
--- branches/work/kst/portto4/kst/src/plugins/fits/polynomial_weighted/fitpolynomial_weighted.cpp #1225593:1225594
@@ -230,7 +230,40 @@
return bReturn;
}
+QString FitPolynomialWeightedSource::parameterVectorToString() const {
+ QString str = Name();
+
+ if (hasParameterVector()) {
+ Kst::VectorPtr vectorParam = _outputVectors["Parameters Vector"];
+ for (int i = 0; i < vectorParam->length(); i++) {
+ QString paramName = parameterName(i);
+ if (!paramName.isEmpty()) {
+ if (_outputScalars.contains(paramName)) {
+ QString name = _outputScalars[paramName]->Name();
+ double value = _outputScalars[paramName]->value();
+ QString sign;
+ if (value >= 0) {
+ sign = " +";
+ } else {
+ sign = " "; // Just for the space, the "-" is already in the number
+ }
+ if (i == 0) {
+ str += QString("\n[%1]").arg(name);
+ } else if (i == 1) { // Special case x^1 to x
+ str += QString("%1[%2]x").arg(sign).arg(name);
+ } else {
+ str += QString("%1[%2]%3").arg(sign).arg(name).arg(paramName);
+ }
+ }
+ }
+ }
+ }
+
+ return str;
+}
+
+
Kst::VectorPtr FitPolynomialWeightedSource::vectorX() const {
return _inputVectors[VECTOR_IN_X];
}
--- branches/work/kst/portto4/kst/src/plugins/fits/polynomial_weighted/fitpolynomial_weighted.h #1225593:1225594
@@ -50,6 +50,7 @@
~FitPolynomialWeightedSource();
virtual QString parameterName(int index) const;
+ virtual QString parameterVectorToString() const;
friend class Kst::ObjectStore;
More information about the Kst
mailing list