aboutsummaryrefslogtreecommitdiffhomepage
path: root/blas
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-10-01 22:37:10 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-10-01 22:37:10 +0200
commit446320b226c152ced3e42dbff08049a3f82ffee7 (patch)
treef3ff34ee57459e06f4f2716ca861ac84c0186967 /blas
parent54e576c88af67aa2c8a66d95a104a4ffc5fd1985 (diff)
Fix dot*w to return 0 for empty vectors (BLAS interface)
Diffstat (limited to 'blas')
-rw-r--r--blas/level1_cplx_impl.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/blas/level1_cplx_impl.h b/blas/level1_cplx_impl.h
index 283b9f827..ffe192481 100644
--- a/blas/level1_cplx_impl.h
+++ b/blas/level1_cplx_impl.h
@@ -39,13 +39,16 @@ RealScalar EIGEN_CAT(EIGEN_CAT(REAL_SCALAR_SUFFIX,SCALAR_SUFFIX),asum_)(int *n,
// computes a dot product of a conjugated vector with another vector.
int EIGEN_BLAS_FUNC(dotcw)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar* pres)
{
-// std::cerr << "_dotc " << *n << " " << *incx << " " << *incy << "\n";
+ Scalar* res = reinterpret_cast<Scalar*>(pres);
- if(*n<=0) return 0;
+ if(*n<=0)
+ {
+ *res = Scalar(0);
+ return 0;
+ }
Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py);
- Scalar* res = reinterpret_cast<Scalar*>(pres);
if(*incx==1 && *incy==1) *res = (vector(x,*n).dot(vector(y,*n)));
else if(*incx>0 && *incy>0) *res = (vector(x,*n,*incx).dot(vector(y,*n,*incy)));
@@ -58,13 +61,16 @@ int EIGEN_BLAS_FUNC(dotcw)(int *n, RealScalar *px, int *incx, RealScalar *py, in
// computes a vector-vector dot product without complex conjugation.
int EIGEN_BLAS_FUNC(dotuw)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar* pres)
{
-// std::cerr << "_dotu " << *n << " " << *incx << " " << *incy << "\n";
+ Scalar* res = reinterpret_cast<Scalar*>(pres);
- if(*n<=0) return 0;
+ if(*n<=0)
+ {
+ *res = Scalar(0);
+ return 0;
+ }
Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py);
- Scalar* res = reinterpret_cast<Scalar*>(pres);
if(*incx==1 && *incy==1) *res = (vector(x,*n).cwiseProduct(vector(y,*n))).sum();
else if(*incx>0 && *incy>0) *res = (vector(x,*n,*incx).cwiseProduct(vector(y,*n,*incy))).sum();