#include <complex>
#include <iostream>
#include "blis.hh"
#include "test.hh"
using namespace blis;
using namespace std;
#define N 6
#define ALPHA 1.0
template< typename T>
void ref_axpy(int64_t n,
T * alpha,
T *X,
T *Y
)
{
obj_t obj_x, obj_y, obj_alpha;
num_t dt;
if(is_same<T, float>::value)
dt = BLIS_FLOAT;
else if(is_same<T, double>::value)
dt = BLIS_DOUBLE;
else if(is_same<T, complex<float>>::value)
dt = BLIS_SCOMPLEX;
else if(is_same<T, complex<double>>::value)
dt = BLIS_DCOMPLEX;
bli_obj_create_with_attached_buffer( dt, 1, 1, alpha, 1,1,&obj_alpha );
bli_obj_create_with_attached_buffer( dt, n, 1, X, 1, n,&obj_x );
bli_obj_create_with_attached_buffer( dt, n, 1, Y, 1, n,&obj_y );
bli_axpyv( &obj_alpha,
&obj_x,
&obj_y
);
}
template< typename T >
void test_axpy( )
{
T *X, *Y,*Y_ref;
T alpha = ALPHA;
int n;
int incx, incy;
n = N;
incx = 1;
incy = 1;
srand (time(NULL));
allocate_init_buffer(X , n , 1);
allocate_init_buffer(Y , n , 1);
copy_buffer(Y, Y_ref , n ,1);
#ifdef PRINT
printvector(X, n,(char *) "X");
printvector(Y, n, (char *) "Y");
#endif
blis::axpy(
n,
alpha,
X,
incx,
Y,
incy
);
#ifdef PRINT
printvector(Y, n,(char *) "Y output");
#endif
ref_axpy(n , &alpha , X, Y_ref );
#ifdef PRINT
printvector(Y_ref, n, (char *) "Y ref output");
#endif
if(computeErrorV(incy, incy , n, Y, Y_ref )==1)
printf("%s TEST FAIL\n" , __PRETTY_FUNCTION__);
else
printf("%s TEST PASS\n" , __PRETTY_FUNCTION__);
delete[]( X );
delete[]( Y );
delete[]( Y_ref );
}
int main( int argc, char** argv )
{
test_axpy<float>( );
test_axpy<double>( );
test_axpy<complex<float>>( );
test_axpy<complex<double>>( );
return 0;
}