<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>135090</bug_id>
          
          <creation_ts>2006-10-04 15:31:57 +0000</creation_ts>
          <short_desc>Add a [Vector-First] automatic scalar</short_desc>
          <delta_ts>2006-11-27 10:21:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kst</product>
          <component>general</component>
          <version>1.x</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Solaris</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nicolas Brisset">nicolas.brisset</reporter>
          <assigned_to>kst</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>474682</commentid>
    <comment_count>0</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 15:31:58 +0000</bug_when>
    <thetext>Version:           1.3.0 (using KDE 3.4.0, compiled sources)
Compiler:          gcc version 3.4.3
OS:                SunOS (sun4u) release 5.8

As there is a [Vector-Last] scalar created for each loaded vector, a [Vector-First] scalar containing the first value would be handy.

On a side note, what does the -MinPos scalar represent ? Is is supposed to be the index corresponding to the minimum value ? And why is there no MaxPos ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474695</commentid>
    <comment_count>1</comment_count>
      <attachid>18009</attachid>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 16:07:52 +0000</bug_when>
    <thetext>Created attachment 18009
Proposed patch

Since the request is very similar to bug #88120, I developed something very
similar. It seems to work fine, I&apos;ll leave it to you to apply after review,
though.

Note: I&apos;m not sure I understand the purpose of the first
_scalars[&quot;first&quot;]-&gt;setValue(first); 
line after the loop that checks whether there are NaNs in the vector.. Maybe
the line I added there is not appropriate...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474698</commentid>
    <comment_count>2</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 16:13:41 +0000</bug_when>
    <thetext>By the way, MinPos is the smallest positive value. There may be other useful values we could add ? I&apos;m thinking particularly about:
- index of the min (to e.g. create a label containing the time at which the minimum occurs, provided that time is the X vector and has the same length)
- index of the max
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474699</commentid>
    <comment_count>3</comment_count>
    <who name="George Staikos">staikos</who>
    <bug_when>2006-10-04 16:18:15 +0000</bug_when>
    <thetext>On Wednesday 04 October 2006 10:07, Nicolas Brisset wrote:

&gt; Since the request is very similar to bug #88120, I developed something very
&gt; similar. It seems to work fine, I&apos;ll leave it to you to apply after review,
&gt; though.


  Looks fine, feel free to commit to trunk if you like.

&gt; Note: I&apos;m not sure I understand the purpose of the first
&gt; _scalars[&quot;first&quot;]-&gt;setValue(first);
&gt; line after the loop that checks whether there are NaNs in the vector..
&gt; Maybe the line I added there is not appropriate...


  It&apos;s a short-circuit to exit the update early.  Notice that it returns if it 
goes there.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474702</commentid>
    <comment_count>4</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 16:25:15 +0000</bug_when>
    <thetext>OK, I&apos;ll commit to trunk. I suppose you&apos;ll backport it to the 1.3 branch ?
Regarding the MinIndex and MaxIndex scalars, are there opinions as to whether we should also add them ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474704</commentid>
    <comment_count>5</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 16:42:45 +0000</bug_when>
    <thetext>SVN commit 592357 by brisset:

Add a -First scalar when loading vectors, with the first value of the vector.
I think it would be useful to also add -MinIndex and -MaxIndex scalars, so I&apos;ll leave the bug open.
I have just one question: what happens to these scalars when vectors are interpolated ?

CCBUG: 135090



 M  +8 -2      kstvector.cpp  


--- trunk/extragear/graphics/kst/src/libkst/kstvector.cpp #592356:592357
@@ -250,6 +250,8 @@
     sp-&gt;_KShared_ref();
     _scalars.insert(&quot;last&quot;, sp = new KstScalar(tagName() + &quot;-Last&quot;, this));
     sp-&gt;_KShared_ref();
+    _scalars.insert(&quot;first&quot;, sp = new KstScalar(tagName() + &quot;-First&quot;, this));
+    sp-&gt;_KShared_ref();
     _scalars.insert(&quot;mean&quot;, sp = new KstScalar(tagName() + &quot;-Mean&quot;, this));
     sp-&gt;_KShared_ref();
     _scalars.insert(&quot;sigma&quot;, sp = new KstScalar(tagName() + &quot;-Sigma&quot;, this));
@@ -272,6 +274,7 @@
     _scalars[&quot;max&quot;]-&gt;setTagName(tagName() + &quot;-Max&quot;);
     _scalars[&quot;min&quot;]-&gt;setTagName(tagName() + &quot;-Min&quot;);
     _scalars[&quot;last&quot;]-&gt;setTagName(tagName() + &quot;-Last&quot;);
+    _scalars[&quot;first&quot;]-&gt;setTagName(tagName() + &quot;-First&quot;);
     _scalars[&quot;mean&quot;]-&gt;setTagName(tagName() + &quot;-Mean&quot;);
     _scalars[&quot;sigma&quot;]-&gt;setTagName(tagName() + &quot;-Sigma&quot;);
     _scalars[&quot;rms&quot;]-&gt;setTagName(tagName() + &quot;-Rms&quot;);
@@ -375,11 +378,11 @@
 
 KstObject::UpdateType KstVector::internalUpdate(KstObject::UpdateType providerRC) {
   int i, i0;
-  double sum, sum2, last, v;
+  double sum, sum2, last, first, v;
   double last_v;
   double dv2 = 0.0, dv, no_spike_max_dv;
   
-  _max = _min = sum = sum2 = _minPos = last = KST::NOPOINT;
+  _max = _min = sum = sum2 = _minPos = last = first = KST::NOPOINT;
   _nsum = 0;
   
   if (_size &gt; 0) {
@@ -398,6 +401,7 @@
         _scalars[&quot;min&quot;]-&gt;setValue(_min);
         _scalars[&quot;minpos&quot;]-&gt;setValue(_minPos);
         _scalars[&quot;last&quot;]-&gt;setValue(last);
+        _scalars[&quot;first&quot;]-&gt;setValue(first);
       }
       _ns_max = _ns_min = 0;
 
@@ -460,6 +464,7 @@
     _ns_max = _ns_min = last_v = _v[i0];
 
     last = _v[_size-1];
+    first = _v[0];
 
     for (i = i0; i &lt; _size; i++) {
       v = _v[i]; // get rid of redirections
@@ -490,6 +495,7 @@
       _scalars[&quot;min&quot;]-&gt;setValue(_min);
       _scalars[&quot;minpos&quot;]-&gt;setValue(_minPos);
       _scalars[&quot;last&quot;]-&gt;setValue(last);
+      _scalars[&quot;first&quot;]-&gt;setValue(first);
     }
 
     updateScalars();
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474718</commentid>
    <comment_count>6</comment_count>
    <who name="George Staikos">staikos</who>
    <bug_when>2006-10-04 17:13:13 +0000</bug_when>
    <thetext>No new features in 1.3.1.  It will have to wait for 1.4.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474725</commentid>
    <comment_count>7</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 18:01:15 +0000</bug_when>
    <thetext>Looking at the code again, I notice there is a updateScalars method that seems to update some scalar values, e.g. when a vector is blanked or zeroed. It is not clear to me why other scalars are not updated like for instance -Last, and certainly others ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474728</commentid>
    <comment_count>8</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-10-04 18:12:26 +0000</bug_when>
    <thetext>Thinking about the use cases for MinIndex and MaxIndex, I realize this is linked with indexed access into vectors (as discussed on the list in July 2005)? Have we eventually gone as far as adding that to the parser ?
The idea would be to be able to generate a label like &quot;Min temperature: [Temperature-Min] obtained at @Time[Temperature-MinIndex]&quot;
If indexed access into vectors hs been forgotten, I think we should create a new bugzilla entry for it...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>474738</commentid>
    <comment_count>9</comment_count>
    <who name="George Staikos">staikos</who>
    <bug_when>2006-10-04 18:37:29 +0000</bug_when>
    <thetext>  If you think it is a bug, please test and report it here and we can fix it 
(and backport those fixes).
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489528</commentid>
    <comment_count>10</comment_count>
    <who name="Netterfield">netterfield</who>
    <bug_when>2006-11-25 03:59:46 +0000</bug_when>
    <thetext>The fix for this was committed by Nicholas in October.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489950</commentid>
    <comment_count>11</comment_count>
    <who name="Nicolas Brisset">nicolas.brisset</who>
    <bug_when>2006-11-27 10:21:30 +0000</bug_when>
    <thetext>Right, but the first reason I left this open is that I had doubts that all scalars get updated correctly. Looking at the code, it was not obvious as some are handled in internalUpdate() and others in updateScalars(). But I have just had a (quick) look again and it seems to be OK. As far as I remember (non-exhaustive) testing also showed normal results. 
The second reason was that we could easily add other scalars (see comment #8) that will be very useful as soon as we have indexed access into vectors from labels. I was also wondering if we could benefit performance wise in the drawing code from these scalars ? In any case, the best would probably be to open a separate report for those new scalars. That&apos;s what I&apos;ll do...
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>18009</attachid>
            <date>2006-10-04 16:07:52 +0000</date>
            <delta_ts>2006-10-04 16:07:52 +0000</delta_ts>
            <desc>Proposed patch</desc>
            <filename>patch_add_first_scalar.txt</filename>
            <type>text/plain</type>
            <size>2261</size>
            <attacher name="Nicolas Brisset">nicolas.brisset</attacher>
            
              <data encoding="base64">LS0tIGtzdHZlY3Rvci5jcHAub3JpZwkyMDA2LTEwLTA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Bfc2NhbGFy
c1sibGFzdCJdLT5zZXRWYWx1ZShsYXN0KTsKKyAgICAgICAgX3NjYWxhcnNbImZpcnN0Il0tPnNl
dFZhbHVlKGZpcnN0KTsKICAgICAgIH0KICAgICAgIF9uc19tYXggPSBfbnNfbWluID0gMDsKIApA
QCAtNDYwLDYgKzQ2NCw3IEBAIEtzdE9iamVjdDo6VXBkYXRlVHlwZSBLc3RWZWN0b3I6OmludGVy
bmEKICAgICBfbnNfbWF4ID0gX25zX21pbiA9IGxhc3RfdiA9IF92W2kwXTsKIAogICAgIGxhc3Qg
PSBfdltfc2l6ZS0xXTsKKyAgICBmaXJzdCA9IF92WzBdOwogCiAgICAgZm9yIChpID0gaTA7IGkg
PCBfc2l6ZTsgaSsrKSB7CiAgICAgICB2ID0gX3ZbaV07IC8vIGdldCByaWQgb2YgcmVkaXJlY3Rp
b25zCkBAIC00OTAsNiArNDk1LDcgQEAgS3N0T2JqZWN0OjpVcGRhdGVUeXBlIEtzdFZlY3Rvcjo6
aW50ZXJuYQogICAgICAgX3NjYWxhcnNbIm1pbiJdLT5zZXRWYWx1ZShfbWluKTsKICAgICAgIF9z
Y2FsYXJzWyJtaW5wb3MiXS0+c2V0VmFsdWUoX21pblBvcyk7CiAgICAgICBfc2NhbGFyc1sibGFz
dCJdLT5zZXRWYWx1ZShsYXN0KTsKKyAgICAgIF9zY2FsYXJzWyJmaXJzdCJdLT5zZXRWYWx1ZShm
aXJzdCk7CiAgICAgfQogCiAgICAgdXBkYXRlU2NhbGFycygpOwo=
</data>

          </attachment>
      

    </bug>

</bugzilla>