Bug 88120 - scalar that would give the last value of a vector
Summary: scalar that would give the last value of a vector
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Other
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-26 13:02 UTC by Marc-Antoine Miville-Deschenes
Modified: 2004-08-26 18:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-Antoine Miville-Deschenes 2004-08-26 13:02:15 UTC
Version:           1.0.0_devel (using KDE 3.1.4)
Installed from:    compiled sources
Compiler:          gcc version 3.3 20030304 (Apple Computer, Inc. build 1495)
OS:                Darwin (Power Macintosh) release 7.5.0

It would be very useful to have a scalar 
computed automatically that would give the last
value of a vector (to monitor slowly varying values)
Comment 1 Andrew Walker 2004-08-26 18:17:34 UTC
CVS commit by arwalker: 

Add automatically generated scalar gicing last read value of a vector.

CCMAIL: 88120-done@bugs.kde.org


  M +13 -4     kstvector.cpp   1.79


--- kdeextragear-2/kst/kst/kstvector.cpp  #1.78:1.79
@@ -136,9 +136,11 @@ double KstVector::interpolate(int in_i, 
 
   /** Limits checks - optional? **/
-  if (in_i < 0)
+  if (in_i < 0) {
     return _v[0];
+  }
 
-  if (in_i >= ns_i - 1)
+  if (in_i >= ns_i - 1) {
     return _v[_size - 1];
+  }
 
   /** speedup check **/
@@ -186,4 +188,6 @@ void KstVector::CreateScalars() {
     _scalars.insert("min", new KstScalar(tagName() + "-Min"));
     _scalars["min"]->_KShared_ref();
+    _scalars.insert("last", new KstScalar(tagName() + "-Last"));
+    _scalars["last"]->_KShared_ref();
     _scalars.insert("mean", new KstScalar(tagName() + "-Mean"));
     _scalars["mean"]->_KShared_ref();
@@ -207,4 +211,5 @@ void KstVector::RenameScalars() {
     _scalars["max"]->setTagName(tagName() + "-Max");
     _scalars["min"]->setTagName(tagName() + "-Min");
+    _scalars["last"]->setTagName(tagName() + "-Last");
     _scalars["mean"]->setTagName(tagName() + "-Mean");
     _scalars["sigma"]->setTagName(tagName() + "-Sigma");
@@ -279,9 +284,9 @@ bool KstVector::resize(int sz, bool rein
 KstObject::UpdateType KstVector::update(int update_counter) {
   int i, i0;
-  double max, min, sum, sum2, minpos, v;
+  double max, min, sum, sum2, minpos, last, v;
   double last_v;
   double dv2=0.0, dv, no_spike_max_dv;
 
-  max = min = sum = sum2 = minpos = 0.0;
+  max = min = sum = sum2 = minpos = last = 0.0;
 
   if (KstObject::checkUpdateCounter(update_counter))
@@ -303,4 +308,5 @@ KstObject::UpdateType KstVector::update(
         _scalars["min"]->setValue(min);
         _scalars["minpos"]->setValue(minpos);
+        _scalars["last"]->setValue(last);
       }
       _ns_max = _ns_min = 0;
@@ -364,4 +370,6 @@ KstObject::UpdateType KstVector::update(
     _ns_max = _ns_min = last_v = _v[i0];
 
+    last = _v[_size-1];
+    
     for (i = i0; i < _size; i++) {
       v = _v[i]; // get rid of redirections
@@ -390,4 +398,5 @@ KstObject::UpdateType KstVector::update(
       _scalars["min"]->setValue(min);
       _scalars["minpos"]->setValue(minpos);
+      _scalars["last"]->setValue(last);
     }