0
0
mirror of https://gitlab.com/libeigen/eigen.git synced 2026-01-18 17:31:19 +01:00

Add BLAS function axpby.

libeigen/eigen!2083
This commit is contained in:
Antonio Sánchez
2025-11-25 23:13:02 +00:00
committed by Rasmus Munk Larsen
parent a1eeb02204
commit 48eb5227c8
3 changed files with 52 additions and 4 deletions

View File

@@ -59,6 +59,19 @@ EIGEN_BLAS_API void BLASFUNC(caxpyc)(const int *, const float *, const float *,
EIGEN_BLAS_API void BLASFUNC(zaxpyc)(const int *, const double *, const double *, const int *, double *, const int *);
EIGEN_BLAS_API void BLASFUNC(xaxpyc)(const int *, const double *, const double *, const int *, double *, const int *);
EIGEN_BLAS_API void BLASFUNC(saxpby)(const int *, const float *, const float *, const int *, const float *, float *,
const int *);
EIGEN_BLAS_API void BLASFUNC(daxpby)(const int *, const double *, const double *, const int *, const double *, double *,
const int *);
EIGEN_BLAS_API void BLASFUNC(qaxpby)(const int *, const double *, const double *, const int *, const double *, double *,
const int *);
EIGEN_BLAS_API void BLASFUNC(caxpby)(const int *, const float *, const float *, const int *, const float *, float *,
const int *);
EIGEN_BLAS_API void BLASFUNC(zaxpby)(const int *, const double *, const double *, const int *, const double *, double *,
const int *);
EIGEN_BLAS_API void BLASFUNC(xaxpby)(const int *, const double *, const double *, const int *, const double *, double *,
const int *);
EIGEN_BLAS_API void BLASFUNC(scopy)(int *, float *, int *, float *, int *);
EIGEN_BLAS_API void BLASFUNC(dcopy)(int *, double *, int *, double *, int *);
EIGEN_BLAS_API void BLASFUNC(qcopy)(int *, double *, int *, double *, int *);

View File

@@ -13,6 +13,10 @@ EXPORTS
zaxpy_
; caxpyc_
; zaxpyc_
saxpby_,
daxpby_,
caxpby_,
zaxpby_,
scopy_
dcopy_
ccopy_
@@ -91,8 +95,8 @@ EXPORTS
; dmin_
; cmin_
; zmin_
; Level 2
sgemv_
dgemv_

View File

@@ -22,11 +22,42 @@ EIGEN_BLAS_FUNC(axpy)
else if (*incx > 0 && *incy > 0)
make_vector(y, *n, *incy) += alpha * make_vector(x, *n, *incx);
else if (*incx > 0 && *incy < 0)
make_vector(y, *n, -*incy).reverse() += alpha * make_vector(x, *n, *incx);
make_vector(y, *n, -*incy) += alpha * make_vector(x, *n, *incx).reverse();
else if (*incx < 0 && *incy > 0)
make_vector(y, *n, *incy) += alpha * make_vector(x, *n, -*incx).reverse();
else if (*incx < 0 && *incy < 0)
make_vector(y, *n, -*incy).reverse() += alpha * make_vector(x, *n, -*incx).reverse();
make_vector(y, *n, -*incy) += alpha * make_vector(x, *n, -*incx);
}
EIGEN_BLAS_FUNC(axpby)
(const int *pn, const RealScalar *palpha, const RealScalar *px, const int *pincx, const RealScalar *pbeta,
RealScalar *py, const int *pincy) {
const Scalar *x = reinterpret_cast<const Scalar *>(px);
Scalar *y = reinterpret_cast<Scalar *>(py);
const Scalar alpha = *reinterpret_cast<const Scalar *>(palpha);
const Scalar beta = *reinterpret_cast<const Scalar *>(pbeta);
const int n = *pn;
if (n <= 0) return;
if (Eigen::numext::equal_strict(beta, Scalar(1))) {
EIGEN_BLAS_FUNC_NAME(axpy)(pn, palpha, px, pincx, py, pincy);
return;
}
const int incx = *pincx;
const int incy = *pincy;
if (incx == 1 && incy == 1)
make_vector(y, n) = alpha * make_vector(x, n) + beta * make_vector(y, n);
else if (incx > 0 && incy > 0)
make_vector(y, n, incy) = alpha * make_vector(x, n, incx) + beta * make_vector(y, n, incy);
else if (incx > 0 && incy < 0)
make_vector(y, n, -incy) = alpha * make_vector(x, n, incx).reverse() + beta * make_vector(y, n, -incy);
else if (incx < 0 && incy > 0)
make_vector(y, n, incy) = alpha * make_vector(x, n, -incx).reverse() + beta * make_vector(y, n, incy);
else if (incx < 0 && incy < 0)
make_vector(y, n, -incy) = alpha * make_vector(x, n, -incx) + beta * make_vector(y, n, -incy);
}
EIGEN_BLAS_FUNC(copy)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy) {