From e14f14642d6101f94274459cfd499d2ec28925e4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 19 Nov 2010 16:09:25 +0100 Subject: implement SYR and SYR2 --- blas/level2_impl.h | 143 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 99 insertions(+), 44 deletions(-) (limited to 'blas/level2_impl.h') diff --git a/blas/level2_impl.h b/blas/level2_impl.h index 55851ddb3..2dc059c14 100644 --- a/blas/level2_impl.h +++ b/blas/level2_impl.h @@ -204,70 +204,125 @@ int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *p // TODO } -int EIGEN_BLAS_FUNC(syr)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa, int *inca, RealScalar *pc, int *ldc) +// C := alpha*x*x' + C +int EIGEN_BLAS_FUNC(syr)(char *uplo, int *n, RealScalar *palpha, RealScalar *px, int *incx, RealScalar *pc, int *ldc) { - return 0; - - // TODO - typedef void (*functype)(int, const Scalar *, int, Scalar *, int, Scalar); - functype func[2]; - - static bool init = false; - if(!init) - { - for(int k=0; k<2; ++k) - func[k] = 0; - + +// typedef void (*functype)(int, const Scalar *, int, Scalar *, int, Scalar); +// functype func[2]; + +// static bool init = false; +// if(!init) +// { +// for(int k=0; k<2; ++k) +// func[k] = 0; +// // func[UP] = (internal::selfadjoint_product::run); // func[LO] = (internal::selfadjoint_product::run); - init = true; - } +// init = true; +// } - Scalar* a = reinterpret_cast(pa); + Scalar* x = reinterpret_cast(px); Scalar* c = reinterpret_cast(pc); Scalar alpha = *reinterpret_cast(palpha); + + int info = 0; + if(UPLO(*uplo)==INVALID) info = 1; + else if(*n<0) info = 2; + else if(*incx==0) info = 5; + else if(*ldc().rankUpdate(vector(x_cpy,*n), alpha); + else if(UPLO(*uplo)==UP) matrix(c,*n,*n,*ldc).selfadjointView().rankUpdate(vector(x_cpy,*n), alpha); + + if(*incx!=1) + delete[] x_cpy; - int code = UPLO(*uplo); - if(code>=2 || func[code]==0) - return 0; - - func[code](*n, a, *inca, c, *ldc, alpha); +// func[code](*n, a, *inca, c, *ldc, alpha); return 1; } - -int EIGEN_BLAS_FUNC(syr2)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa, int *inca, RealScalar *pb, int *incb, RealScalar *pc, int *ldc) +// 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) { - return 0; - - // TODO - typedef void (*functype)(int, const Scalar *, int, const Scalar *, int, Scalar *, int, Scalar); - functype func[2]; - - static bool init = false; - if(!init) - { - for(int k=0; k<2; ++k) - func[k] = 0; - +// typedef void (*functype)(int, const Scalar *, int, const Scalar *, int, Scalar *, int, Scalar); +// functype func[2]; +// +// static bool init = false; +// if(!init) +// { +// for(int k=0; k<2; ++k) +// func[k] = 0; +// // func[UP] = (internal::selfadjoint_product::run); // func[LO] = (internal::selfadjoint_product::run); +// +// init = true; +// } - init = true; - } - - Scalar* a = reinterpret_cast(pa); - Scalar* b = reinterpret_cast(pb); + Scalar* x = reinterpret_cast(px); + Scalar* y = reinterpret_cast(py); Scalar* c = reinterpret_cast(pc); Scalar alpha = *reinterpret_cast(palpha); + + int info = 0; + if(UPLO(*uplo)==INVALID) info = 1; + else if(*n<0) info = 2; + else if(*incx==0) info = 5; + else if(*incy==0) info = 7; + else if(*ldc().rankUpdate(vector(x_cpy,*n), vector(y_cpy,*n), alpha); + else if(UPLO(*uplo)==UP) matrix(c,*n,*n,*ldc).selfadjointView().rankUpdate(vector(x_cpy,*n), vector(y_cpy,*n), alpha); + + if(*incx!=1) delete[] x_cpy; + if(*incy!=1) delete[] y_cpy; - int code = UPLO(*uplo); - if(code>=2 || func[code]==0) - return 0; +// int code = UPLO(*uplo); +// if(code>=2 || func[code]==0) +// return 0; - func[code](*n, a, *inca, b, *incb, c, *ldc, alpha); +// func[code](*n, a, *inca, b, *incb, c, *ldc, alpha); return 1; } -- cgit v1.2.3