[Kst] extragear/graphics/kst/src/plugins/interpolations

Adam Treat treat at kde.org
Wed Dec 13 22:09:09 CET 2006


SVN commit 613318 by treat:

* Convert all the interpolation plugins to the new
scheme.  Redo the common algorithm.


 M  +0 -1      Makefile.am  
 M  +8 -8      akima/Makefile.am  
 A             akima/akima.cpp   [License: GPL (v2+)]
 A             akima/akima.h   [License: GPL (v2+)]
 D             akima/kstinterp_akima.cpp  
 D             akima/kstinterp_akima.xml  
 A             akima/kstobject_akima.desktop  
 M  +8 -8      akima_periodic/Makefile.am  
 A             akima_periodic/akima_periodic.cpp   [License: GPL (v2+)]
 A             akima_periodic/akima_periodic.h   [License: GPL (v2+)]
 D             akima_periodic/kstinterp_akima_periodic.cpp  
 D             akima_periodic/kstinterp_akima_periodic.xml  
 A             akima_periodic/kstobject_akima_periodic.desktop  
 M  +8 -8      cspline/Makefile.am  
 A             cspline/cspline.cpp   [License: GPL (v2+)]
 A             cspline/cspline.h   [License: GPL (v2+)]
 D             cspline/kstinterp_cspline.cpp  
 D             cspline/kstinterp_cspline.xml  
 A             cspline/kstobject_cspline.desktop  
 M  +8 -8      cspline_periodic/Makefile.am  
 A             cspline_periodic/cspline_periodic.cpp   [License: GPL (v2+)]
 A             cspline_periodic/cspline_periodic.h   [License: GPL (v2+)]
 D             cspline_periodic/kstinterp_cspline_periodic.cpp  
 D             cspline_periodic/kstinterp_cspline_periodic.xml  
 A             cspline_periodic/kstobject_cspline_periodic.desktop  
 M  +42 -55    interpolations.h  
 M  +8 -8      linear/Makefile.am  
 D             linear/kstinterp_linear.cpp  
 D             linear/kstinterp_linear.xml  
 A             linear/kstobject_linear.desktop  
 A             linear/linear.cpp   [License: GPL (v2+)]
 A             linear/linear.h   [License: GPL (v2+)]
 M  +8 -8      polynomial/Makefile.am  
 D             polynomial/kstinterp_polynomial.cpp  
 D             polynomial/kstinterp_polynomial.xml  
 A             polynomial/kstobject_polynomial.desktop  
 A             polynomial/polynomial.cpp   [License: GPL (v2+)]
 A             polynomial/polynomial.h   [License: GPL (v2+)]


--- trunk/extragear/graphics/kst/src/plugins/interpolations/Makefile.am #613317:613318
@@ -1,2 +1 @@
 SUBDIRS=linear cspline cspline_periodic akima akima_periodic polynomial
-
--- trunk/extragear/graphics/kst/src/plugins/interpolations/akima/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_akima.la
+kde_module_LTLIBRARIES=kstobject_akima.la
 
-kstinterp_akima_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_akima_la_LIBADD = $(GSL_LIBS)
-kstinterp_akima_la_SOURCES = kstinterp_akima.cpp
+kstobject_akima_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_akima_la_SOURCES=akima.cpp
+kstobject_akima_la_LIBADD = $(GSL_LIBS)
 
-METASOURCES=AUTO
+services_DATA=kstobject_akima.desktop
+servicesdir=$(kde_servicesdir)/kst
 
-install_DATA=kstinterp_akima.xml
+METASOURCES=AUTO
\ No newline at end of file
--- trunk/extragear/graphics/kst/src/plugins/interpolations/akima_periodic/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_akima_periodic.la
+kde_module_LTLIBRARIES=kstobject_akima_periodic.la
 
-kstinterp_akima_periodic_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_akima_periodic_la_LIBADD = $(GSL_LIBS)
-kstinterp_akima_periodic_la_SOURCES = kstinterp_akima_periodic.cpp
+kstobject_akima_periodic_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_akima_periodic_la_SOURCES=akima_periodic.cpp
+kstobject_akima_periodic_la_LIBADD = $(GSL_LIBS)
 
+services_DATA=kstobject_akima_periodic.desktop
+servicesdir=$(kde_servicesdir)/kst
+
 METASOURCES=AUTO
-
-install_DATA=kstinterp_akima_periodic.xml
--- trunk/extragear/graphics/kst/src/plugins/interpolations/cspline/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_cspline.la
+kde_module_LTLIBRARIES=kstobject_cspline.la
 
-kstinterp_cspline_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_cspline_la_LIBADD = $(GSL_LIBS)
-kstinterp_cspline_la_SOURCES = kstinterp_cspline.cpp
+kstobject_cspline_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_cspline_la_SOURCES=cspline.cpp
+kstobject_cspline_la_LIBADD = $(GSL_LIBS)
 
-METASOURCES=AUTO
+services_DATA=kstobject_cspline.desktop
+servicesdir=$(kde_servicesdir)/kst
 
-install_DATA=kstinterp_cspline.xml
+METASOURCES=AUTO
\ No newline at end of file
--- trunk/extragear/graphics/kst/src/plugins/interpolations/cspline_periodic/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_cspline_periodic.la
+kde_module_LTLIBRARIES=kstobject_cspline_periodic.la
 
-kstinterp_cspline_periodic_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_cspline_periodic_la_LIBADD = $(GSL_LIBS)
-kstinterp_cspline_periodic_la_SOURCES = kstinterp_cspline_periodic.cpp
+kstobject_cspline_periodic_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_cspline_periodic_la_SOURCES=cspline_periodic.cpp
+kstobject_cspline_periodic_la_LIBADD = $(GSL_LIBS)
 
+services_DATA=kstobject_cspline_periodic.desktop
+servicesdir=$(kde_servicesdir)/kst
+
 METASOURCES=AUTO
-
-install_DATA=kstinterp_cspline_periodic.xml
--- trunk/extragear/graphics/kst/src/plugins/interpolations/interpolations.h #613317:613318
@@ -4,75 +4,62 @@
  *  Released under the terms of the GPL.
  */
 
-#define KST_UNUSED(x) if(x){};
+#define X           0
+#define Y           1
+#define X_INTERP    2
 
-#define X 					0
-#define Y 					1
-#define X_INTERP 		2
+#include <kstvector.h>
 
-int interpolate(
-  const double *const inArrays[], 
-  const int inArrayLens[],
-  const double inScalars[],
-  double *outArrays[], 
-  int outArrayLens[],
-	double outScalars[],
-  const gsl_interp_type* pType);
+bool interpolate(KstVectorPtr x_array,
+                 KstVectorPtr y_array,
+                 KstVectorPtr x1_array,
+                 KstVectorPtr y_interpolated,
+                 const gsl_interp_type* pType) {
 
-int interpolate(
-  const double *const inArrays[], 
-  const int inArrayLens[],
-  const double inScalars[],
-  double *outArrays[], 
-  int outArrayLens[],
-	double outScalars[],
-  const gsl_interp_type* pType) {
-  
-  KST_UNUSED( inScalars )
-  KST_UNUSED( outScalars )
-  
-  gsl_interp_accel*	pAccel = NULL;
-  gsl_interp*				pInterp = NULL;
-  gsl_spline*				pSpline = NULL;
-  int i = 0;
+  gsl_interp_accel *pAccel = NULL;
+  gsl_interp *pInterp = NULL;
+  gsl_spline *pSpline = NULL;
   int iLengthData;
-  int	iLengthInterp;
-  int iReturn = -1;
+  int iLengthInterp;
+  bool iReturn = false;
   double* pResult[1];
-  
-  iLengthData = inArrayLens[X];
-  if( inArrayLens[Y] < iLengthData ) {
-    iLengthData = inArrayLens[Y];
+
+  iLengthData = x_array->length();
+  if (y_array->length() < iLengthData) {
+    iLengthData = y_array->length();
   }
-  
-  iLengthInterp = inArrayLens[X_INTERP];
-  if( iLengthInterp > 0 ) {
-    if( outArrayLens[0] != iLengthInterp ) {
-      pResult[0] = (double*)realloc( outArrays[0], iLengthInterp * sizeof( double ) );
+
+  iLengthInterp = x1_array->length();
+  if (iLengthInterp > 0) {
+    if (y_interpolated->length() != iLengthInterp) {
+      y_interpolated->resize(iLengthInterp, true);
+      pResult[0] = (double*)realloc( y_interpolated->value(), iLengthInterp * sizeof( double ) );
     } else {
-      pResult[0] = outArrays[0];
+      pResult[0] = y_interpolated->value();
     }
-    
-    if( pResult[0] != NULL ) {
-      outArrays[0] = pResult[0];
-      outArrayLens[0] = iLengthInterp;
-     
+
+    if (pResult[0] != NULL) {
+
+      for (int i = 0; i < iLengthInterp; ++i) {
+        y_interpolated->value()[i] = pResult[0][i];
+      }
+
       pInterp = gsl_interp_alloc( pType, iLengthData );
-      if( pInterp != NULL ) {
+      if (pInterp != NULL) {
         //
         // check that we have enough data points...
         //
-        if( (unsigned int)iLengthData > gsl_interp_min_size( pInterp ) ) {    
+        if ((unsigned int)iLengthData > gsl_interp_min_size( pInterp )) {
           pAccel  = gsl_interp_accel_alloc( );
-          if( pAccel != NULL ) {
+          if (pAccel != NULL) {
             pSpline = gsl_spline_alloc( pType, iLengthData );
-            if( pSpline != NULL ) {
-              if( !gsl_spline_init( pSpline, inArrays[X], inArrays[Y], iLengthData ) ) {
-                for( i=0; i<iLengthInterp; i++ ) {
-                  outArrays[0][i] = gsl_spline_eval( pSpline, inArrays[X_INTERP][i], pAccel );
+            if (pSpline != NULL) {
+              if (!gsl_spline_init( pSpline, x_array->value(), y_array->value(), iLengthData )) {
+                for( int i=0; i<iLengthInterp; i++) {
+                  y_interpolated->value()[i] = gsl_spline_eval( pSpline, x1_array->value()[i], pAccel );
                 }
-                
-                iReturn = 0;
+
+                iReturn = true;
               }
               gsl_spline_free( pSpline );
             }
@@ -83,6 +70,6 @@
       }
     }
   }
-  
+
   return iReturn;
 }
--- trunk/extragear/graphics/kst/src/plugins/interpolations/linear/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_linear.la
+kde_module_LTLIBRARIES=kstobject_linear.la
 
-kstinterp_linear_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_linear_la_LIBADD = $(GSL_LIBS)
-kstinterp_linear_la_SOURCES = kstinterp_linear.cpp
+kstobject_linear_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_linear_la_SOURCES=linear.cpp
+kstobject_linear_la_LIBADD = $(GSL_LIBS)
 
-METASOURCES=AUTO
+services_DATA=kstobject_linear.desktop
+servicesdir=$(kde_servicesdir)/kst
 
-install_DATA=kstinterp_linear.xml
+METASOURCES=AUTO
\ No newline at end of file
--- trunk/extragear/graphics/kst/src/plugins/interpolations/polynomial/Makefile.am #613317:613318
@@ -1,12 +1,12 @@
-installdir=$(kde_moduledir)/kstplugins
-INCLUDES=-I$(srcdir)/../../../kst $(all_includes)
+INCLUDES=-I$(top_srcdir)/kst -I$(top_srcdir)/kst/src/libkst -I$(top_srcdir)/kst/src/libkstmath $(all_includes)
 
-install_LTLIBRARIES = kstinterp_polynomial.la
+kde_module_LTLIBRARIES=kstobject_polynomial.la
 
-kstinterp_polynomial_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
-kstinterp_polynomial_la_LIBADD = $(GSL_LIBS)
-kstinterp_polynomial_la_SOURCES = kstinterp_polynomial.cpp
+kstobject_polynomial_la_LDFLAGS=$(all_libraries) -module -avoid-version
+kstobject_polynomial_la_SOURCES=polynomial.cpp
+kstobject_polynomial_la_LIBADD = $(GSL_LIBS)
 
-METASOURCES=AUTO
+services_DATA=kstobject_polynomial.desktop
+servicesdir=$(kde_servicesdir)/kst
 
-install_DATA=kstinterp_polynomial.xml
+METASOURCES=AUTO
\ No newline at end of file


More information about the Kst mailing list