[Kst] extragear/graphics/kst/plugins/discretizing_filters

Nicolas Brisset nicolas.brisset at eurocopter.com
Mon Dec 12 12:47:29 CET 2005


SVN commit 487879 by brisset:

Fixlets; factor out a test in filter.h, but efficiency is still a problem: the FFT + filtering in freq domain + inverse FFT approach is almost as fast as this implementation, which should not be the case. Needs further investigation (any help appreciated, the only comptuationally-intensive piece being :NextTimeStep() in filter.h and the main loop in kstfilter_generic.cpp, line 60)

 M  +3 -1      Makefile  
 M  +5 -3      filter.h  
 M  +5 -5      kstfilter_generic.cpp  
 M  +1 -1      kstfilter_generic.xml  


--- trunk/extragear/graphics/kst/plugins/discretizing_filters/Makefile #487878:487879
@@ -10,10 +10,12 @@
 #Debug-Version
 #CFLAGS	=	-g -Wall 
 
-OBJ      = 	polynom.o filter.o kstfilter_generic.o
+OBJ      = 	kstfilter_generic.o
 
 INCLUDE_DIR	   =  -I. -I/usr/local/kde/include
+INCLUDE_DIR	   =  -I. -I/usr/lib/qt-3.3/include
 LINK_LIBS          =  -lm -L/usr/local/kde/lib -lqt-mt -lc
+LINK_LIBS          =  -lm -L/usr/lib/qt-3.3/lib -lqt-mt -lc
 KST_PLUGIN         = kstfilter_generic.so
 
 all:	$(KST_PLUGIN)
--- trunk/extragear/graphics/kst/plugins/discretizing_filters/filter.h #487878:487879
@@ -86,9 +86,11 @@
 {
   // intermediate output (with new input, but just before clock)
   S iOut = (x[n-1] + *in * Nz[n])/ Dz[n];
-  // update state vector (x[0] .. x[n-1] (goes from output to input)
-  for (int i=n-1; i>=0; i--)
-    x[i] = (i>0?x[i-1]:0) + Nz[i]*(*in) - Dz[i]*iOut;
+  // update state vector x[0] .. x[n-1] (goes from output to input)
+  for (int i=n-1; i>0; i--) {
+    x[i] = x[i-1] + Nz[i]*(*in) - Dz[i]*iOut;
+  }
+  x[0] = Nz[0]*(*in) - Dz[0]*iOut;
   // output
   out = (x[n-1] + Nz[n]*(*in)) / Dz[n];
 }
--- trunk/extragear/graphics/kst/plugins/discretizing_filters/kstfilter_generic.cpp #487878:487879
@@ -29,8 +29,8 @@
 
 // Extract polynom coefficients and instantiate polynoms
 QStringList numCoeffs = QStringList::split(QRegExp("\\s*(,|;|:)\\s*"), inStrings[0]);
-QStringList numden = QStringList::split(QRegExp("\\s*(,|;|:)\\s*"), inStrings[1]);
-int numDegree = numCoeffs.count() - 1, denDegree = numden.count() - 1;
+QStringList denCoeffs = QStringList::split(QRegExp("\\s*(,|;|:)\\s*"), inStrings[1]);
+int numDegree = numCoeffs.count() - 1, denDegree = denCoeffs.count() - 1;
 polynom<long double> Num(numDegree), Den(denDegree);
 double tmpDouble = 0.0;
 bool ok = false;
@@ -40,7 +40,7 @@
   else Num[i] = (long double) 0.0;
 }
 for (i=0; i<=denDegree; i++) {
-  tmpDouble = numCoeffs[i].toDouble(&ok);
+  tmpDouble = denCoeffs[i].toDouble(&ok);
   if (ok) Den[i] = (long double) tmpDouble;
   else Den[i] = (long double) 0.0;
 }
@@ -54,13 +54,13 @@
 
 // Create filter
 filter<long double> theFilter(Num,Den,DeltaT);
-long double in = inArrays[0][0];
+long double in = 0.0;
 theFilter.ConnectTo(in);
 theFilter.Reset();
 for (int i=0; i<length; i++) {
+  in = (long double) inArrays[0][i];
   theFilter.NextTimeStep();
   outArrays[0][i] = (double) theFilter.out;
-  in = (long double) inArrays[0][i];
 }
 
 return 0;
--- trunk/extragear/graphics/kst/plugins/discretizing_filters/kstfilter_generic.xml #487878:487879
@@ -18,7 +18,7 @@
 <string name="Numerator (increasing order)" descr="The p polynom of the numerator" default="1"/>
 </input>
 <input>
-<string name="Denominator (increasing order)" descr="The p polynom of the denominator" default="1 2"/>
+<string name="Denominator (increasing order)" descr="The p polynom of the denominator" default="1 ; 2"/>
 </input>
 <input>
 <float name="Sampling interval (s)" descr="Time step" default="0.02"/>


More information about the Kst mailing list