pzgebrd_ge2gb.c 3.88 KB
Newer Older
1
/**
2 3
 *
 * @file pzgebrd_ge2gb.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
 * @brief Chameleon zgebrd_ge2gb parallel algorithm
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15 16 17 18 19
 * @author Hatem Ltaief
 * @author Azzam Haidar
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
20
 */
21 22
#include "control/common.h"

Mathieu Faverge's avatar
Mathieu Faverge committed
23 24
void morse_pzgebrd_ge2gb(CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *D,
                         RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
25 26 27
{
    int k;
    int tempkm, tempkn;
Mathieu Faverge's avatar
Mathieu Faverge committed
28
    CHAM_desc_t *A1, *A2, *T1, *D1 = NULL;
29

30
    if (A->m >= A->n){
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
31 32
        for (k = 0; k < A->nt; k++) {
            tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
33

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
34 35 36 37 38 39
            A1 = morse_desc_submatrix(A, k*A->mb,     k*A->nb, A->m-k*A->mb, tempkn);
            A2 = morse_desc_submatrix(A, k*A->mb, (k+1)*A->nb, A->m-k*A->mb, A->n-(k+1)*A->nb);
            T1 = morse_desc_submatrix(T, k*T->mb,     k*T->nb, T->m-k*T->mb, T->nb );
            if ( D != NULL ) {
                D1 = morse_desc_submatrix(D, k*D->mb, k*D->nb, D->m-k*D->mb, tempkn);
            }
40

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
41 42
            morse_pzgeqrf( A1, T1, D1,
                           sequence, request);
43

Mathieu Faverge's avatar
Mathieu Faverge committed
44
            morse_pzunmqr( ChamLeft, ChamConjTrans,
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
45 46
                           A1, A2, T1, D1,
                           sequence, request);
47

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
48
            if (k+1 < A->nt){
49
                tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
50

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
51 52 53 54 55 56
                A1 = morse_desc_submatrix(A,     k*A->mb, (k+1)*A->nb, tempkm,           A->n-(k+1)*A->nb);
                A2 = morse_desc_submatrix(A, (k+1)*A->mb, (k+1)*A->nb, A->m-(k+1)*A->mb, A->n-(k+1)*A->nb);
                T1 = morse_desc_submatrix(T,     k*T->mb, (k+1)*T->nb, T->mb,            T->n-(k+1)*T->nb);
                if ( D != NULL ) {
                    D1 = morse_desc_submatrix(D, k*D->mb, (k+1)*D->nb, tempkm,           D->n-(k+1)*D->nb);
                }
57

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
58 59
                morse_pzgelqf( A1, T1, D1,
                               sequence, request);
60

Mathieu Faverge's avatar
Mathieu Faverge committed
61
                morse_pzunmlq( ChamRight, ChamConjTrans,
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
62 63 64 65
                               A1, A2, T1, D1,
                               sequence, request);
            }
        }
66 67
    }
    else{
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
68 69
        for (k = 0; k < A->mt; k++) {
            tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
70

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
71 72 73 74 75 76 77 78
            A1 = morse_desc_submatrix(A,     k*A->mb, k*A->nb, tempkm,           A->n-k*A->nb);
            A2 = morse_desc_submatrix(A, (k+1)*A->mb, k*A->nb, A->m-(k+1)*A->mb, A->n-k*A->nb);
            T1 = morse_desc_submatrix(T,     k*T->mb, k*T->nb, T->mb,            T->n-k*T->nb);
            if ( D != NULL ) {
                D1 = morse_desc_submatrix(D, k*D->mb, k*D->nb, tempkm,           D->n-k*D->nb);
            }
            morse_pzgelqf( A1, T1, D1,
                           sequence, request);
79

Mathieu Faverge's avatar
Mathieu Faverge committed
80
            morse_pzunmlq( ChamRight, ChamConjTrans,
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
81 82
                           A1, A2, T1, D1,
                           sequence, request);
83

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
84
            if (k+1 < A->mt){
85
                tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
86

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
87 88 89 90 91 92
                A1 = morse_desc_submatrix(A, (k+1)*A->mb,     k*A->nb, A->m-(k+1)*A->mb, tempkn);
                A2 = morse_desc_submatrix(A, (k+1)*A->mb, (k+1)*A->nb, A->m-(k+1)*A->mb, A->n-(k+1)*A->nb);
                T1 = morse_desc_submatrix(T, (k+1)*T->mb,     k*T->nb, T->m-(k+1)*T->mb, T->nb );
                if ( D != NULL ) {
                    D1 = morse_desc_submatrix(D, (k+1)*D->mb, k*D->nb, D->m-(k+1)*D->mb, tempkn);
                }
93

Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
94 95
                morse_pzgeqrf( A1, T1, D1,
                               sequence, request);
96

Mathieu Faverge's avatar
Mathieu Faverge committed
97
                morse_pzunmqr( ChamLeft, ChamConjTrans,
Mathieu Faverge's avatar
Minor  
Mathieu Faverge committed
98 99 100 101
                               A1, A2, T1, D1,
                               sequence, request);
            }
        }
102 103
    }
}