2015-01-23 03:38:24 +03:00
|
|
|
#include "blas.h"
|
2015-07-10 01:22:14 +03:00
|
|
|
#include "math.h"
|
|
|
|
|
|
|
|
void const_cpu(int N, float ALPHA, float *X, int INCX)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) X[i*INCX] = ALPHA;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mul_cpu(int N, float *X, int INCX, float *Y, int INCY)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) Y[i*INCY] *= X[i*INCX];
|
|
|
|
}
|
|
|
|
|
|
|
|
void pow_cpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) Y[i*INCY] = pow(X[i*INCX], ALPHA);
|
|
|
|
}
|
2015-01-23 03:38:24 +03:00
|
|
|
|
|
|
|
void axpy_cpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) Y[i*INCY] += ALPHA*X[i*INCX];
|
|
|
|
}
|
|
|
|
|
|
|
|
void scal_cpu(int N, float ALPHA, float *X, int INCX)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) X[i*INCX] *= ALPHA;
|
|
|
|
}
|
|
|
|
|
|
|
|
void copy_cpu(int N, float *X, int INCX, float *Y, int INCY)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < N; ++i) Y[i*INCY] = X[i*INCX];
|
|
|
|
}
|
|
|
|
|
|
|
|
float dot_cpu(int N, float *X, int INCX, float *Y, int INCY)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float dot = 0;
|
|
|
|
for(i = 0; i < N; ++i) dot += X[i*INCX] * Y[i*INCY];
|
|
|
|
return dot;
|
|
|
|
}
|
|
|
|
|