time_zgels.c 2.28 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgels.c
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
7 8
 * @copyright 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @version 1.0.0
13 14
 * @precisions normal z -> c d s
 *
15
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
16
#define _TYPE  CHAMELEON_Complex64_t
17 18 19
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

Mathieu Faverge's avatar
Mathieu Faverge committed
20
#define _NAME  "CHAMELEON_zgels"
21 22 23 24 25
/* See Lawn 41 page 120 */
#define _FMULS (FMULS_GEQRF( M, N ) + FMULS_GEQRS( M, N, NRHS ))
#define _FADDS (FADDS_GEQRF( M, N ) + FADDS_GEQRS( M, N, NRHS ))

#include "./timing.c"
26
#include "timing_zauxiliary.h"
27 28

static int
Mathieu Faverge's avatar
Mathieu Faverge committed
29
RunTest(int *iparam, double *dparam, chameleon_time_t *t_) 
30
{
Mathieu Faverge's avatar
Mathieu Faverge committed
31
    CHAM_desc_t *T;
32
    PASTE_CODE_IPARAM_LOCALS( iparam );
33

34 35 36 37 38 39
    if ( M != N ) {
        fprintf(stderr, "This timing works only with M == N\n");
        return -1;
    }

    /* Allocate Data */
Mathieu Faverge's avatar
Mathieu Faverge committed
40 41 42 43
    PASTE_CODE_ALLOCATE_MATRIX( A,    1,     CHAMELEON_Complex64_t, LDA, N   );
    PASTE_CODE_ALLOCATE_MATRIX( x,    1,     CHAMELEON_Complex64_t, LDB, NRHS);
    PASTE_CODE_ALLOCATE_MATRIX( Acpy, check, CHAMELEON_Complex64_t, LDA, N   );
    PASTE_CODE_ALLOCATE_MATRIX( b,    check, CHAMELEON_Complex64_t, LDB, NRHS);
44

45
     /* Initialize Data */
Mathieu Faverge's avatar
Mathieu Faverge committed
46 47
    CHAMELEON_zplrnt( M, N,    A, LDA,  453 );
    CHAMELEON_zplrnt( M, NRHS, x, LDB, 5673 );
48

Mathieu Faverge's avatar
Mathieu Faverge committed
49 50
    CHAMELEON_Alloc_Workspace_zgels(M, N, &T, P, Q);
    memset(T->mat, 0, (T->llm*T->lln)*sizeof(ChamComplexDouble));
51 52 53 54 55 56 57 58

    /* Save A and b  */
    if (check) {
        LAPACKE_zlacpy_work(LAPACK_COL_MAJOR, 'A', M, N,    A, LDA, Acpy, LDA);
        LAPACKE_zlacpy_work(LAPACK_COL_MAJOR, 'A', M, NRHS, x, LDB, b,    LDB);
    }

    START_TIMING();
Mathieu Faverge's avatar
Mathieu Faverge committed
59
    CHAMELEON_zgels( ChamNoTrans, M, N, NRHS, A, LDA, T, x, LDB );
60 61 62 63 64 65 66 67 68 69 70 71
    STOP_TIMING();
    
    /* Check the solution */
    if (check)
    {
        dparam[IPARAM_RES] = z_check_solution(M, N, NRHS, Acpy, LDA, b, x, LDB,
                                              &(dparam[IPARAM_ANORM]), 
                                              &(dparam[IPARAM_BNORM]), 
                                              &(dparam[IPARAM_XNORM]));
        free(Acpy); free(b);
    }

Mathieu Faverge's avatar
Mathieu Faverge committed
72
    CHAMELEON_Dealloc_Workspace( &T );
73 74 75 76 77
    free( A );
    free( x );

    return 0;
}