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_real_impl.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'blas/level1_real_impl.h') diff --git a/blas/level1_real_impl.h b/blas/level1_real_impl.h index 02586d519..c58771125 100644 --- a/blas/level1_real_impl.h +++ b/blas/level1_real_impl.h @@ -23,6 +23,28 @@ RealScalar EIGEN_BLAS_FUNC(asum)(int *n, RealScalar *px, int *incx) else return make_vector(x,*n,std::abs(*incx)).cwiseAbs().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).cwiseAbs().maxCoeff(&ret); + else make_vector(x,*n,std::abs(*incx)).cwiseAbs().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).cwiseAbs().minCoeff(&ret); + else make_vector(x,*n,std::abs(*incx)).cwiseAbs().minCoeff(&ret); + return int(ret)+1; +} + // computes a vector-vector dot product. Scalar EIGEN_BLAS_FUNC(dot)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy) { -- cgit v1.2.3