aboutsummaryrefslogtreecommitdiffhomepage
path: root/blas/level2_real_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'blas/level2_real_impl.h')
-rw-r--r--blas/level2_real_impl.h162
1 files changed, 50 insertions, 112 deletions
diff --git a/blas/level2_real_impl.h b/blas/level2_real_impl.h
index cac89b268..7620f0a38 100644
--- a/blas/level2_real_impl.h
+++ b/blas/level2_real_impl.h
@@ -10,28 +10,22 @@
#include "common.h"
// y = alpha*A*x + beta*y
-int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *pa, int *lda, RealScalar *px, int *incx, RealScalar *pbeta, RealScalar *py, int *incy)
+int EIGEN_BLAS_FUNC(symv) (const char *uplo, const int *n, const RealScalar *palpha, const RealScalar *pa, const int *lda,
+ const RealScalar *px, const int *incx, const RealScalar *pbeta, RealScalar *py, const int *incy)
{
typedef void (*functype)(int, const Scalar*, int, const Scalar*, Scalar*, Scalar);
- static functype func[2];
-
- static bool init = false;
- if(!init)
- {
- for(int k=0; k<2; ++k)
- func[k] = 0;
-
- func[UP] = (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Upper,false,false>::run);
- func[LO] = (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Lower,false,false>::run);
-
- init = true;
- }
-
- Scalar* a = reinterpret_cast<Scalar*>(pa);
- Scalar* x = reinterpret_cast<Scalar*>(px);
+ static const functype func[2] = {
+ // array index: UP
+ (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Upper,false,false>::run),
+ // array index: LO
+ (internal::selfadjoint_matrix_vector_product<Scalar,int,ColMajor,Lower,false,false>::run),
+ };
+
+ const Scalar* a = reinterpret_cast<const Scalar*>(pa);
+ const Scalar* x = reinterpret_cast<const Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py);
- Scalar alpha = *reinterpret_cast<Scalar*>(palpha);
- Scalar beta = *reinterpret_cast<Scalar*>(pbeta);
+ Scalar alpha = *reinterpret_cast<const Scalar*>(palpha);
+ Scalar beta = *reinterpret_cast<const Scalar*>(pbeta);
// check arguments
int info = 0;
@@ -46,7 +40,7 @@ int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *p
if(*n==0)
return 0;
- Scalar* actual_x = get_compact_vector(x,*n,*incx);
+ const Scalar* actual_x = get_compact_vector(x,*n,*incx);
Scalar* actual_y = get_compact_vector(y,*n,*incy);
if(beta!=Scalar(1))
@@ -68,41 +62,20 @@ int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *p
}
// C := alpha*x*x' + C
-int EIGEN_BLAS_FUNC(syr)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *pc, int *ldc)
+int EIGEN_BLAS_FUNC(syr)(const char *uplo, const int *n, const RealScalar *palpha, const RealScalar *px, const int *incx, RealScalar *pc, const int *ldc)
{
-// typedef void (*functype)(int, const Scalar *, int, Scalar *, int, Scalar);
-// static functype func[2];
-
-// static bool init = false;
-// if(!init)
-// {
-// for(int k=0; k<2; ++k)
-// func[k] = 0;
-//
-// func[UP] = (internal::selfadjoint_product<Scalar,ColMajor,ColMajor,false,UpperTriangular>::run);
-// func[LO] = (internal::selfadjoint_product<Scalar,ColMajor,ColMajor,false,LowerTriangular>::run);
-
-// init = true;
-// }
typedef void (*functype)(int, Scalar*, int, const Scalar*, const Scalar*, const Scalar&);
- static functype func[2];
-
- static bool init = false;
- if(!init)
- {
- for(int k=0; k<2; ++k)
- func[k] = 0;
-
- func[UP] = (selfadjoint_rank1_update<Scalar,int,ColMajor,Upper,false,Conj>::run);
- func[LO] = (selfadjoint_rank1_update<Scalar,int,ColMajor,Lower,false,Conj>::run);
-
- init = true;
- }
-
- Scalar* x = reinterpret_cast<Scalar*>(px);
+ static const functype func[2] = {
+ // array index: UP
+ (selfadjoint_rank1_update<Scalar,int,ColMajor,Upper,false,Conj>::run),
+ // array index: LO
+ (selfadjoint_rank1_update<Scalar,int,ColMajor,Lower,false,Conj>::run),
+ };
+
+ const Scalar* x = reinterpret_cast<const Scalar*>(px);
Scalar* c = reinterpret_cast<Scalar*>(pc);
- Scalar alpha = *reinterpret_cast<Scalar*>(palpha);
+ Scalar alpha = *reinterpret_cast<const Scalar*>(palpha);
int info = 0;
if(UPLO(*uplo)==INVALID) info = 1;
@@ -115,7 +88,7 @@ int EIGEN_BLAS_FUNC(syr)(char *uplo, int *n, RealScalar *palpha, RealScalar *px,
if(*n==0 || alpha==Scalar(0)) return 1;
// if the increment is not 1, let's copy it to a temporary vector to enable vectorization
- Scalar* x_cpy = get_compact_vector(x,*n,*incx);
+ const Scalar* x_cpy = get_compact_vector(x,*n,*incx);
int code = UPLO(*uplo);
if(code>=2 || func[code]==0)
@@ -129,41 +102,20 @@ int EIGEN_BLAS_FUNC(syr)(char *uplo, int *n, RealScalar *palpha, RealScalar *px,
}
// C := alpha*x*y' + alpha*y*x' + C
-int EIGEN_BLAS_FUNC(syr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, int *ldc)
+int EIGEN_BLAS_FUNC(syr2)(const char *uplo, const int *n, const RealScalar *palpha, const RealScalar *px, const int *incx, const RealScalar *py, const int *incy, RealScalar *pc, const int *ldc)
{
-// typedef void (*functype)(int, const Scalar *, int, const Scalar *, int, Scalar *, int, Scalar);
-// static functype func[2];
-//
-// static bool init = false;
-// if(!init)
-// {
-// for(int k=0; k<2; ++k)
-// func[k] = 0;
-//
-// func[UP] = (internal::selfadjoint_product<Scalar,ColMajor,ColMajor,false,UpperTriangular>::run);
-// func[LO] = (internal::selfadjoint_product<Scalar,ColMajor,ColMajor,false,LowerTriangular>::run);
-//
-// init = true;
-// }
typedef void (*functype)(int, Scalar*, int, const Scalar*, const Scalar*, Scalar);
- static functype func[2];
-
- static bool init = false;
- if(!init)
- {
- for(int k=0; k<2; ++k)
- func[k] = 0;
-
- func[UP] = (internal::rank2_update_selector<Scalar,int,Upper>::run);
- func[LO] = (internal::rank2_update_selector<Scalar,int,Lower>::run);
-
- init = true;
- }
-
- Scalar* x = reinterpret_cast<Scalar*>(px);
- Scalar* y = reinterpret_cast<Scalar*>(py);
+ static const functype func[2] = {
+ // array index: UP
+ (internal::rank2_update_selector<Scalar,int,Upper>::run),
+ // array index: LO
+ (internal::rank2_update_selector<Scalar,int,Lower>::run),
+ };
+
+ const Scalar* x = reinterpret_cast<const Scalar*>(px);
+ const Scalar* y = reinterpret_cast<const Scalar*>(py);
Scalar* c = reinterpret_cast<Scalar*>(pc);
- Scalar alpha = *reinterpret_cast<Scalar*>(palpha);
+ Scalar alpha = *reinterpret_cast<const Scalar*>(palpha);
int info = 0;
if(UPLO(*uplo)==INVALID) info = 1;
@@ -177,8 +129,8 @@ int EIGEN_BLAS_FUNC(syr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *px
if(alpha==Scalar(0))
return 1;
- Scalar* x_cpy = get_compact_vector(x,*n,*incx);
- Scalar* y_cpy = get_compact_vector(y,*n,*incy);
+ const Scalar* x_cpy = get_compact_vector(x,*n,*incx);
+ const Scalar* y_cpy = get_compact_vector(y,*n,*incy);
int code = UPLO(*uplo);
if(code>=2 || func[code]==0)
@@ -234,19 +186,12 @@ int EIGEN_BLAS_FUNC(syr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *px
int EIGEN_BLAS_FUNC(spr)(char *uplo, int *n, Scalar *palpha, Scalar *px, int *incx, Scalar *pap)
{
typedef void (*functype)(int, Scalar*, const Scalar*, Scalar);
- static functype func[2];
-
- static bool init = false;
- if(!init)
- {
- for(int k=0; k<2; ++k)
- func[k] = 0;
-
- func[UP] = (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Upper,false,false>::run);
- func[LO] = (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Lower,false,false>::run);
-
- init = true;
- }
+ static const functype func[2] = {
+ // array index: UP
+ (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Upper,false,false>::run),
+ // array index: LO
+ (internal::selfadjoint_packed_rank1_update<Scalar,int,ColMajor,Lower,false,false>::run),
+ };
Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* ap = reinterpret_cast<Scalar*>(pap);
@@ -285,19 +230,12 @@ int EIGEN_BLAS_FUNC(spr)(char *uplo, int *n, Scalar *palpha, Scalar *px, int *in
int EIGEN_BLAS_FUNC(spr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pap)
{
typedef void (*functype)(int, Scalar*, const Scalar*, const Scalar*, Scalar);
- static functype func[2];
-
- static bool init = false;
- if(!init)
- {
- for(int k=0; k<2; ++k)
- func[k] = 0;
-
- func[UP] = (internal::packed_rank2_update_selector<Scalar,int,Upper>::run);
- func[LO] = (internal::packed_rank2_update_selector<Scalar,int,Lower>::run);
-
- init = true;
- }
+ static const functype func[2] = {
+ // array index: UP
+ (internal::packed_rank2_update_selector<Scalar,int,Upper>::run),
+ // array index: LO
+ (internal::packed_rank2_update_selector<Scalar,int,Lower>::run),
+ };
Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py);