Commit b9439882 authored by Mathieu Faverge's avatar Mathieu Faverge

start factorizing the code to reduce code complexity

parent 2f7fceb0
......@@ -21,59 +21,76 @@
#include <string.h>
#include <assert.h>
/* static int libhqr_qrtree_getinon0( const qr_piv_t *arg, */
/* const int k, int i, int mt ); */
#define ENDCHECK( test, ret ) \
do { \
if ( !test ) { \
assert( ret == 0 ); \
return ret; \
} \
}while (0)
} while (0)
/**
* @brief Check Formula for NB geqrt
* @param[in] qrtree
* The reduction tree on which to check the number of geqrt calls.
* @retval True if ok, False if an error was found.
*
* This functions checks the number of tiles of type 1, 2 or 3 per column and
* make sure it matches the value returned by getnbgeqrf() subfunction.
*/
int
libhqr_check( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree)
libhqr_check_nbgeqrf( const libhqr_tree_t *qrtree )
{
int i, m, k, nb, m0;
int check;
int check = 1;
int k, nb, m, m0;
int checkTS = (qrtree->facto == LIBHQR_TSQR) || (qrtree->facto == LIBHQR_TSLQ);
int a = qrtree->a;
int p = qrtree->p;
int checkTS = (qrtree->facto == LIBHQR_TSQR) || (qrtree->facto == LIBHQR_TSLQ);
/*
* Check Formula for NB geqrt
*/
{
/* libhqr_print_type( A, qrtree ); */
/* libhqr_print_nbgeqrt( A, qrtree ); */
check = 1;
for (k=0; k<qrtree->nt; k++) {
nb = 0;
m0 = checkTS ? 0 : k;
for (m=m0; m < qrtree->mt; m++) {
if ( qrtree->gettype( qrtree, k, m ) > 0 ) {
nb++;
}
}
#if defined(DEBUG_WITH_PRINT)
libhqr_print_type( A, qrtree );
libhqr_print_nbgeqrt( A, qrtree );
#endif
if ( nb != qrtree->getnbgeqrf( qrtree, k ) ) {
check = 0;
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
" Check number of geqrt:\n"
" For k=%d => return %d instead of %d",
a, p, A->mt, A->nt, k, qrtree->getnbgeqrf( qrtree, k ), nb );
for (k=0; k<qrtree->nt; k++) {
nb = 0;
m0 = checkTS ? 0 : k;
for (m=m0; m < qrtree->mt; m++) {
if ( qrtree->gettype( qrtree, k, m ) > 0 ) {
nb++;
}
}
ENDCHECK( check, 1 );
if ( nb != qrtree->getnbgeqrf( qrtree, k ) ) {
check = 0;
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
" Check number of geqrt:\n"
" For k=%d => return %d instead of %d",
a, p, qrtree->mt, qrtree->nt, k, qrtree->getnbgeqrf( qrtree, k ), nb );
}
}
/*
* Check indices of geqrt
*/
return check;
}
int
libhqr_check( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree)
{
int i, m, k, nb, m0;
int check;
int a = qrtree->a;
int p = qrtree->p;
int checkTS = (qrtree->facto == LIBHQR_TSQR) || (qrtree->facto == LIBHQR_TSLQ);
/* Check the number of geqrt */
check = libhqr_check_nbgeqrf( qrtree );
ENDCHECK( check, 1 );
/* Check indices of geqrt */
{
int prevm = -1;
check = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment