help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] About invalid parameters in cblas implementation


From: José Luis García Pallero
Subject: Re: [Help-gsl] About invalid parameters in cblas implementation
Date: Tue, 7 Jul 2009 11:35:53 +0200

El 6 de julio de 2009 20:31, Brian Gough <address@hidden> escribió:

> >  I can try to implement the error checking for cblas_* functions in
> > my spare time, but problably will be a slow task.
>
> Given the similarity between the functions, perhaps it is possible the
> generate some of the checking code automatically with a script or at
> least reduce it to a few standard C macros.


I propose to make the checks with macros. In this way, we can use the same
macro for checking the arguments in the cblas_* function and in the
gsl_cblas_* wrapper. The arguments of the macro must be the arguments of the
function tocheck and an extra variable for store the result of the testing.
For example, for the functions *gemv (s, d, c and z versions performs the
same checks), the macro can be like:

#define GSL_ERROR_GEMV(pos,order,TransA,M,N,lda,incX,incY) \
(pos) = 0; \
if(((order)!=CblasRowMajor)&&((order)!=CblasColMajor)) { \
    (pos) = 1; \
} else
if(((TransA)!=CblasNoTrans)&&((TransA)!=CblasTrans)&&((TransA)!=CblasConjTrans))
{ \
    (pos) = 2; \
} else if((M)<0) { \
    (pos) = 3; \
} else if((N)<0) { \
    (pos) = 4; \
} else if((order)==CblasRowMajor) { \
    if((lda)<GEOCBLAS_MAX(1,(N))) { \
        (pos) = 7; \
    } \
} else if((order)==CblasColMajor) { \
    if((lda)<GEOCBLAS_MAX(1,(M))) { \
        (pos) = 7; \
    } \
} else if((incX)==0) { \
    (pos) = 9; \
} else if((incY)==0) { \
    (pos) = 12; \
}

The variable 'pos' stores the position of the incorrect argument in the list
of arguments of the original *gemv function and the value 0 if all are
correct.
The use of this macro in the cblas_*gemv function is like:

int pos = 0;
GSL_ERROR_GEMV(pos,order,TransA,M,N,lda,incX,incY);
if(pos!=0)
  cblas_xerbla(pos,"cblas_dgemv","");

And the use in gsl_cblas_*gemv:

int pos = 0;
GSL_ERROR_GEMV(pos,order,TransA,M,N,lda,incX,incY);
if(pos!=0) {
  call function for convert the 'pos' value into the correct GSL_ERROR_CODE
  return GSL_ERROR_CODE;
} else {
  cblas_*gemv(order,TransA,M,N,alpha,A,lda,X,incX,beta,Y,incY);
  return GSL_SUCCESS;
}

-- 
*****************************************
José Luis García Pallero
address@hidden
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************


reply via email to

[Prev in Thread] Current Thread [Next in Thread]