pzlaset2.c 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
/**
 *
 * @copyright (c) 2009-2014 The University of Tennessee and The University 
 *                          of Tennessee Research Foundation. 
 *                          All rights reserved.
 * @copyright (c) 2012-2014 Inria. All rights reserved.
 * @copyright (c) 2012-2014 IPB. All rights reserved. 
 *
 **/

/**
 *
 * @file pzlaset2.c
 *
 *  MORSE auxiliary routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
 * @version 2.5.0
 * @comment This file has been automatically generated
 *          from Plasma 2.5.0 for MORSE 1.0.0
 * @author Hatem Ltaief
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
 **/
#include "common.h"

#define A(m,n) A,  m,  n
/***************************************************************************//**
 *  Parallel initializztion a 2-D array A to 
 *  ALPHA on the offdiagonals.
 **/
void morse_pzlaset2(MORSE_enum uplo, MORSE_Complex64_t alpha, 
                           MORSE_desc_t *A,
                           MORSE_sequence_t *sequence, MORSE_request_t *request)
{
    MORSE_context_t *morse;
    MORSE_option_t options;

    int i, j;
    int ldai, ldaj;
    int tempim;
    int tempjm, tempjn;
    int minmn = min(A->mt, A->nt);

    morse = morse_context_self();
    if (sequence->status != MORSE_SUCCESS)
        return;

    RUNTIME_options_init(&options, morse, sequence, request);

    if (uplo == MorseLower) {
       for (j = 0; j < minmn; j++){
           tempjm = j == A->mt-1 ? A->m-j*A->mb : A->mb;
           tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
           ldaj = BLKLDD(A, j);
           MORSE_TASK_zlaset2(
               &options,
               MorseLower, tempjm, tempjn, alpha,
               A(j, j), ldaj);

           for (i = j+1; i < A->mt; i++){
               tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
               ldai = BLKLDD(A, i);
               MORSE_TASK_zlaset2(
                   &options,
                   MorseUpperLower, tempim, tempjn, alpha,
                   A(i, j), ldai);
           }
       }
    }
    else if (uplo == MorseUpper) {
       for (j = 1; j < A->nt; j++){
           tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
           for (i = 0; i < min(j, A->mt); i++){
               tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
               ldai = BLKLDD(A, i);
               MORSE_TASK_zlaset2(
                   &options,
                   MorseUpperLower, tempim, tempjn, alpha,
                   A(i, j), ldai);
           }
       }
       for (j = 0; j < minmn; j++){
           tempjm = j == A->mt-1 ? A->m-j*A->mb : A->mb;
           tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
           ldaj = BLKLDD(A, j);
           MORSE_TASK_zlaset2(
               &options,
               MorseUpper, tempjm, tempjn, alpha,
               A(j, j), ldaj);
       }
    }
    else {
       for (i = 0; i < A->mt; i++){
           tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
           ldai = BLKLDD(A, i);
           for (j = 0; j < A->nt; j++){
               tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
               MORSE_TASK_zlaset2(
                   &options,
                   MorseUpperLower, tempim, tempjn, alpha,
                   A(i, j), ldai);
           }
       }
    } 
    RUNTIME_options_finalize(&options, morse);
    MORSE_TASK_dataflush_all();
}