aboutsummaryrefslogtreecommitdiffhomepage
path: root/blas/level1_cplx_impl.h
diff options
context:
space:
mode:
authorGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2019-04-15 17:18:03 +0200
committerGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2019-04-15 17:18:03 +0200
commit4270c62812016c71db82e4d780108bb3b7c0d539 (patch)
treea25c1e600f68f93413fe64d331fd69858de41109 /blas/level1_cplx_impl.h
parent039ee521250eab33e9f7aadc5ba2baef9661673c (diff)
Split the implementation of i?amax/min into two. Based on PR-627 by Sameer Agarwal.
Like the Netlib reference implementation, I*AMAX now uses the L1-norm instead of the L2-norm for each element. Changed I*MIN accordingly.
Diffstat (limited to 'blas/level1_cplx_impl.h')
-rw-r--r--blas/level1_cplx_impl.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/blas/level1_cplx_impl.h b/blas/level1_cplx_impl.h
index 4ac457175..6c7edd7eb 100644
--- a/blas/level1_cplx_impl.h
+++ b/blas/level1_cplx_impl.h
@@ -36,6 +36,28 @@ RealScalar EIGEN_CAT(REAL_SCALAR_SUFFIX, EIGEN_BLAS_FUNC(asum))(int *n, RealScal
else return make_vector(x,*n,std::abs(*incx)).unaryExpr<scalar_norm1_op>().sum();
}
+int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amax))(int *n, RealScalar *px, int *incx)
+{
+ if(*n<=0) return 0;
+ Scalar* x = reinterpret_cast<Scalar*>(px);
+
+ DenseIndex ret;
+ if(*incx==1) make_vector(x,*n).unaryExpr<scalar_norm1_op>().maxCoeff(&ret);
+ else make_vector(x,*n,std::abs(*incx)).unaryExpr<scalar_norm1_op>().maxCoeff(&ret);
+ return int(ret)+1;
+}
+
+int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amin))(int *n, RealScalar *px, int *incx)
+{
+ if(*n<=0) return 0;
+ Scalar* x = reinterpret_cast<Scalar*>(px);
+
+ DenseIndex ret;
+ if(*incx==1) make_vector(x,*n).unaryExpr<scalar_norm1_op>().minCoeff(&ret);
+ else make_vector(x,*n,std::abs(*incx)).unaryExpr<scalar_norm1_op>().minCoeff(&ret);
+ return int(ret)+1;
+}
+
// 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)
{