[Scipy-svn] r3112 - trunk/Lib/cluster/src

scipy-svn@scip... scipy-svn@scip...
Wed Jun 20 11:35:36 CDT 2007


Author: cdavid
Date: 2007-06-20 11:35:16 -0500 (Wed, 20 Jun 2007)
New Revision: 3112

Modified:
   trunk/Lib/cluster/src/vq.c
   trunk/Lib/cluster/src/vq.h
   trunk/Lib/cluster/src/vq.tpl
   trunk/Lib/cluster/src/vq_module.c
Log:
Convert int to long long for index for correct support on 64 bits arch

Modified: trunk/Lib/cluster/src/vq.c
===================================================================
--- trunk/Lib/cluster/src/vq.c	2007-06-20 10:23:17 UTC (rev 3111)
+++ trunk/Lib/cluster/src/vq.c	2007-06-20 16:35:16 UTC (rev 3112)
@@ -1,5 +1,9 @@
 /*
  * vim:syntax=c
+ *
+ * This file implements vq for float and double in C. It is a direct
+ * translation from the swig interface which could not be generated anymore
+ * with recent swig
  */
 #include <stddef.h>
 #include <math.h>
@@ -14,7 +18,7 @@
 
 static int float_vq_1d(const float *in, int n, 
     const float *init, int ncode, 
-    int *code, float *mdist)
+    long long *code, float *mdist)
 {
     int i, j;
     float m, d;
@@ -37,7 +41,7 @@
 
 static int float_vq_obs(const float *obs,
     float *code_book, int Ncodes, int Nfeatures,
-       int* code, float *lowest_dist)
+       long long* code, float *lowest_dist)
 {
 	int i,j,k=0;
 	float dist, diff;
@@ -64,7 +68,7 @@
     float* obs,
     float* code_book, 
     int Nobs, int Ncodes, int Nfeatures,
-    int* codes, float* lowest_dist)
+    long long* codes, float* lowest_dist)
 {
     int i;
 	for( i = 0; i < Nobs; i++) {		
@@ -78,7 +82,7 @@
 
 static int double_vq_1d(const double *in, int n, 
     const double *init, int ncode, 
-    int *code, double *mdist)
+    long long *code, double *mdist)
 {
     int i, j;
     double m, d;
@@ -101,7 +105,7 @@
 
 static int double_vq_obs(const double *obs,
     double *code_book, int Ncodes, int Nfeatures,
-       int* code, double *lowest_dist)
+       long long* code, double *lowest_dist)
 {
 	int i,j,k=0;
 	double dist, diff;
@@ -128,7 +132,7 @@
     double* obs,
     double* code_book, 
     int Nobs, int Ncodes, int Nfeatures,
-    int* codes, double* lowest_dist)
+    long long* codes, double* lowest_dist)
 {
     int i;
 	for( i = 0; i < Nobs; i++) {		

Modified: trunk/Lib/cluster/src/vq.h
===================================================================
--- trunk/Lib/cluster/src/vq.h	2007-06-20 10:23:17 UTC (rev 3111)
+++ trunk/Lib/cluster/src/vq.h	2007-06-20 16:35:16 UTC (rev 3112)
@@ -2,9 +2,9 @@
 #define _VQ_H
 
 int double_tvq(double* obs, double* code_book, int Nobs, int Ncodes, 
-        int Nfeatures, int* codes, double* lowest_dist);
+        int Nfeatures, long long* codes, double* lowest_dist);
 
 int float_tvq(float* obs, float* code_book, int Nobs, int Ncodes, 
-        int Nfeatures, int* codes, float* lowest_dist);
+        int Nfeatures, long long* codes, float* lowest_dist);
 
 #endif

Modified: trunk/Lib/cluster/src/vq.tpl
===================================================================
--- trunk/Lib/cluster/src/vq.tpl	2007-06-20 10:23:17 UTC (rev 3111)
+++ trunk/Lib/cluster/src/vq.tpl	2007-06-20 16:35:16 UTC (rev 3112)
@@ -19,7 +19,7 @@
 [+ FOR data_type +]
 static int [+ (get "type_name") +]_vq_1d(const [+ (get "type_name") +] *in, int n, 
     const [+ (get "type_name") +] *init, int ncode, 
-    int *code, [+ (get "type_name") +] *mdist)
+    long long *code, [+ (get "type_name") +] *mdist)
 {
     int i, j;
     [+ (get "data_type") +] m, d;
@@ -42,7 +42,7 @@
 
 static int [+ (get "type_name") +]_vq_obs(const [+ (get "data_type") +] *obs,
     [+ (get "data_type") +] *code_book, int Ncodes, int Nfeatures,
-       int* code, [+ (get "data_type") +] *lowest_dist)
+       long long* code, [+ (get "data_type") +] *lowest_dist)
 {
 	int i,j,k=0;
 	[+ (get "data_type") +] dist, diff;
@@ -69,7 +69,7 @@
     [+ (get "data_type") +]* obs,
     [+ (get "data_type") +]* code_book, 
     int Nobs, int Ncodes, int Nfeatures,
-    int* codes, [+ (get "data_type") +]* lowest_dist)
+    long long* codes, [+ (get "data_type") +]* lowest_dist)
 {
     int i;
 	for( i = 0; i < Nobs; i++) {		

Modified: trunk/Lib/cluster/src/vq_module.c
===================================================================
--- trunk/Lib/cluster/src/vq_module.c	2007-06-20 10:23:17 UTC (rev 3111)
+++ trunk/Lib/cluster/src/vq_module.c	2007-06-20 16:35:16 UTC (rev 3112)
@@ -27,7 +27,8 @@
     PyArrayObject *obs_a, *code_a;
     PyArrayObject *index_a, *dist_a;
     int typenum1, typenum2;
-    int n, nc, d, nd;
+    int nc, nd;
+    npy_intp n, d;
 
     if ( !PyArg_ParseTuple(args, "OO", &obs, &code) ) {
         return NULL;



More information about the Scipy-svn mailing list