[Scipy-svn] r3297 - in branches/0.6.x/scipy/linalg: . src tests

scipy-svn@scip... scipy-svn@scip...
Thu Aug 30 18:19:31 CDT 2007


Author: chris.burns
Date: 2007-08-30 18:19:19 -0500 (Thu, 30 Aug 2007)
New Revision: 3297

Added:
   branches/0.6.x/scipy/linalg/src/fblaswrap_veclib_c.c
Modified:
   branches/0.6.x/scipy/linalg/setup.py
   branches/0.6.x/scipy/linalg/tests/test_blas.py
Log:
Applied veclib.patch from cdavid re ticket238

Modified: branches/0.6.x/scipy/linalg/setup.py
===================================================================
--- branches/0.6.x/scipy/linalg/setup.py	2007-08-30 21:15:48 UTC (rev 3296)
+++ branches/0.6.x/scipy/linalg/setup.py	2007-08-30 23:19:19 UTC (rev 3297)
@@ -23,6 +23,23 @@
 
 #--------------------
 
+def needs_cblas_wrapper(info):
+    """Returns true if needs c wrapper around cblas for calling from
+    fortran."""
+    import re
+    r_accel = re.compile("Accelerate")
+    r_vec = re.compile("vecLib")
+    res = False
+    try:
+        tmpstr = info['extra_link_args']
+        for i in tmpstr:
+            if r_accel.search(i) or r_vec.search(i):
+                res = True
+    except KeyError:
+        pass
+
+    return res
+    
 def configuration(parent_package='',top_path=None):
     from numpy.distutils.system_info import get_info, NotFoundError
 
@@ -98,16 +115,28 @@
         return target
 
     # fblas:
-    config.add_extension('fblas',
-                         sources = [generate_pyf,
-                                    join('src','fblaswrap.f')],
-                         depends = ['generic_fblas.pyf',
-                                    'generic_fblas1.pyf',
-                                    'generic_fblas2.pyf',
-                                    'generic_fblas3.pyf',
-                                    'interface_gen.py'],
-                         extra_info = lapack_opt
-                         )
+    if needs_cblas_wrapper(lapack_opt):
+        config.add_extension('fblas',
+                             sources = [generate_pyf,
+                                        join('src','fblaswrap_veclib_c.c')],
+                             depends = ['generic_fblas.pyf',
+                                        'generic_fblas1.pyf',
+                                        'generic_fblas2.pyf',
+                                        'generic_fblas3.pyf',
+                                        'interface_gen.py'],
+                             extra_info = lapack_opt
+                             )
+    else:
+        config.add_extension('fblas',
+                             sources = [generate_pyf,
+                                        join('src','fblaswrap.f')],
+                             depends = ['generic_fblas.pyf',
+                                        'generic_fblas1.pyf',
+                                        'generic_fblas2.pyf',
+                                        'generic_fblas3.pyf',
+                                        'interface_gen.py'],
+                             extra_info = lapack_opt
+                             )
 
     # cblas:
     config.add_extension('cblas',

Added: branches/0.6.x/scipy/linalg/src/fblaswrap_veclib_c.c
===================================================================
--- branches/0.6.x/scipy/linalg/src/fblaswrap_veclib_c.c	2007-08-30 21:15:48 UTC (rev 3296)
+++ branches/0.6.x/scipy/linalg/src/fblaswrap_veclib_c.c	2007-08-30 23:19:19 UTC (rev 3297)
@@ -0,0 +1,22 @@
+#include <vecLib/vecLib.h>
+
+//#define WRAP_F77(a) wcblas_##a##_
+#define WRAP_F77(a) w##a##_
+void WRAP_F77(cdotc)(complex *dotc, const int *N, const complex *X, const int *incX, const complex *Y, const int *incY)
+{
+    cblas_cdotc_sub(*N, X, *incX, Y, *incY, dotc);
+}
+
+void WRAP_F77(cdotu)(complex* dotu, const int *N, const complex *X, const int *incX, const complex *Y, const int *incY)
+{
+    cblas_cdotu_sub(*N, X, *incX, Y, *incY, dotu);
+}
+
+void WRAP_F77(zdotc)(double complex *dotu, const int *N, const double complex *X, const int *incX, const double complex *Y, const int *incY)
+{
+    cblas_zdotc_sub(*N, X, *incX, Y, *incY, dotu);
+}
+void WRAP_F77(zdotu)(double complex *dotu, const int *N, const double complex *X, const int *incX, const double complex *Y, const int *incY)
+{
+    cblas_zdotu_sub(*N, X, *incX, Y, *incY, dotu);
+}


Property changes on: branches/0.6.x/scipy/linalg/src/fblaswrap_veclib_c.c
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: branches/0.6.x/scipy/linalg/tests/test_blas.py
===================================================================
--- branches/0.6.x/scipy/linalg/tests/test_blas.py	2007-08-30 21:15:48 UTC (rev 3296)
+++ branches/0.6.x/scipy/linalg/tests/test_blas.py	2007-08-30 23:19:19 UTC (rev 3297)
@@ -20,6 +20,7 @@
 from numpy.testing import *
 set_package_path()
 from linalg import fblas
+print fblas
 from linalg import cblas
 restore_path()
 
@@ -69,12 +70,18 @@
             f = getattr(fblas,p+'dot',None)
             if f is None: continue
             assert_almost_equal(f([3,-4,5],[2,5,1]),-9)
+    def check_complex_dotu(self):
         for p in 'cz':
             f = getattr(fblas,p+'dotu',None)
             if f is None: continue
             assert_almost_equal(f([3j,-4,3-4j],[2,3,1]),-9+2j)
-            f = getattr(fblas,p+'dotc')
+
+    def check_complex_dotc(self):
+        for p in 'cz':
+            f = getattr(fblas,p+'dotc',None)
+            if f is None: continue
             assert_almost_equal(f([3j,-4,3-4j],[2,3j,1]),3-14j)
+
     def check_nrm2(self):
         for p in 'sd':
             f = getattr(fblas,p+'nrm2',None)



More information about the Scipy-svn mailing list