aboutsummaryrefslogtreecommitdiffhomepage
path: root/blas/level2_cplx_impl.h
diff options
context:
space:
mode:
authorGravatar Chen-Pang He <jdh8@ms63.hinet.net>2012-09-08 17:29:44 +0800
committerGravatar Chen-Pang He <jdh8@ms63.hinet.net>2012-09-08 17:29:44 +0800
commite4e7585a24a4ef08742b4c198ab6e37e93eececf (patch)
tree66cdac8952a48b9d6a25e8222b41e0a5b309ba46 /blas/level2_cplx_impl.h
parentb5f9bec8ac2771abbd74e7abd03734d578a88e80 (diff)
Implement rank-2 update for packed matrices.
Diffstat (limited to 'blas/level2_cplx_impl.h')
-rw-r--r--blas/level2_cplx_impl.h51
1 files changed, 47 insertions, 4 deletions
diff --git a/blas/level2_cplx_impl.h b/blas/level2_cplx_impl.h
index 8ab3cb638..46bddc134 100644
--- a/blas/level2_cplx_impl.h
+++ b/blas/level2_cplx_impl.h
@@ -120,10 +120,53 @@ int EIGEN_BLAS_FUNC(hemv)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa
* where alpha is a scalar, x and y are n element vectors and A is an
* n by n hermitian matrix, supplied in packed form.
*/
-// int EIGEN_BLAS_FUNC(hpr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *x, int *incx, RealScalar *y, int *incy, RealScalar *ap)
-// {
-// return 1;
-// }
+int EIGEN_BLAS_FUNC(hpr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pap)
+{
+ typedef void (*functype)(int, Scalar*, const Scalar*, const 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::packed_rank2_update_selector<Scalar,int,Upper>::run);
+ func[LO] = (internal::packed_rank2_update_selector<Scalar,int,Lower>::run);
+
+ init = true;
+ }
+
+ Scalar* x = reinterpret_cast<Scalar*>(px);
+ Scalar* y = reinterpret_cast<Scalar*>(py);
+ Scalar* ap = reinterpret_cast<Scalar*>(pap);
+ Scalar alpha = *reinterpret_cast<Scalar*>(palpha);
+
+ int info = 0;
+ if(UPLO(*uplo)==INVALID) info = 1;
+ else if(*n<0) info = 2;
+ else if(*incx==0) info = 5;
+ else if(*incy==0) info = 7;
+ if(info)
+ return xerbla_(SCALAR_SUFFIX_UP"HPR2 ",&info,6);
+
+ if(alpha==Scalar(0))
+ return 1;
+
+ Scalar* x_cpy = get_compact_vector(x, *n, *incx);
+ Scalar* y_cpy = get_compact_vector(y, *n, *incy);
+
+ int code = UPLO(*uplo);
+ if(code>=2 || func[code]==0)
+ return 0;
+
+ func[code](*n, ap, x_cpy, y_cpy, alpha);
+
+ if(x_cpy!=x) delete[] x_cpy;
+ if(y_cpy!=y) delete[] y_cpy;
+
+ return 1;
+}
/** ZHER performs the hermitian rank 1 operation
*