aboutsummaryrefslogtreecommitdiffhomepage
path: root/blas/double.cpp
diff options
context:
space:
mode:
authorGravatar Chen-Pang He <jdh8@ms63.hinet.net>2012-09-05 18:59:32 +0800
committerGravatar Chen-Pang He <jdh8@ms63.hinet.net>2012-09-05 18:59:32 +0800
commitc86d047c2f83d335d2d126079d53d6925db01740 (patch)
tree7a3e689f071a8aaef224ccf341f428306a754563 /blas/double.cpp
parentc4051d3d024584323b20e1568d982b76a702f80c (diff)
BLAS: implement DSDOT and SDSDOT; update test for them.
Diffstat (limited to 'blas/double.cpp')
-rw-r--r--blas/double.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/blas/double.cpp b/blas/double.cpp
index cad2f63ec..9b53be484 100644
--- a/blas/double.cpp
+++ b/blas/double.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,21 @@
#include "level2_impl.h"
#include "level2_real_impl.h"
#include "level3_impl.h"
+
+// currently used by DSDOT only
+double* cast_vector_to_double(float* x, int n, int incx)
+{
+ double* ret = new double[n];
+ if(incx<0) vector(ret,n) = vector(x,n,-incx).reverse().cast<double>();
+ else vector(ret,n) = vector(x,n, incx).cast<double>();
+ return ret;
+}
+
+double BLASFUNC(dsdot)(int* n, float* px, int* incx, float* py, int* incy)
+{
+ if(*n <= 0) return 0;
+ double* x = cast_vector_to_double(px, *n, *incx);
+ double* y = cast_vector_to_double(py, *n, *incy);
+ return vector(x,*n).cwiseProduct(vector(y,*n)).sum();
+}
+