time_zgeqrf.c 2.1 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgeqrf.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.
Mathieu Faverge's avatar
Mathieu Faverge committed
7
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8
 *                      Univ. Bordeaux. All rights reserved.
9
 *
10
 ***
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @version 1.0.0
13 14
 * @precisions normal z -> c d s
 *
15
 */
16
#define _TYPE  CHAMELEON_Complex64_t
17 18 19
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

20
#define _NAME  "CHAMELEON_zgeqrf"
21 22 23 24 25
/* See Lawn 41 page 120 */
#define _FMULS FMULS_GEQRF(M, N)
#define _FADDS FADDS_GEQRF(M, N)

#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
{
31
    CHAM_desc_t *T;
32 33 34 35 36 37 38 39
    PASTE_CODE_IPARAM_LOCALS( iparam );

    if ( M != N && check ) {
        fprintf(stderr, "Check cannot be perfomed with M != N\n");
        check = 0;
    }

    /* Allocate Data */
40
    PASTE_CODE_ALLOCATE_MATRIX( A, 1, CHAMELEON_Complex64_t, LDA, N );
41 42

    /* Initialize Data */
43
    CHAMELEON_zplrnt(M, N, A, LDA, 3456);
44 45

    /* Allocate Workspace */
46
    CHAMELEON_Alloc_Workspace_zgels(M, N, &T, P, Q);
47 48

    /* Save AT in lapack layout for check */
49
    PASTE_CODE_ALLOCATE_COPY( Acpy, check, CHAMELEON_Complex64_t, A, LDA, N );
50 51

    START_TIMING();
52
    CHAMELEON_zgeqrf( M, N, A, LDA, T );
53
    STOP_TIMING();
54

55 56 57
    /* Check the solution */
    if ( check )
    {
58 59 60
        PASTE_CODE_ALLOCATE_MATRIX( X, 1, CHAMELEON_Complex64_t, LDB, NRHS );
        CHAMELEON_zplrnt( N, NRHS, X, LDB, 5673 );
        PASTE_CODE_ALLOCATE_COPY( B, 1, CHAMELEON_Complex64_t, X, LDB, NRHS );
61

62
        CHAMELEON_zgeqrs(M, N, NRHS, A, LDA, T, X, LDB);
63 64

        dparam[IPARAM_RES] = z_check_solution(M, N, NRHS, Acpy, LDA, B, X, LDB,
65 66
                                              &(dparam[IPARAM_ANORM]),
                                              &(dparam[IPARAM_BNORM]),
67 68
                                              &(dparam[IPARAM_XNORM]));

69 70
        free( Acpy );
        free( B );
71 72 73 74
        free( X );
      }

    /* Free Workspace */
75
    CHAMELEON_Dealloc_Workspace( &T );
76 77 78 79
    free( A );

    return 0;
}