time_zgeqrf.c 2.14 KB
Newer Older
1 2
/**
 *
3 4
 * @copyright (c) 2009-2014 The University of Tennessee and The University
 *                          of Tennessee Research Foundation.
5 6
 *                          All rights reserved.
 * @copyright (c) 2012-2014 Inria. All rights reserved.
7
 * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 **/

/**
 *
 * @precisions normal z -> c d s
 *
 **/
#define _TYPE  MORSE_Complex64_t
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

#define _NAME  "MORSE_zgeqrf"
/* 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
29
RunTest(int *iparam, double *dparam, morse_time_t *t_)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
{
    MORSE_desc_t *T;
    PASTE_CODE_IPARAM_LOCALS( iparam );

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

    /* Allocate Data */
    PASTE_CODE_ALLOCATE_MATRIX( A, 1, MORSE_Complex64_t, LDA, N );

    /* Initialize Data */
    MORSE_zplrnt(M, N, A, LDA, 3456);

    /* Allocate Workspace */
46
    MORSE_Alloc_Workspace_zgels(M, N, &T, P, Q);
47
    memset(T->mat, 0, (T->llm*T->lln)*sizeof(MorseComplexDouble));
48 49 50 51 52 53 54

    /* Save AT in lapack layout for check */
    PASTE_CODE_ALLOCATE_COPY( Acpy, check, MORSE_Complex64_t, A, LDA, N );

    START_TIMING();
    MORSE_zgeqrf( M, N, A, LDA, T );
    STOP_TIMING();
55

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

63 64 65
        MORSE_zgeqrs(M, N, NRHS, A, LDA, T, X, LDB);

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

70 71
        free( Acpy );
        free( B );
72 73 74 75 76 77 78 79 80
        free( X );
      }

    /* Free Workspace */
    MORSE_Dealloc_Workspace( &T );
    free( A );

    return 0;
}