mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Fix memory leak in DSDOT.
This commit is contained in:
parent
c86d047c2f
commit
145f89cd5f
@ -31,8 +31,13 @@ double* cast_vector_to_double(float* x, int n, int incx)
|
|||||||
double BLASFUNC(dsdot)(int* n, float* px, int* incx, float* py, int* incy)
|
double BLASFUNC(dsdot)(int* n, float* px, int* incx, float* py, int* incy)
|
||||||
{
|
{
|
||||||
if(*n <= 0) return 0;
|
if(*n <= 0) return 0;
|
||||||
|
|
||||||
double* x = cast_vector_to_double(px, *n, *incx);
|
double* x = cast_vector_to_double(px, *n, *incx);
|
||||||
double* y = cast_vector_to_double(py, *n, *incy);
|
double* y = cast_vector_to_double(py, *n, *incy);
|
||||||
return vector(x,*n).cwiseProduct(vector(y,*n)).sum();
|
double res = vector(x,*n).cwiseProduct(vector(y,*n)).sum();
|
||||||
|
|
||||||
|
delete[] x;
|
||||||
|
delete[] y;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,18 +19,16 @@
|
|||||||
#include "level2_real_impl.h"
|
#include "level2_real_impl.h"
|
||||||
#include "level3_impl.h"
|
#include "level3_impl.h"
|
||||||
|
|
||||||
float BLASFUNC(sdsdot)(int* n, float* alpha, float* px, int* incx, float* py, int* incy)
|
float BLASFUNC(sdsdot)(int* n, float* alpha, float* x, int* incx, float* y, int* incy)
|
||||||
{
|
{
|
||||||
float* x = reinterpret_cast<float*>(px);
|
float res = *alpha;
|
||||||
float* y = reinterpret_cast<float*>(py);
|
|
||||||
float ret = *alpha;
|
|
||||||
|
|
||||||
if(*n>0) {
|
if(*n>0) {
|
||||||
if(*incx==1 && *incy==1) ret += (vector(x,*n).cwiseProduct(vector(y,*n))).sum();
|
if(*incx==1 && *incy==1) res += (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) res += (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) res += (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) res += (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();
|
else if(*incx<0 && *incy<0) res += (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,-*incy).reverse())).sum();
|
||||||
}
|
}
|
||||||
return ret;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user