diff options
author | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-08 15:47:33 +0800 |
---|---|---|
committer | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-08 15:47:33 +0800 |
commit | b5f9bec8ac2771abbd74e7abd03734d578a88e80 (patch) | |
tree | 4440c3d14036ab9122173f73e3705710aefe5d96 /blas | |
parent | 1b61aadcbe0f3d8c6898d28b7605347a7643190d (diff) |
Perform direct calls in xHEMV and xSYMV.
Diffstat (limited to 'blas')
-rw-r--r-- | blas/level2_cplx_impl.h | 23 | ||||
-rw-r--r-- | blas/level2_real_impl.h | 23 |
2 files changed, 40 insertions, 6 deletions
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<Scalar,int,ColMajor,Upper,false,false>::run); + func[LO] = (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Lower,false,false>::run); + + init = true; + } + Scalar* a = reinterpret_cast<Scalar*>(pa); Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* y = reinterpret_cast<Scalar*>(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<Upper>() * (alpha * vector(actual_x,*n)); - else if(UPLO(*uplo)==LO) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView<Lower>() * (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<Scalar,int,ColMajor,Upper,false,false>::run); + func[LO] = (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Lower,false,false>::run); + + init = true; + } + Scalar* a = reinterpret_cast<Scalar*>(pa); Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* y = reinterpret_cast<Scalar*>(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<Upper>() * (alpha * vector(actual_x,*n)); - else if(UPLO(*uplo)==LO) vector(actual_y,*n).noalias() += matrix(a,*n,*n,*lda).selfadjointView<Lower>() * (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); |