diff options
author | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-10 18:25:30 +0800 |
---|---|---|
committer | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-10 18:25:30 +0800 |
commit | 04f315d692d4b2b01635981d34b44743ba63571c (patch) | |
tree | 91874d6be16cd2a443322f3e12e08c315bf69f5a /blas/level2_cplx_impl.h | |
parent | 65caa40a3d792dbbd28b3f47de2a87efea58bb24 (diff) |
Fix rank-1 update for self-adjoint packed matrices.
Diffstat (limited to 'blas/level2_cplx_impl.h')
-rw-r--r-- | blas/level2_cplx_impl.h | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/blas/level2_cplx_impl.h b/blas/level2_cplx_impl.h index 11ee13b4c..f52d384a9 100644 --- a/blas/level2_cplx_impl.h +++ b/blas/level2_cplx_impl.h @@ -108,10 +108,49 @@ int EIGEN_BLAS_FUNC(hemv)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa * where alpha is a real scalar, x is an n element vector and A is an * n by n hermitian matrix, supplied in packed form. */ -// int EIGEN_BLAS_FUNC(hpr)(char *uplo, int *n, RealScalar *alpha, RealScalar *x, int *incx, RealScalar *ap) -// { -// return 1; -// } +int EIGEN_BLAS_FUNC(hpr)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *pap) +{ + typedef void (*functype)(int, Scalar*, const Scalar*, RealScalar); + static functype func[2]; + + static bool init = false; + if(!init) + { + for(int k=0; k<2; ++k) + func[k] = 0; + + func[UP] = (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Upper,false,Conj>::run); + func[LO] = (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Lower,false,Conj>::run); + + init = true; + } + + Scalar* x = reinterpret_cast<Scalar*>(px); + Scalar* ap = reinterpret_cast<Scalar*>(pap); + RealScalar alpha = *palpha; + + int info = 0; + if(UPLO(*uplo)==INVALID) info = 1; + else if(*n<0) info = 2; + else if(*incx==0) info = 5; + if(info) + return xerbla_(SCALAR_SUFFIX_UP"HPR ",&info,6); + + if(alpha==Scalar(0)) + return 1; + + Scalar* x_cpy = get_compact_vector(x, *n, *incx); + + int code = UPLO(*uplo); + if(code>=2 || func[code]==0) + return 0; + + func[code](*n, ap, x_cpy, alpha); + + if(x_cpy!=x) delete[] x_cpy; + + return 1; +} /** ZHPR2 performs the hermitian rank 2 operation * |