diff options
author | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-05 18:59:32 +0800 |
---|---|---|
committer | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-05 18:59:32 +0800 |
commit | c86d047c2f83d335d2d126079d53d6925db01740 (patch) | |
tree | 7a3e689f071a8aaef224ccf341f428306a754563 /blas/single.cpp | |
parent | c4051d3d024584323b20e1568d982b76a702f80c (diff) |
BLAS: implement DSDOT and SDSDOT; update test for them.
Diffstat (limited to 'blas/single.cpp')
-rw-r--r-- | blas/single.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/blas/single.cpp b/blas/single.cpp index 1b7775aed..d549a906e 100644 --- a/blas/single.cpp +++ b/blas/single.cpp @@ -2,6 +2,7 @@ // for linear algebra. // // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr> +// Copyright (C) 2012 Chen-Pang He <jdh8@ms63.hinet.net> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed @@ -17,3 +18,19 @@ #include "level2_impl.h" #include "level2_real_impl.h" #include "level3_impl.h" + +float BLASFUNC(sdsdot)(int* n, float* alpha, float* px, int* incx, float* py, int* incy) +{ + float* x = reinterpret_cast<float*>(px); + float* y = reinterpret_cast<float*>(py); + float ret = *alpha; + + if(*n>0) { + if(*incx==1 && *incy==1) ret += (vector(x,*n).cwiseProduct(vector(y,*n))).sum(); + else if(*incx>0 && *incy>0) ret += (vector(x,*n,*incx).cwiseProduct(vector(y,*n,*incy))).sum(); + else if(*incx<0 && *incy>0) ret += (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,*incy))).sum(); + else if(*incx>0 && *incy<0) ret += (vector(x,*n,*incx).cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); + else if(*incx<0 && *incy<0) ret += (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); + } + return ret; +} |