Commit 46e54e52 authored by Mathieu Faverge's avatar Mathieu Faverge

Add a tshqr function to evaluate the difference with tphqr

parent bc9c02e6
......@@ -209,6 +209,10 @@ int libhqr_init_tphqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, const libhqr_matrix_t *A,
libhqr_tree_e hlvl, int a, int p );
int libhqr_init_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt,
const libhqr_matrix_t *A );
void libhqr_finalize( libhqr_tree_t *qrtree );
/**
......
......@@ -56,6 +56,118 @@ tphqr_getm( const libhqr_tree_t *qrtree, int k, int i )
return killers[i];
}
static int
tshqr_getnbgeqrf( const libhqr_tree_t *qrtree, int k )
{
(void)qrtree;
(void)k;
return 1;
}
static int
tshqr_getm( const libhqr_tree_t *qrtree, int k, int i )
{
(void)qrtree;
(void)k;
(void)i;
return 0;
}
int
libhqr_initmtx_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt,
const libhqr_matrix_t *A )
{
libhqr_tile_args_t *args;
libhqr_tile_info_t *tileinfo;
int *pivots;
int low_mt, j, k, l;
if (qrtree == NULL) {
fprintf(stderr, "libhqr_hqr_init, illegal value of qrtree");
return -1;
}
if ((trans != LIBHQR_TSQR) &&
(trans != LIBHQR_TSLQ)) {
fprintf(stderr, "libhqr_hqr_init, illegal value of trans");
return -2;
}
if (A == NULL) {
fprintf(stderr, "libhqr_hqr_init, illegal value of A");
return -3;
}
libhqr_rdmtx_initfct( qrtree );
qrtree->init = LIBHQR_QRTREE_MTX;
qrtree->facto = trans;
qrtree->getnbgeqrf = tshqr_getnbgeqrf;
qrtree->getm = tshqr_getm;
qrtree->mt = (trans == LIBHQR_TSQR) ? A->mt : A->nt;
qrtree->nt = kt;
low_mt = qrtree->mt;
qrtree->p = 1;
qrtree->a = 1;
qrtree->args = malloc( sizeof(libhqr_tile_args_t) );
args = (libhqr_tile_args_t*)qrtree->args;
args->tileinfo = malloc( qrtree->mt * qrtree->nt * sizeof(libhqr_tile_info_t) );
args->killers = NULL;
args->pivots = malloc( qrtree->nt * sizeof(int) );
args->nbgeqrf = NULL;
tileinfo = args->tileinfo;
pivots = args->pivots;
/* Initialize the matrix */
for (k=0; k<qrtree->nt; k++, tileinfo += qrtree->mt)
{
tileinfo[0].type = LIBHQR_KILLED_BY_LOCALTREE;
tileinfo[0].index = 0;
tileinfo[0].currpiv = -1;
tileinfo[0].nextpiv = qrtree->mt;
tileinfo[0].prevpiv = qrtree->mt;
tileinfo[0].first_nextpiv = qrtree->mt;
tileinfo[0].first_prevpiv = qrtree->mt;
for (j=1; j<low_mt-lt; j++, l++) {
tileinfo[j].type = LIBHQR_KILLED_BY_TS;
tileinfo[j].index = -2;
tileinfo[j].currpiv = 0;
tileinfo[j].nextpiv = qrtree->mt;
tileinfo[j].prevpiv = qrtree->mt;
tileinfo[j].first_nextpiv = qrtree->mt;
tileinfo[j].first_prevpiv = qrtree->mt;
/* If first_nextpiv is undefined, it is the current tile */
if ( tileinfo[0].first_nextpiv == qrtree->mt ) {
tileinfo[0].first_nextpiv = j;
}
/* The previous tile is the former first_prevpiv, and the current one become the first_prevpiv */
if ( tileinfo[0].first_prevpiv != qrtree->mt ) {
tileinfo[tileinfo[0].first_prevpiv].nextpiv = j;
tileinfo[j].prevpiv = tileinfo[0].first_prevpiv;
}
tileinfo[0].first_prevpiv = j;
}
/* Let's register elt1 as the first pivot */
pivots[k] = 0;
lt--;
}
return 0;
}
int
libhqr_init_tshqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, const libhqr_matrix_t *A )
{
return libhqr_initmtx_tshqr( qrtree, trans, kt, lt, A );
}
int
libhqr_initmtx_tphqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, int kt, int lt, const libhqr_matrix_t *A,
......@@ -167,7 +279,7 @@ libhqr_initmtx_tphqr( libhqr_tree_t *qrtree,
lists2[i] = lists3[i];
lists3[i] = NULL;
}
/* Handle TS tiles */
l = 0;
for (i=0; i<p; i++) {
......@@ -390,4 +502,3 @@ libhqr_init_tphqr( libhqr_tree_t *qrtree,
{
return libhqr_initmtx_tphqr( qrtree, trans, kt, lt, A, hlvl, a, p );
}
......@@ -42,5 +42,12 @@ main(int argc, char ** argv)
libhqr_print_svg( &qrtree, "tphqr.svg" );
libhqr_finalize( &qrtree );
rc = libhqr_init_tshqr( &qrtree, LIBHQR_TSQR, NT, 0, &matrix );
if ( rc != 0 ) {
return EXIT_FAILURE;
}
libhqr_print_svg( &qrtree, "tshqr.svg" );
libhqr_finalize( &qrtree );
return EXIT_SUCCESS;
}
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