Exemplo n.º 1
0
/* 
 * INPUT
 *  alpha
 *  mat [n1, n2]
 *  x [n2]
 *  beta
 * OUTPUT
 *  y [n1] = alpha * mat [n1, n2] . x [n2] + beta * y[]
 */
void
dot_prod_matrix_ (double alpha, const double *mat, int n1, int n2,
		  const double *x,
		  double beta, double *y)
{
#ifdef HAVE_CBLAS_H
  /* use ATLAS' CBLAS routines */
  cblas_dgemv (CblasRowMajor, CblasNoTrans,
	       n1, n2,
	       alpha, mat, n2,
	       x, 1,
	       beta, y, 1);

#else // !HAVE_CBLAS_H
# ifdef HAVE_BLAS_H
  /* use Fortran BLAS routines */
  dgemv_wrap (n1, n2,
	      alpha, mat,
	      x,
	      beta, y);

# else // !HAVE_BLAS_H
  /* use local BLAS routines */
  my_dgemv (n1, n2,
	    alpha, mat, n2,
	    x, 1,
	    beta, y, 1);

# endif // !HAVE_BLAS_H
#endif // !HAVE_CBLAS_H
}
Exemplo n.º 2
0
void test_dgemv_trans2()
{
    const size_t m=35, n=45;
    double a[m*n];
    double x[m];
    double y[n];
    double z[n];
    size_t i;
    for(i=0; i<m*n; i++) a[i]=i;
    for(i=0; i<n; i++) x[i]=i+m*n;
    for(i=0; i<m; i++) y[i]=z[i]=i*i;

    my_dgemv(CblasRowMajor,CblasTrans,m,n,2.0,a,n,x,1,2.0,y,1);
    cblas_dgemv(CblasRowMajor,CblasTrans,m,n,2.0,a,n,x,1,2.0,z,1);
    for(i=0; i<m; i++){
	assert(y[i]==z[i]);
    }
}
Exemplo n.º 3
0
void test_dgemv()
{
    const size_t m=3, n=4;
    double a[3*4]={
	1,2,3,4,
	5,6,7,8,
	9,10,11,12
    };
    double x[4]={2,1,4,3};
    double y[3]={6,5,7};
    double z[3]={6,5,7};
    size_t i;
    my_dgemv(CblasRowMajor,CblasNoTrans,m,n,2.0,a,n,x,1,2.0,y,1);
    cblas_dgemv(CblasRowMajor,CblasNoTrans,m,n,2.0,a,n,x,1,2.0,z,1);
    for(i=0; i<m; i++){
	assert(y[i]==z[i]);
    }
}