libflame  revision_anchor
Functions
zhetrd.c File Reference

(r)

Functions

int zhetrd_fla (char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info)

Function Documentation

int zhetrd_fla ( char *  uplo,
integer n,
doublecomplex a,
integer lda,
doublereal d__,
doublereal e,
doublecomplex tau,
doublecomplex work,
integer lwork,
integer info 
)

References doublecomplex::i, doublecomplex::r, and zhetd2_fla().

{
    /* System generated locals */
    integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
    doublecomplex z__1;
    /* Local variables */
    integer i__, j, nb, kk, nx, iws;
    extern logical lsame_(char *, char *);
    integer nbmin, iinfo;
    logical upper;
    extern /* Subroutine */
    int zhetd2_fla(char *, integer *, doublecomplex *, integer *, doublereal *, doublereal *, doublecomplex *, integer *), zher2k_(char *, char *, integer *, integer *, doublecomplex *, doublecomplex *, integer *, doublecomplex *, integer *, doublereal *, doublecomplex *, integer *), xerbla_(char *, integer *);
    extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *);
    extern /* Subroutine */
    int zlatrd_(char *, integer *, integer *, doublecomplex *, integer *, doublereal *, doublecomplex *, doublecomplex *, integer *);
    integer ldwork, lwkopt;
    logical lquery;
    /* -- LAPACK computational routine (version 3.4.0) -- */
    /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
    /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
    /* November 2011 */
    /* .. Scalar Arguments .. */
    /* .. */
    /* .. Array Arguments .. */
    /* .. */
    /* ===================================================================== */
    /* .. Parameters .. */
    /* .. */
    /* .. Local Scalars .. */
    /* .. */
    /* .. External Subroutines .. */
    /* .. */
    /* .. Intrinsic Functions .. */
    /* .. */
    /* .. External Functions .. */
    /* .. */
    /* .. Executable Statements .. */
    /* Test the input parameters */
    /* Parameter adjustments */
    a_dim1 = *lda;
    a_offset = 1 + a_dim1;
    a -= a_offset;
    --d__;
    --e;
    --tau;
    --work;
    /* Function Body */
    *info = 0;
    upper = lsame_(uplo, "U");
    lquery = *lwork == -1;
    if (! upper && ! lsame_(uplo, "L"))
    {
        *info = -1;
    }
    else if (*n < 0)
    {
        *info = -2;
    }
    else if (*lda < max(1,*n))
    {
        *info = -4;
    }
    else if (*lwork < 1 && ! lquery)
    {
        *info = -9;
    }
    if (*info == 0)
    {
        /* Determine the block size. */
        nb = ilaenv_(&c__1, "ZHETRD", uplo, n, &c_n1, &c_n1, &c_n1);
        lwkopt = *n * nb;
        work[1].r = (doublereal) lwkopt;
        work[1].i = 0.; // , expr subst
    }
    if (*info != 0)
    {
        i__1 = -(*info);
        xerbla_("ZHETRD", &i__1);
        return 0;
    }
    else if (lquery)
    {
        return 0;
    }
    /* Quick return if possible */
    if (*n == 0)
    {
        work[1].r = 1.;
        work[1].i = 0.; // , expr subst
        return 0;
    }
    nx = *n;
    iws = 1;
    if (nb > 1 && nb < *n)
    {
        /* Determine when to cross over from blocked to unblocked code */
        /* (last block is always handled by unblocked code). */
        /* Computing MAX */
        i__1 = nb;
        i__2 = ilaenv_(&c__3, "ZHETRD", uplo, n, &c_n1, &c_n1, & c_n1); // , expr subst
        nx = max(i__1,i__2);
        if (nx < *n)
        {
            /* Determine if workspace is large enough for blocked code. */
            ldwork = *n;
            iws = ldwork * nb;
            if (*lwork < iws)
            {
                /* Not enough workspace to use optimal NB: determine the */
                /* minimum value of NB, and reduce NB or force use of */
                /* unblocked code by setting NX = N. */
                /* Computing MAX */
                i__1 = *lwork / ldwork;
                nb = max(i__1,1);
                nbmin = ilaenv_(&c__2, "ZHETRD", uplo, n, &c_n1, &c_n1, &c_n1);
                if (nb < nbmin)
                {
                    nx = *n;
                }
            }
        }
        else
        {
            nx = *n;
        }
    }
    else
    {
        nb = 1;
    }
    if (upper)
    {
        /* Reduce the upper triangle of A. */
        /* Columns 1:kk are handled by the unblocked method. */
        kk = *n - (*n - nx + nb - 1) / nb * nb;
        i__1 = kk + 1;
        i__2 = -nb;
        for (i__ = *n - nb + 1;
                i__2 < 0 ? i__ >= i__1 : i__ <= i__1;
                i__ += i__2)
        {
            /* Reduce columns i:i+nb-1 to tridiagonal form and form the */
            /* matrix W which is needed to update the unreduced part of */
            /* the matrix */
            i__3 = i__ + nb - 1;
            zlatrd_(uplo, &i__3, &nb, &a[a_offset], lda, &e[1], &tau[1], & work[1], &ldwork);
            /* Update the unreduced submatrix A(1:i-1,1:i-1), using an */
            /* update of the form: A := A - V*W**H - W*V**H */
            i__3 = i__ - 1;
            z__1.r = -1.;
            z__1.i = -0.; // , expr subst
            zher2k_(uplo, "No transpose", &i__3, &nb, &z__1, &a[i__ * a_dim1 + 1], lda, &work[1], &ldwork, &c_b23, &a[a_offset], lda);
            /* Copy superdiagonal elements back into A, and diagonal */
            /* elements into D */
            i__3 = i__ + nb - 1;
            for (j = i__;
                    j <= i__3;
                    ++j)
            {
                i__4 = j - 1 + j * a_dim1;
                i__5 = j - 1;
                a[i__4].r = e[i__5];
                a[i__4].i = 0.; // , expr subst
                i__4 = j;
                i__5 = j + j * a_dim1;
                d__[i__4] = a[i__5].r;
                /* L10: */
            }
            /* L20: */
        }
        /* Use unblocked code to reduce the last or only block */
        zhetd2_fla(uplo, &kk, &a[a_offset], lda, &d__[1], &e[1], &tau[1], &iinfo);
    }
    else
    {
        /* Reduce the lower triangle of A */
        i__2 = *n - nx;
        i__1 = nb;
        for (i__ = 1;
                i__1 < 0 ? i__ >= i__2 : i__ <= i__2;
                i__ += i__1)
        {
            /* Reduce columns i:i+nb-1 to tridiagonal form and form the */
            /* matrix W which is needed to update the unreduced part of */
            /* the matrix */
            i__3 = *n - i__ + 1;
            zlatrd_(uplo, &i__3, &nb, &a[i__ + i__ * a_dim1], lda, &e[i__], & tau[i__], &work[1], &ldwork);
            /* Update the unreduced submatrix A(i+nb:n,i+nb:n), using */
            /* an update of the form: A := A - V*W**H - W*V**H */
            i__3 = *n - i__ - nb + 1;
            z__1.r = -1.;
            z__1.i = -0.; // , expr subst
            zher2k_(uplo, "No transpose", &i__3, &nb, &z__1, &a[i__ + nb + i__ * a_dim1], lda, &work[nb + 1], &ldwork, &c_b23, &a[ i__ + nb + (i__ + nb) * a_dim1], lda);
            /* Copy subdiagonal elements back into A, and diagonal */
            /* elements into D */
            i__3 = i__ + nb - 1;
            for (j = i__;
                    j <= i__3;
                    ++j)
            {
                i__4 = j + 1 + j * a_dim1;
                i__5 = j;
                a[i__4].r = e[i__5];
                a[i__4].i = 0.; // , expr subst
                i__4 = j;
                i__5 = j + j * a_dim1;
                d__[i__4] = a[i__5].r;
                /* L30: */
            }
            /* L40: */
        }
        /* Use unblocked code to reduce the last or only block */
        i__1 = *n - i__ + 1;
        zhetd2_fla(uplo, &i__1, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[i__], &tau[i__], &iinfo);
    }
    work[1].r = (doublereal) lwkopt;
    work[1].i = 0.; // , expr subst
    return 0;
    /* End of ZHETRD */
}