From b5f9bec8ac2771abbd74e7abd03734d578a88e80 Mon Sep 17 00:00:00 2001 From: Chen-Pang He Date: Sat, 8 Sep 2012 15:47:33 +0800 Subject: Perform direct calls in xHEMV and xSYMV. --- blas/level2_cplx_impl.h | 23 ++++++++++++++++++++--- blas/level2_real_impl.h | 23 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'blas') diff --git a/blas/level2_cplx_impl.h b/blas/level2_cplx_impl.h index 477f6d649..8ab3cb638 100644 --- a/blas/level2_cplx_impl.h +++ b/blas/level2_cplx_impl.h @@ -18,6 +18,21 @@ */ int EIGEN_BLAS_FUNC(hemv)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa, int *lda, RealScalar *px, int *incx, RealScalar *pbeta, RealScalar *py, int *incy) { + typedef void (*functype)(int, const Scalar*, int, const Scalar*, int, Scalar*, Scalar); + static functype func[2]; + + static bool init = false; + if(!init) + { + for(int k=0; k<2; ++k) + func[k] = 0; + + func[UP] = (internal::selfadjoint_matrix_vector_product::run); + func[LO] = (internal::selfadjoint_matrix_vector_product::run); + + init = true; + } + Scalar* a = reinterpret_cast(pa); Scalar* x = reinterpret_cast(px); Scalar* y = reinterpret_cast(py); @@ -48,9 +63,11 @@ int EIGEN_BLAS_FUNC(hemv)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa if(alpha!=Scalar(0)) { - // TODO performs a direct call to the underlying implementation function - if(UPLO(*uplo)==UP) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView() * (alpha * vector(actual_x,*n)); - else if(UPLO(*uplo)==LO) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView() * (alpha * vector(actual_x,*n)); + int code = UPLO(*uplo); + if(code>=2 || func[code]==0) + return 0; + + func[code](*n, a, *lda, actual_x, 1, actual_y, alpha); } if(actual_x!=x) delete[] actual_x; diff --git a/blas/level2_real_impl.h b/blas/level2_real_impl.h index 06da283d3..e2575d30a 100644 --- a/blas/level2_real_impl.h +++ b/blas/level2_real_impl.h @@ -12,6 +12,21 @@ // y = alpha*A*x + beta*y int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *pa, int *lda, RealScalar *px, int *incx, RealScalar *pbeta, RealScalar *py, int *incy) { + typedef void (*functype)(int, const Scalar*, int, const Scalar*, int, Scalar*, Scalar); + static functype func[2]; + + static bool init = false; + if(!init) + { + for(int k=0; k<2; ++k) + func[k] = 0; + + func[UP] = (internal::selfadjoint_matrix_vector_product::run); + func[LO] = (internal::selfadjoint_matrix_vector_product::run); + + init = true; + } + Scalar* a = reinterpret_cast(pa); Scalar* x = reinterpret_cast(px); Scalar* y = reinterpret_cast(py); @@ -40,9 +55,11 @@ int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *p else vector(actual_y, *n) *= beta; } - // TODO performs a direct call to the underlying implementation function - if(UPLO(*uplo)==UP) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView() * (alpha * vector(actual_x,*n)); - else if(UPLO(*uplo)==LO) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView() * (alpha * vector(actual_x,*n)); + int code = UPLO(*uplo); + if(code>=2 || func[code]==0) + return 0; + + func[code](*n, a, *lda, actual_x, 1, actual_y, alpha); if(actual_x!=x) delete[] actual_x; if(actual_y!=y) delete[] copy_back(actual_y,y,*n,*incy); -- cgit v1.2.3