From 4270c62812016c71db82e4d780108bb3b7c0d539 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Mon, 15 Apr 2019 17:18:03 +0200 Subject: 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. --- blas/level1_cplx_impl.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'blas/level1_cplx_impl.h') 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().sum(); } +int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amax))(int *n, RealScalar *px, int *incx) +{ + if(*n<=0) return 0; + Scalar* x = reinterpret_cast(px); + + DenseIndex ret; + if(*incx==1) make_vector(x,*n).unaryExpr().maxCoeff(&ret); + else make_vector(x,*n,std::abs(*incx)).unaryExpr().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(px); + + DenseIndex ret; + if(*incx==1) make_vector(x,*n).unaryExpr().minCoeff(&ret); + else make_vector(x,*n,std::abs(*incx)).unaryExpr().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) { -- cgit v1.2.3