Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50296 - in sandbox/boost/numeric/bindings: blas lapack traits
From: thomas.klimpel_at_[hidden]
Date: 2008-12-16 09:50:23


Author: klimpel
Date: 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
New Revision: 50296
URL: http://svn.boost.org/trac/boost/changeset/50296

Log:
Add support for no-f2c return convention (g77 -fno-f2c, gfortran, MKL)

Text files modified:
   sandbox/boost/numeric/bindings/blas/blas.h | 16 ++++++++++++++++
   sandbox/boost/numeric/bindings/blas/blas1_overloads.hpp | 16 ++++++++++++++++
   sandbox/boost/numeric/bindings/lapack/trevc.hpp | 4 ++--
   sandbox/boost/numeric/bindings/traits/type.h | 10 ++++++++--
   sandbox/boost/numeric/bindings/traits/type_traits.hpp | 3 +++
   5 files changed, 45 insertions(+), 4 deletions(-)

Modified: sandbox/boost/numeric/bindings/blas/blas.h
==============================================================================
--- sandbox/boost/numeric/bindings/blas/blas.h (original)
+++ sandbox/boost/numeric/bindings/blas/blas.h 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
@@ -39,11 +39,27 @@
 #endif
   double BLAS_DDOT (const int *n, const double *x, const int *incx, const double *y, const int *incy);
 
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ fcomplex_t BLAS_CDOTU(const int *n, const fcomplex_t *x, const int *incx, const fcomplex_t *y, const int *incy);
+#else
   void BLAS_CDOTU(fcomplex_t* ret, const int *n, const fcomplex_t *x, const int *incx, const fcomplex_t *y, const int *incy);
+#endif
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ dcomplex_t BLAS_ZDOTU(const int *n, const dcomplex_t *x, const int *incx, const dcomplex_t *y, const int *incy);
+#else
   void BLAS_ZDOTU(dcomplex_t* ret, const int *n, const dcomplex_t *x, const int *incx, const dcomplex_t *y, const int *incy);
+#endif
 
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ fcomplex_t BLAS_CDOTC(const int *n, const fcomplex_t *x, const int *incx, const fcomplex_t *y, const int *incy);
+#else
   void BLAS_CDOTC(fcomplex_t* ret, const int *n, const fcomplex_t *x, const int *incx, const fcomplex_t *y, const int *incy);
+#endif
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ dcomplex_t BLAS_ZDOTC(const int *n, const dcomplex_t *x, const int *incx, const dcomplex_t *y, const int *incy);
+#else
   void BLAS_ZDOTC(dcomplex_t* ret, const int *n, const dcomplex_t *x, const int *incx, const dcomplex_t *y, const int *incy);
+#endif
 
 #ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
   float BLAS_SNRM2(const int *n, const float *x, const int *incx);

Modified: sandbox/boost/numeric/bindings/blas/blas1_overloads.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/blas/blas1_overloads.hpp (original)
+++ sandbox/boost/numeric/bindings/blas/blas1_overloads.hpp 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
@@ -34,12 +34,28 @@
   inline double dot(const int& n, const double* x, const int& incx, const double* y, const int& incy) { return BLAS_DDOT( &n, x, &incx, y, &incy ) ; }
 
   // x^T . y
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ inline void dotu(complex_f& ret, const int& n, const complex_f* x, const int& incx, const complex_f* y, const int& incy) { ret = complex_ret( BLAS_CDOTU( &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ) ; }
+#else
   inline void dotu(complex_f& ret, const int& n, const complex_f* x, const int& incx, const complex_f* y, const int& incy) { BLAS_CDOTU( complex_ptr( &ret ), &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ; }
+#endif
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ inline void dotu(complex_d& ret, const int& n, const complex_d* x, const int& incx, const complex_d* y, const int& incy) { ret = complex_ret( BLAS_ZDOTU( &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ) ; }
+#else
   inline void dotu(complex_d& ret, const int& n, const complex_d* x, const int& incx, const complex_d* y, const int& incy) { BLAS_ZDOTU( complex_ptr( &ret ), &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ; }
+#endif
 
   // x^H . y
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ inline void dotc(complex_f& ret, const int& n, const complex_f* x, const int& incx, const complex_f* y, const int& incy) { ret = complex_ret( BLAS_CDOTC( &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ) ; }
+#else
   inline void dotc(complex_f& ret, const int& n, const complex_f* x, const int& incx, const complex_f* y, const int& incy) { BLAS_CDOTC( complex_ptr( &ret ), &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ; }
+#endif
+#ifndef BIND_FORTRAN_F2C_RETURN_CONVENTIONS
+ inline void dotc(complex_d& ret, const int& n, const complex_d* x, const int& incx, const complex_d* y, const int& incy) { ret = complex_ret( BLAS_ZDOTC( &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ) ; }
+#else
   inline void dotc(complex_d& ret, const int& n, const complex_d* x, const int& incx, const complex_d* y, const int& incy) { BLAS_ZDOTC( complex_ptr( &ret ), &n, complex_ptr( x ), &incx, complex_ptr( y ), &incy ) ; }
+#endif
 
   // euclidean norm
   inline float nrm2(const int& n, const float* x, const int& incx) { return BLAS_SNRM2( &n, x, &incx ) ; }

Modified: sandbox/boost/numeric/bindings/lapack/trevc.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/lapack/trevc.hpp (original)
+++ sandbox/boost/numeric/bindings/lapack/trevc.hpp 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
@@ -68,7 +68,7 @@
                  int const mm, int& m, traits::complex_f* work, int& info)
       {
         LAPACK_CTREVC (&side, &howmny, select, &n, traits::complex_ptr(t), &ldt, traits::complex_ptr(vl), &ldvl,
- traits::complex_ptr(vr), &ldvr, &mm, &m, traits::complex_ptr(work+n), traits::complex_ptr(work), &info);
+ traits::complex_ptr(vr), &ldvr, &mm, &m, traits::complex_ptr(work+n), reinterpret_cast<float*>(work), &info);
       }
 
       inline
@@ -78,7 +78,7 @@
       {
         LAPACK_ZTREVC (&side, &howmny, select, &n, traits::complex_ptr(t), &ldt,
                        traits::complex_ptr(vl), &ldvl, traits::complex_ptr(vr), &ldvr,
- &mm, &m, traits::complex_ptr(work+n), traits::complex_ptr(work), &info);
+ &mm, &m, traits::complex_ptr(work+n), reinterpret_cast<double*>(work), &info);
       }
 
     }

Modified: sandbox/boost/numeric/bindings/traits/type.h
==============================================================================
--- sandbox/boost/numeric/bindings/traits/type.h (original)
+++ sandbox/boost/numeric/bindings/traits/type.h 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
@@ -17,8 +17,14 @@
 
 #ifndef BOOST_NUMERIC_BINDINGS_USE_COMPLEX_STRUCT
 
-typedef float fcomplex_t ;
-typedef double dcomplex_t ;
+#if defined(__GNUC__)
+typedef _Complex float fcomplex_t ;
+typedef _Complex double dcomplex_t ;
+#else
+#include <complex>
+typedef std::complex<float> fcomplex_t ;
+typedef std::complex<double> dcomplex_t ;
+#endif
 
 #else
 

Modified: sandbox/boost/numeric/bindings/traits/type_traits.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/traits/type_traits.hpp (original)
+++ sandbox/boost/numeric/bindings/traits/type_traits.hpp 2008-12-16 09:50:22 EST (Tue, 16 Dec 2008)
@@ -55,6 +55,9 @@
   inline fcomplex_t* complex_ptr( complex_f* c) { return reinterpret_cast< fcomplex_t*>( c ) ; }
   inline dcomplex_t* complex_ptr( complex_d* c) { return reinterpret_cast< dcomplex_t*>( c ) ; }
 
+ inline complex_f complex_ret(const fcomplex_t& ret) { return reinterpret_cast<const complex_f&>( ret ) ; }
+ inline complex_d complex_ret(const dcomplex_t& ret) { return reinterpret_cast<const complex_d&>( ret ) ; }
+
 }}}}
 
 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_TYPE_TRAITS_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk